Sieve of Eratosthenes: Difference between revisions
→Hash Table Based Odds-Only Version: Chapel - Updated version check, qualified time...
GordonBGood (talk | contribs) m (→Alternate Odds-Only Bit-Packed Implementation: Chapel - Updated version check, qualified time...) |
GordonBGood (talk | contribs) (→Hash Table Based Odds-Only Version: Chapel - Updated version check, qualified time...) |
||
Line 2,594:
<lang chapel>use Time;
config const limit =
type Prime = uint(32);
Line 2,648:
<pre>The first 25 primes are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Found
Time as run using Chapel version 24.1 on an Intel Skylake i5-6500 at 3.6 GHz (turbo, single threaded).
As you can see, this is much slower than the array based versions; this is due in part to Chapel's current somewhat inefficient implementation of hash tables, both as Association Arrays as used here and in the Map standard library. This is somewhat slower than as run in Python as for the code from which it was translated due to Python's extremely well optimized hash table implementation as used internally.
{{works with|Chapel|1.22}}
Line 2,661:
<lang chapel>use Time;
config const limit =
type Prime = uint(32);
Line 2,759:
<pre>The first 25 primes are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Found
This last code is quite usable up to a hundred million (as here) or even a billion in a little over ten times the time, but is still slower than the very simple odds-only monolithic array version and is also more complex, although it uses less memory (only for the hash table for the base primes of about eight Kilobytes for sieving to a billion compared to over 60 Megabytes for the monolithic odds-only simple version).
|