A Friendly Challenge for D
Jabari Zakiya
jzakiya at gmail.com
Wed Oct 10 16:15:56 UTC 2018
Hi.
I hope this is the right place to request this, if not please
tell me a better one.
I had looked at D, and played with it some circa 2010~2012, but
time and life took my priorities away. But I'm still interested
in learning different languages, but there are so many more now
it's hard to devote the time to learn them to some high level of
proficiency.
Subsequently, I started learning Nim, because I find the syntax
and constructs simpler and more familiar than most (I'm coming
mostly from a Ruby background).
I have developed in Nim a program to find twinprimes that seems
to be the fastest of its type, compared to primesieve
(https://primesieve.org/) which claims to be the fastest, written
in C++.
Here is the code to my Nim implementation of twinprimes_ssoz.
https://gist.github.com/jzakiya/6c7e1868bd749a6b1add62e3e3b2341e
The total file is just 318 lines of code, with about 60 separate
lines of comments.
The code is extensively commented per line to explain what's
happening.
Reading the references given in the code introduction will
explain the general process.
See "The Segmented Sieve of Zakiya (SSoZ)"
https://www.scribd.com/doc/228155369/The-Segmented-Sieve-of-Zakiya-SSoZ
I am in the process of writing up a paper to explain this
application, and implementation. What I am requesting here is for
a person(s) who is an "expert" (very good) to create a very fast
D version, using whatever tricks it has to maximize performance.
I would like to include in my paper a good comparison of various
implementations in different compiled languages (C/C++, D, Nim,
etc) to show how it performs with each.
This algorithm is designed to be run in multiprocessing
environments (more core/threads, better performance). The Nim
version (0.18.0, 0.19.0 recently released) uses its native
parallel processing structure. In C++, et al, it may be best
implemented using OPenMP, or CUDA, etc. These are implementation
details one versed in a language could determine.
Well that's it. I am willing to share performance data, compared
to primesive, if you like. The beauty of this
algorithm|implementation is its simplicity in design, and minimal
code. It shouldn't be that hard to understand to determine how to
translate into D. Of course, I'm am fully available to answer
questions and provide help.
Thanks
Jabari
More information about the Digitalmars-d
mailing list