primegen replacement?
Hallvard B Furuseth <[email protected]> Wed, 19 May 2010 18:54:05 +0200
| Newsgroups | gmane.org.djb.miscellaneous |
|---|---|
| Message-ID | <[email protected]> |
Is primegen (0.97) still starting point for fast prime number generation? My googling leads there and to Eratosthenes variants. It seems strange to me if decade-old code is still current for what I'd thought was one of the most frequently solved problems in computing. On x86_64, some of the "prefer 32-bit over 64-bit" optimizations look like pessimizations by now. Also hardware multiply and (I think) divide is faster than when the code was written. When I removed most code- level optimizations from primegen.c I only got a 6% primespeed slowdown near 1E15. 33% slowdown from 0, but there Eratosthenes is faster and can be used instead. Any particular preferences code-wise if I (eventually) send you an upgraded primegen-0.97? E.g. <stdint.h> and inline from C99 in would be convenient, but I can make do with limits.h and macros. (Though I'd still examine uint_fast32_t in <stdint.h> if available as a hint of best integer type.) Similarly using C89 size_t and POSIX ssize_t for array indexes can compile to better code than int, except when they are long long. I'd kill most of the magic constants and generate them instead - I have to do that anyway in order to figure out what the code is doing. Currently using Python scripts since the generated C files can be included in a distribution. -- Hallvard