This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, libstdc++, complex] complex multiplication algorithm improved


Paolo, I tested the patch with this program :

#include <complex>
#include <iostream>
#include <ctime>

using namespace std;

int main()
{
    unsigned long long l = clock();

    complex<long long> a;

    a.real() = l & 0xFFFFFFFF;
    a.imag() = l & 0xFFFFFFFF0000;
    a.imag() >>= 32;

    unsigned long long i = clock();
    for ( unsigned long i = 1; i < 1000000000; ++i )
        a *= a;
    unsigned long long j = clock();

    cout << "\nclocks: " << j - i << endl;
    cout << a;

    return 0;
}

the one compiled with the patched <complex> outputs 34930000, while
the one with old <complex> outputs 37430000.

The linux's running as a virtual machine, kernel is 2.6.35, 32 bit,
and cpu info is:

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 Duo CPU     E4600  @ 2.40GHz
stepping        : 13
cpu MHz         : 2297.903
cache size      : 6144 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca
cmov pat pse36 clflush mmx fxsr sse sse2 constant_tsc up pni monitor
ssse3
bogomips        : 4597.29
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:



On 15 September 2010 17:24, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> On 09/15/2010 11:22 AM, Wang Feng wrote:
>> On 15 September 2010 16:58, Basile Starynkevitch
>> <basile@starynkevitch.net> wrote:
>>
>>> Are you sure it is worth it?
>>>
>> It depends, it is faster on my linux-pc.
>>
> It is faster how and when? Because for float / double / long double you
> are *not* using that code *at all*.
>
> Paolo.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]