W3bbo wrote:

TimP wrote:
Perhaps gcc is performing optimizations that VC++ is not. Try compiling them both with no optimizations and test the run times. If they're equivalent, then gcc is optimizing more aggressively, otherwise the culprit is elsewhere.


Optimizations are good... but I'd never expect a 50% gain in performance with them.


The gain in performance is far greater than 50% depending on the test case, as when I ran the original tests, I had the multithreaded code path enabled in Visual Studio. I reran them with the single threaded code path and posted the new numbers not that long ago.

I will restate them with gains in performance computated:

It takes 1 second to test M0 through M2281 on Ubuntu and 5 seconds on Windows, making Ubuntu 400% faster.
It takes 5 seconds to test M0 through M3217 on Ubuntu and 12 seconds on Windows, making Ubuntu 140% faster.
It takes 6 seconds to test M2281 through M3217 on Ubuntu and 17 seconds on Windows, making Ubuntu 183% faster.
It takes 7 seconds to test M21701 on Ubuntu and 20 seconds on Windows, making Ubuntu 186% faster.

TimP wrote:

W3bbo wrote:

TimP wrote:
Perhaps gcc is performing optimizations that VC++ is not. Try compiling them both with no optimizations and test the run times. If they're equivalent, then gcc is optimizing more aggressively, otherwise the culprit is elsewhere.



Optimizations are good... but I'd never expect a 50% gain in performance with them.



I would assume so too, but it's worth ruling out.

I'm slightly confused by the invocation of gcc.

gcc -m32 -O2 -fomit-frame-pointer -mtune=k8 -march=k8 mersenne.c /usr/local/lib/gmp.so

Adding the path to gmp.so, in particular. If my understanding of the gcc documentation is accurate, it will regard gmp.so as an "in file", which would seem to imply (if gcc is not complaining) that gmp.so is being statically linked with your executable. You can test this by running ldd yourbinary. If you don't see gmp.so in the output, you're statically linking. I'm not well versed on VC++, so I don't know if your VC++ build is performing static linking or how you would check on Windows. Can anyone chime in?

Back to the point at hand though, if this was the case you should have a fixed delay since dynamic linking resolution is done at invocation and the runtime differences would always be different by a roughly fixed amount.



Here is the output:

richard@richard-desktop:~$ ldd ./a.out
        linux-gate.so.1 =>  (0xffffe000)
        libgmp.so.3 => /usr/local/lib/libgmp.so.3 (0xb7f7a000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e40000)
        /lib/ld-linux.so.2 (0xb7fb4000)