Did you compile the ubuntu GMP library yourself, or do they come as 
packaged binaries? (sorry I don't know anything about ubuntu)

If you compiled them yourself, what is the CFLAGS string that GMP's 
configure program produces? Is it the same as what the GMP inside SAGE 
produces? In fact it would be interesting to see some other settings, 
like which mpn subdirectory is activated, etc.

This is a very puzzling problem, I hope we can get to the bottom of it.

david

On Jul 30, 2007, at 5:36 PM, Jonathan Bober wrote:

>
> Here are some examples of timings with different compilation options.
> (I'm using 3*10^8) here because it takes long enough to see the
> difference, but short enough to conveniently run lots of tests.
>
> After running hg_sage.pull() to get the newest version, of the code, I
> get:
>
> sage: time a = number_of_partitions(300000000, algorithm='bober')
> CPU times: user 46.81 s, sys: 0.04 s, total: 46.85 s
> Wall time: 47.19
>
> Now I copy the code somewhere else and compile it, linking it to the
> Ubuntu-installed libraries:
>
> [EMAIL PROTECTED]:~/sage-2.7.1/sage-2.7.1/devel/sage-bober/sage/combinat$ cp 
> partitions_c.cc ~/temp/
> [EMAIL PROTECTED]:~/sage-2.7.1/sage-2.7.1/devel/sage-bober/sage/combinat$ cd 
> ~/temp
> [EMAIL PROTECTED]:~/temp$ g++ partitions_c.cc -O3 -lgmp -lmpfr
> [EMAIL PROTECTED]:~/temp$ ls -l a.out
> -rwxr-xr-x 1 bober bober 27529 2007-07-30 20:01 a.out <-- Look at size 
> of file to make sure we aren't linking statically
> [EMAIL PROTECTED]:~/temp$ time ./a.out 300000000
> [...]
> real    0m36.171s
> user    0m36.110s
> sys     0m0.016s
>
> Now do the same thing, but link statically:
>
> [EMAIL PROTECTED]:~/temp$ g++ partitions_c.cc -O3 -lmpfr -lgmp -static
> [EMAIL PROTECTED]:~/temp$ ls -l a.out
> -rwxr-xr-x 1 bober bober 1452497 2007-07-30 20:08 a.out    <-- Much 
> bigger binary
> [EMAIL PROTECTED]:~/temp$ time ./a.out 300000000
> [...]
> real    0m34.240s
> user    0m34.146s
> sys     0m0.020s
>
> Now we build with the libraries included in sage. (Note that
> sage does not build a shared library version of mprf, so
> this binary is bigger than first we build.) The time this
> takes to run is comparable to the time it took to run from
> within sage, so we know the overhead isn't from sage.
>
> [EMAIL PROTECTED]:~/temp$ g++ partitions_c.cc -O3 
> -L/home/bober/sage-2.7.1/sage-2.7.1/local/lib 
> -I/home/bober/sage-2.7.1/sage-2.7.1/local/lib -lmpfr -lgmp
> [EMAIL PROTECTED]:~/temp$ ls -l a.out
> -rwxr-xr-x 1 bober bober 150003 2007-07-30 20:14 a.out
> [EMAIL PROTECTED]:~/temp$ time ./a.out 300000000
> [...]
> real    0m46.675s
> user    0m46.515s
> sys     0m0.116s
>
> Now build a static version of the library. (It looks like sage
> only builds a shared library version of gmp, so I'm not sure if
> this really works the way it is supposed to, but it runs at a
> similar speed.)
>
> [EMAIL PROTECTED]:~/temp$ g++ partitions_c.cc -O3 
> -L/home/bober/sage-2.7.1/sage-2.7.1/local/lib 
> -I/home/bober/sage-2.7.1/sage-2.7.1/local/lib -lmpfr -lgmp -static
> [EMAIL PROTECTED]:~/temp$ ls -l a.out
> -rwxr-xr-x 1 bober bober 1479519 2007-07-30 20:19 a.out
> [EMAIL PROTECTED]:~/temp$ time ./a.out 300000000
> [...]
> real    0m43.592s
> user    0m43.443s
> sys     0m0.012s
>
> Now we build using the gmp 4.2.1 and mfpr 2.2.1 that I just built.
>
> [EMAIL PROTECTED]:~/temp$ g++ partitions_c.cc -O3 -L/home/bober/local/lib/ 
> -I/home/bober/local/include/ -lmpfr -lgmp
> [EMAIL PROTECTED]:~/temp$ ls -l a.out
> -rwxr-xr-x 1 bober bober 114849 2007-07-30 20:26 a.out
> [EMAIL PROTECTED]:~/temp$ time ./a.out 300000000
> [...]
> real    0m35.630s
> user    0m35.206s
> sys     0m0.060s
>
> And one more time, linking statically to those libraries
>
> [EMAIL PROTECTED]:~/temp$ g++ partitions_c.cc -O3 -L/home/bober/local/lib/ 
> -I/home/bober/local/include/ -lmpfr -lgmp -static
> [EMAIL PROTECTED]:~/temp$ ls -l a.out
> -rwxr-xr-x 1 bober bober 1401979 2007-07-30 20:29 a.out
> [EMAIL PROTECTED]:~/temp$ time ./a.out 300000000
> [...]
> real    0m33.924s
> user    0m33.354s
> sys     0m0.052s
>


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to