|
1 |
| -# amd64 solution by @dacvs (https://dacvs.neocities.org/) |
| 1 | +# amd64 solution by dacvs (https://dacvs.neocities.org/) |
2 | 2 |
|
3 | 3 | 
|
4 | 4 | 
|
5 | 5 | 
|
| 6 | + |
6 | 7 | 
|
7 | 8 |
|
8 |
| -This is an 8-bit faithful implementation of the base prime number sieve algorithm from Dave Plummer's Software Drag Race. |
| 9 | +This is a faithful implementation of the base prime number sieve algorithm from Dave Plummer's Software Drag Race. |
9 | 10 | This submission is written in machine language (amd64) in the style of my video series "Handmade Linux x86 executables."
|
10 | 11 | (https://www.youtube.com/playlist?list=PLZCIHSjpQ12woLj0sjsnqDH8yVuXwTy3p).
|
11 | 12 |
|
12 |
| -When I open the source file dacvs8.dmp in vi (really vim) on my Ubuntu system, the text editor provides "syntax highlighting" by graying out the comments. This requires no special configuration. |
| 13 | +When I open a source file (dacvs1.dmp or dacvs8.dmp) in vi (really vim) on my Ubuntu system, the text editor provides "syntax highlighting" by graying out the comments. This requires no special configuration. |
13 | 14 |
|
14 | 15 | ## Run instructions
|
15 | 16 |
|
16 | 17 | To make the binary, run `make.sh` (on a Linux system).
|
17 |
| -To execute the binary (after it is made) for primes up to 1 million, run `run8.sh`. |
| 18 | +To execute the binaries (after they are made) for primes up to 1 million, run `run.sh`. |
18 | 19 |
|
19 |
| -## Output of run8.sh |
| 20 | +## Output of run.sh |
20 | 21 | ```
|
21 |
| -dsmith8;6383;5.000102;1;algorithm=base,faithful=yes,bits=8 |
| 22 | +dacvs1;5581;5.000286;1;algorithm=base,faithful=yes,bits=1 |
| 23 | +dacvs8;7021;5.000677;1;algorithm=base,faithful=yes,bits=8 |
| 24 | +``` |
| 25 | + |
| 26 | +## Output of run1p.sh |
| 27 | +``` |
| 28 | +P 2 |
| 29 | +P 3 |
| 30 | +P 5 |
| 31 | +P 7 |
| 32 | +P 11 |
| 33 | +P 13 |
| 34 | +P 17 |
| 35 | +P 19 |
| 36 | +P 23 |
| 37 | +P 29 |
| 38 | +... |
| 39 | +P 999953 |
| 40 | +P 999959 |
| 41 | +P 999961 |
| 42 | +P 999979 |
| 43 | +P 999983 |
| 44 | += 78498 |
| 45 | +I 5315 |
| 46 | +T 5000700682 |
| 47 | +1062.9 |
| 48 | +dacvs1;5315;5.000701;1;algorithm=base,faithful=yes,bits=1 |
22 | 49 | ```
|
23 | 50 |
|
24 | 51 | ## Output of run8p.sh
|
@@ -62,14 +89,16 @@ A new object is created each time through the loop. However, I arranged a memory
|
62 | 89 | Yes, although not every request for memory triggers a system call, as described above.
|
63 | 90 |
|
64 | 91 | ### The size of the memory buffer must correspond to the size of the sieve.
|
65 |
| -Yes, the buffer has 8 bits for each sieve number 1, 3, 5, 7, 9, ..., (M-1)/2. |
| 92 | +Yes, in the 8-bit program, the buffer has 8 bits for each sieve number 1, 3, 5, 7, 9, ..., (M-1)/2. |
| 93 | + |
| 94 | +The 1-bit program has 1 bit for each sieve number 1, 3, 5, 7, 9, ..., (M-1)/2, but the number of sieve bits is rounded up to the next multiple of 64, as sieve bits are accessed as members of 64-bit integers. |
66 | 95 |
|
67 | 96 | ## This submission conforms to the rules:
|
68 | 97 | ### Solution uses sieve of Eratosthenes.
|
69 | 98 | Yes.
|
70 | 99 |
|
71 | 100 | ### Benchmarked code returns a list of primes.
|
72 |
| -Script run8.sh puts out a single line of statistics in the preferred style. Script run8p.sh puts out a list of primes to stderr and a single line of statistics to stdout. |
| 101 | +Script run.sh puts out one line of statistics in the preferred style for each program, 1-bit and 8-bit. Scripts run1p.sh and run8p.sh each put out a list of primes to stderr and a single line of statistics to stdout. |
73 | 102 |
|
74 | 103 | ### Solution runs for at least 5 seconds, then stops as quickly as possible after that.
|
75 | 104 | The algorithm completes its current pass before checking the clock, then stops if at least 5 seconds have passed. The program gets the time (down to the nanosecond) from Linux system call clock_gettime.
|
|
0 commit comments