gmp 4.2 on MacIntel
March 26th, 2006
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
3 Responses to “gmp 4.2 on MacIntel”
1aleax
April 6th, 2006 @ 23:17
I problemi con make check sono dovuti a un bug (o strana feature;-) dell’ld di Apple, che elimina dal link i .o che forniscono “solo” dati (non funzioni). Basta (come gia` su Apple PPC) una piccola pezza che forzi una dipendenza-funzione cosi` che si soddisfino anche quelle dati!-) Ad esempio, questa pippo.patch:
— gmp-4.2.orig/tests/x86call.asm 2006-03-14 10:57:54.000000000 -0500
+++ gmp-4.2/tests/x86call.asm 2006-04-06 00:10:03.000000000 -0400
@@ -110,8 +110,20 @@
movl G(calling_conventions_save_esi), %esi
movl G(calling_conventions_save_edi), %edi
movl G(calling_conventions_save_ebp), %ebp
jmp *G(calling_conventions_retaddr)
EPILOGUE()
+
+C void gmp_x86check_workaround_apple_ld_bug()
+C
+C Apple ld has an annoying bug that causes it to only load members from
+C static archives that satisfy text symbol dependencies. This procedure
+C creates a bogus dependency on a text symbol in x86check.o (in libtests.a)
+C to ensure that ld loads it, also making all of the needed non-text
+C symbols available.
+
+PROLOGUE(gmp_x86check_workaround_apple_ld_bug)
+ jmp *G(calling_conventions_check)
+EPILOGUE()
patch -p0 di questa, e il make check passa al volo.
Rik0, non ho il tempo di sottoporre questa patch alla gente di GMP (vado al Gran Canyon per 10gg, yeah!), potresti please farlo tu? Posterei l’informazione anche su i.c.m ma individual.net fa le bizze… grazie!
Alex
2Enrico Franchi
April 7th, 2006 @ 02:25
Grazie mille!
Sembra che la patch non funzioni, immagino problemi di spazi o simili passando per e-mail e compagnia. Mettendo a posto il file a mano non funziona proprio (nel senso che non risolve l’errore)
A breve mando il bug-fix a gmp e su icm, appena ho capito come devo fare.
$ patch -p0 < patch.apple
patching file gmp-4.2/tests/x86call.asm
patch unexpectedly ends in middle of line
patch: **** malformed patch at line 22:
anche se a me non sembra abbia effettivamente problemi.
3Enrico Franchi
April 7th, 2006 @ 03:47
Stupido io: avevo modificato male il file.
Adesso funziona tutto.
Grazie mille e divertiti!
Leave a Reply