This 32-bit Primes Generator, primes.exe, does up to 2 billion (98222287 primes) in about 235 milliseconds. With one thread, it's about twice as fast as my previous version from

jj2007's Primes thread.

Chris Wallich's primesieve (C++) is still 1.9x faster. I think / hope the reason is, it's 64-bit. The optimizing compiler utilizes all 16 registers, especially for the critical wheel algorithm. If I get to it I'll convert this to 64, which is worth doing anyway because it would compute primes up to 2^64 (100 billion takes about 10 secs with primesieve).

Although I used no algos from primesieve (just the segmenting idea) it was invaluable for providing test cases and something to shoot for. Thanks Chris! Comparisons:

BUILD SIZE: primesieve is 775K, primes is 7K: 1%! CW's is 64-bit, does more algo's (like wheeling), and also K-tuplets. So I figure roughly, the asm prog would be about 8% the size for equivalent functionality.

SLOC's: primesieve is almost 4000, primes less than 1000. If expanded to the same functionality I think they'd have approximately equal SLOCs (contrary to C-programmer's opinion).

Readability: Chris Wallich's prog is clear as a bell, my asm prog is not. Literally, I can read his C++ easier than my asm, even though I just wrote it!

Test runs:

`C:\primes>test`

C:\primes>primes

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 235.8

with 4 threads

from 2 up to 2000000001, 98222287 primes

C:\primes>primes 0 0 3

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 311.5

with 3 threads

from 2 up to 2000000001, 98222287 primes

C:\primes>primes 0 0 2

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 436.3

with 2 threads

from 2 up to 2000000001, 98222287 primes

C:\primes>primes 0 0 1

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 863.9

with 1 threads

from 2 up to 2000000001, 98222287 primes

C:\primes>primes 0 1000000000

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 107.5

with 4 threads

from 2 up to 1000000000, 50847534 primes

C:\primes>primes 1000000000 2000000000

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 130.8

with 4 threads

from 1000000000 up to 2000000000, 47374753 primes

C:\primes>primes 777

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 236.2

with 4 threads

from 777 up to 2000000001, 98222150 primes

C:\primes>primes 777777

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 235.3

with 4 threads

from 777777 up to 2000000001, 98159986 primes

C:\primes>primes 1234567 123456789

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 10.42

with 4 threads

from 1234567 up to 123456789, 6931900 primes

C:\primes>primes 15485163 15485163

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 0.1576

with 1 threads

from 15485163 up to 15485163, 0 primes

C:\primes>primes 15485863 15485863

******************************************************************

Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz; Windows 8; 4 threads

prime time ms 0.157

with 1 threads

from 15485863 up to 15485863, 1 primes

The zip contains the following:

primes.exe

primes.asm ; main, does up to 60061 then calls threads

threads.asm ; sets up thread data, launches them

Do_Segments.asm ; each thread uses per job of segments

SysInfo.asm ; mod of siekmanski's code, gets # threads

primes.inc ; global equates, etc; printing and timing

makeit.bat ; make file

test.bat ; runs test cases given above