Re: slow complex<double>'s with g++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Budge wrote:
> It may be that I'm missing something, but you appear to be computing
> different things...
> 
> Zi = 2.0*Zr*Zi + Ci;
> Zr = Tr - Ti + Cr;
> 
> vs
> 
>  Z = Z*Z + C;
> 
> No doubt the 2.0 makes a difference...

    Hmm.  I don't get what you are saying.  Squaring a complex number
like a+ib you get...

(a+ib) * (a+ib)
a*a + iab + iab - b*b
(a*a - b*b) + i2ab

...Are you saying a multiplication instead of an addition is the cause?
Yes, the C version is a little more optimized, but I was surprised at
the factor of 8.5 time difference for gcc-4.1pre021006.  I guess I
expecting something small, say a 20-50% slowdown.  And you get all of
the speed back if you just use "-ffast-math".  Maybe I'm just surprised
that the optimizations that "-ffast-math" turns on do such a good job.

Greg Buchholz


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux