Sunday, March 26, 2006

gmp 4.2 on MacIntel

Good news. With gmp 4.2 assembly optimization works. That means that you can get decent performances. For values of decent that are *below* those of an old Prescott and just a bit better than those of a plain Pentium M with the same clock.

The problem is that (for example) you can't run make check. This makes me thing something is broken. However, I can't understand what. However I've been told that "MacIntels" are not supported by gmp-4.2 . So consider twice before buying a MacIntel if you need to work with gmp.

And you can't use c++ too. For some reason there is an error with the generation of an assembly optimization. The answer from the developers has been "gmp-4.2 is not supported on MacIntels" (however I am not really able to consider this a solution to the problem, but unfortunately I'm not skilled enought to fix things by myself).

In fact the second core is not used at all, so this result is quite predictable. Moreover I used shared libraries instead of static ones (for the very good reasons that the guys at apple don't ship the gcc with the static version of libgcc and of crt0.o, so there is no easy way to do it).

In the end I assume MacOS X on Intel is young and probably not as optimized as a FreeBSD (just to name one). These are the results:

iMac 2 GHz 2 GB

***** GMPbench version 0.1 ***** 
Using default CFLAGS = "-O3 -fomit-frame-pointer -I../gmp-4.2" 
Using default CC = "gcc" 
Using default LIBS = "-lgmp -L../gmp-4.2/.libs" 
Using compilation command: gcc -O3 -fomit-frame-pointer -I../gmp-4.2 foo.c -o foo -lgmp -L../gmp-4.2/.libs 
You may want to override CC, CFLAGS, and LIBS 
Using gmp version: 4.2 
Compiling benchmarks 
Running benchmarks 
Category base 
Program multiply 
multiply 128 128 
GMPbench.base.multiply.128,128 result: 9530908 
multiply 512 512 
GMPbench.base.multiply.512,512 result: 1150785 
multiply 8192 8192 
GMPbench.base.multiply.8192,8192 result: 12500 
multiply 131072 131072 
GMPbench.base.multiply.131072,131072 result: 228 
multiply 2097152 2097152 
GMPbench.base.multiply.2097152,2097152 result: 9.62 
GMPbench.base.multiply result: 12463 
Program divide 
divide 8192 32 
GMPbench.base.divide.8192,32 result: 306090 
divide 8192 64 
GMPbench.base.divide.8192,64 result: 104119 
divide 8192 128 
GMPbench.base.divide.8192,128 result: 66800 
divide 8192 4096 
GMPbench.base.divide.8192,4096 result: 20668 
divide 8192 8064 
GMPbench.base.divide.8192,8064 result: 268859 
divide 131072 8192 
GMPbench.base.divide.131072,8192 result: 435 
divide 131072 65536 
GMPbench.base.divide.131072,65536 result: 242 
divide 8388608 4194304 
GMPbench.base.divide.8388608,4194304 result: 0.796 
GMPbench.base.divide result: 5617.3 
GMPbench.base result: 8367.1 
Category app 
Program rsa 
rsa 512 
GMPbench.app.rsa.512 result: 2755 
rsa 1024 
GMPbench.app.rsa.1024 result: 478 
rsa 2048 
GMPbench.app.rsa.2048 result: 72.6 
GMPbench.app.rsa result: 457.26 
GMPbench.app result: 457.26 
GMPbench result: 1956 

No comments: