primorial(negative)

Marco Bodrato bodrato at mail.dm.unipi.it
Fri Nov 13 18:43:09 UTC 2015


Ciao Paul,

Il Ven, 13 Novembre 2015 6:17 pm, Marco Bodrato ha scritto:
> Il Ven, 13 Novembre 2015 2:56 pm, paul zimmermann ha scritto:
>> you can also consider the file utils/getprime.c from CADO-NFS:

> I'll try to write a gmp_numberofprimesupto_ui function using GMP
> _internals_, so that we can compare timings and decide if we need to
> rewrite the functions we have or we simply have to expose them.

I attach a quick-and-dirty GMP answer to the "counting primes up to a
value represented by an unsigned long" problem.

~/gmp-release$ gcc -I. -DMAIN gmp_pi.c -lgmp
~/gmp-release$ time ./a.out 1000000000
pi(1000000000)=50847534

real	0m1.541s
user	0m1.516s
sys	0m0.020s

But the comparison is unfair. My code does not loop on primes to count
them, it simply exploit a "side effect" of the internal _primesieve
function: it returns the cardinality of the set of sieved primes.

Moreover I'm sure that my version uses much more memory than yours...

But the numbers suggest me that we mainly need a good interface.

As a second step, if we find that we are not as fast as we should be, we
can refine the code.

Best regards,
m

-- 
http://bodrato.it/papers/


More information about the gmp-discuss mailing list