Has anyone invesitgated what is the fastest way to generate prime numbers sequentially in Mathematica, and whether this is effectively parallelizable?
I’m trying to do some statistics on prime numbers and right now I am generating them in batches of size ‘chunk’, something like this:
(* chunk is a large number *)
Prime@Range[r, r + chunk]
(* do stuff *)
r += chunk
The performance characteristics of the prime-related functions are rather opaque and they seem to rely in some sort of internal caching (for example for as long as I’m generating all primes, using Prime[] instead of NextPrime[] didn’t seem to carry any great penalties).
I was wondering if someone has already investigated the fastest way to generate primes in chunks, sequentially. Because of the caching that’s going on it’s not clear how to Parallelize[] this effectively, without duplicating a lot of the work among subkernels.