Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development Tools (Compilers, Debuggers, Profilers & Analyzers)
- Intel® Fortran Compiler
- Speed of REAL*8 and COMPLEX*8 number multiplication

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

Kumara_M_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-26-2017
09:15 AM

4 Views

Speed of REAL*8 and COMPLEX*8 number multiplication

**Hi,**

**I need to compare the speed of operation of REAL*8 and COMPLEX*8 number multiplication/ summation process. I used following code for that.**

**I presumed that real number multiplication should be at least 4 times faster than the complex number multiplication. Because mathematically we can show, to get the product of two complex numbers (e.g. product of X= a+ib and Y=c+id can be given as X*Y=a*c-b*d+i(a*d+b*c) ) we need to do 4 real number multiplications.**

**However, when I run following code in my computer I did't see that such a difference between real and complex number multiplication process. Sometime real number multiplication time is solver than the complex number.**

**How that is possible to get such a results? **

**Is this because of that complex number multiplication process is being parallely processed?**

**Thanks,**

**Kumara**

=============code=============================

REAL*8 :: realA(10000) ,realB(10000),realC(10000), startTime, midTime, endTime, Total_realTime, Total_complxTime

COMPLEX*8 cmplxA(10000), cmplxB(10000), cmplxC(10000)

integer I, K

realA = 1.0111143434

realB = -1.111143434

cmplxA = (1.0111143434, 1.0111143434)

cmplxB = (1.111143434, -1.0111143434)

CALL CPU_TIME(startTime)

DO I =1,10000000000

DO K =1, 10000

realC(K) = realA(K)*realB(K)+realA(K)*realB(K)

ENDDO

ENDDO

CALL CPU_TIME(midTime)

DO I =1,10000000000

DO K =1, 10000

cmplxC(K) = cmplxA(K)*cmplxB(K)+cmplxA(K)*cmplxB(K)

ENDDO

ENDDO

CALL CPU_TIME(endTime)

Total_realTime= midTime - startTime

Total_complxTime = endTime- midTime

WRITE(*,*) 'REAL NUMBER OPERATION TIME', realTime

WRITE(*,*) 'COMPLEX NUMBER OPERATION TIME',complxTime

2 Replies

Highlighted
##

Martyn_C_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-28-2017
09:14 AM

4 Views

This is because you are doing

This is because you are doing double precision real multiplication but single precision complex multiplication.

I think the misunderstanding is in COMPLEX*8 - this allocates 8 bytes to the complex number, so it consists of two 4-byte reals, i.e., single precision.

If you would use COMPLEX(8) instead, the complex data type consists of two 8-byte reals, so 16 bytes in all. (Reals don't have this problem, REAL*8 is the same as REAL(8) ). If you run with COMPLEX(8), you should see that complex multiplications run several times slower than real ones, since you are doing 4 real multiplications, an addition and a subtraction. (And possibly a shuffle, if part of a vectorized loop).

Highlighted
##

Kumara_M_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-28-2017
06:29 PM

4 Views

It make sense, thnak you very

It make sense, thank you very much

For more complete information about compiler optimizations, see our Optimization Notice.