A Friendly Challenge for D
Jabari Zakiya
jzakiya at gmail.com
Mon Oct 15 22:17:57 UTC 2018
> $ dub build --compiler=ldc2 -b=release && echo "3000000000" |
> ./twinprimes
> Enter integer number:
> threads = 8
> each thread segment is [1 x 65536] bytes array
> twinprime candidates = 175324676; resgroups = 1298702
> each 135 threads has nextp[2 x 5566] array
> setup time = 1 ms, 864 μs, and 7 hnsecs
> perform twinprimes ssoz sieve
> sieve time = 196 ms, 566 μs, and 5 hnsecs
> last segment = 53518 resgroups; segment slices = 20
> total twins = 9210144; last twin = 2999999712+/- 1
> total time = 198 ms, 431 μs, and 2 hnsecs
>
> My understanding is that the difference in performance is
> largely due to slightly better optimization from the LLVM based
> ldc2 compiler, where I believe Nim is using gcc.
Here's what I get on my system.
$ echo 3_000_000_000 | ./twinprimes_test7yc.0180.gcc821
Enter integer number: threads = 8
each thread segment is [1 x 65536] bytes array
twinprime candidates = 175324676; resgroups = 1298702
each 135 threads has nextp[2 x 5566] array
setup time = 0.000 secs
perform twinprimes ssoz sieve
sieve time = 0.144 secs
last segment = 53518 resgroups; segment slices = 20
total twins = 9210144; last twin = 2999999712+/-1
total time = 0.144 secs
Could you list your hardware, D ver, compiler specs.
I will run your code on my system with your D version and
compiler, if I can.
Excellent work!
More information about the Digitalmars-d
mailing list