Skip to content

Commit b31bfaa

Browse files
authored
Introduction of implementation characteristics/tags
1 parent 4b2b6b8 commit b31bfaa

File tree

122 files changed

+647
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+647
-300
lines changed

CONTRIBUTING.md

+235-57
Large diffs are not rendered by default.

PrimeAda/solution_1/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Ada solution by BoopBeepBoopBeep
22

3-
![Category](https://img.shields.io/badge/Category-unfaithful-yellowgreen)
3+
![Algorithm](https://img.shields.io/badge/Algorithm-base-green)
4+
![Faithfulness](https://img.shields.io/badge/Faithful-no-yellowgreen)
5+
![Parallelism](https://img.shields.io/badge/Parallel-no-green)
6+
![Bit count](https://img.shields.io/badge/Bits-unknown-yellowgreen)
47

58
Using the Community IDE and Compiler found :
69
https://www.adacore.com/download

PrimeAda/solution_1/src/main.adb

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ procedure Main is
107107

108108
-- Following 2 lines added by rbergen to conform to drag race output format
109109
Put_Line ("");
110-
Put_Line ("BoopBeepBoopBeep;" & Passes'Image & ";" & Dur'Image & ";1");
110+
Put_Line ("BoopBeepBoopBeep;" & Passes'Image & ";" & Dur'Image & ";1;algorithm=base,faithful=no");
111111

112112
end Print_Result;
113113
Passes : Integer := 0;

PrimeAssembly/solution_1/README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# x86-64 assembly solution by rbergen
22

3-
![Category](https://img.shields.io/badge/Category-faithful-green)
4-
![Category](https://img.shields.io/badge/Category-unfaithful-yellowgreen)
3+
![Algorithm](https://img.shields.io/badge/Algorithm-base-green)
4+
![Faithfulness](https://img.shields.io/badge/Faithful-yes-green)
5+
![Faithfulness](https://img.shields.io/badge/Faithful-no-yellowgreen)
6+
![Parallelism](https://img.shields.io/badge/Parallel-no-green)
7+
![Bit count](https://img.shields.io/badge/Bits-1-green)
8+
![Bit count](https://img.shields.io/badge/Bits-8-yellowgreen)
59

610
This solution contains six implementations in x86-64 assembly, of which:
711
* x64ff_bitbtr is faithful, uses bits to store prime number flags and clears them using the btr instruction
@@ -27,10 +31,10 @@ A Dockerfile has been provided.
2731

2832
## Output
2933
```
30-
rbergen_x64uff_byte;7334;5.000;1
31-
rbergen_x64ff_byte;8302;5.000;1
32-
rbergen_x64uff_bitbtr;4179;5.000;1
33-
rbergen_x64ff_bitbtr;4177;5.000;1
34-
rbergen_x64uff_bitshift;6269;5.000;1
35-
rbergen_x64ff_bitshift;4600;5.000;1
34+
rbergen_x64uff_byte;7334;5.000;1;algorithm=base,faithful=no,bits=8
35+
rbergen_x64ff_byte;8302;5.000;1;algorithm=base,faithful=yes,bits=8
36+
rbergen_x64uff_bitbtr;4179;5.000;1;algorithm=base,faithful=no,bits=1
37+
rbergen_x64ff_bitbtr;4177;5.000;1;algorithm=base,faithful=yes,bits=1
38+
rbergen_x64uff_bitshift;6269;5.000;1;algorithm=base,faithful=no,bits=1
39+
rbergen_x64ff_bitshift;4600;5.000;1;algorithm=base,faithful=yes,bits=1
3640
```

PrimeAssembly/solution_1/primes_ff_bitbtr.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ refResults:
5050
dd 0
5151

5252
; format string for output
53-
outputFmt: db 'rbergen_x64ff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0
53+
outputFmt: db 'rbergen_x64ff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=yes,bits=1', 10, 0
5454
; incorrect result warning message
5555
incorrect: db 'WARNING: result is incorrect!', 10
5656
; length of previous

PrimeAssembly/solution_1/primes_ff_bitshift.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ refResults:
5050
dd 0
5151

5252
; format string for output
53-
outputFmt: db 'rbergen_x64ff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0
53+
outputFmt: db 'rbergen_x64ff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=yes,bits=1', 10, 0
5454
; incorrect result warning message
5555
incorrect: db 'WARNING: result is incorrect!', 10
5656
; length of previous

PrimeAssembly/solution_1/primes_ff_byte.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ refResults:
5050
dd 0
5151

5252
; format string for output
53-
outputFmt: db 'rbergen_x64ff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0
53+
outputFmt: db 'rbergen_x64ff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=yes,bits=8', 10, 0
5454
; incorrect result warning message
5555
incorrect: db 'WARNING: result is incorrect!', 10
5656
; length of previous

PrimeAssembly/solution_1/primes_uff_bitbtr.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ refResults:
4545
dd 0
4646

4747
; format string for output
48-
outputFmt: db 'rbergen_x64uff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0
48+
outputFmt: db 'rbergen_x64uff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=no,bits=1', 10, 0
4949
; incorrect result warning message
5050
incorrect: db 'WARNING: result is incorrect!', 10
5151
; length of previous

PrimeAssembly/solution_1/primes_uff_bitshift.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ refResults:
4545
dd 0
4646

4747
; format string for output
48-
outputFmt: db 'rbergen_x64uff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0
48+
outputFmt: db 'rbergen_x64uff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=no,bits=1', 10, 0
4949
; incorrect result warning message
5050
incorrect: db 'WARNING: result is incorrect!', 10
5151
; length of previous

PrimeAssembly/solution_1/primes_uff_byte.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ refResults:
4545
dd 0
4646

4747
; format string for output
48-
outputFmt: db 'rbergen_x64uff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0
48+
outputFmt: db 'rbergen_x64uff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=no,bits=8', 10, 0
4949
; incorrect result warning message
5050
incorrect: db 'WARNING: result is incorrect!', 10
5151
; length of previous

PrimeAssembly/solution_2/README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# arm64 assembly solution by rbergen
22

3-
![Category](https://img.shields.io/badge/Category-faithful-green)
4-
3+
![Algorithm](https://img.shields.io/badge/Algorithm-base-green)
4+
![Faithfulness](https://img.shields.io/badge/Faithful-yes-green)
5+
![Parallelism](https://img.shields.io/badge/Parallel-no-green)
6+
![Bit count](https://img.shields.io/badge/Bits-1-green)
7+
![Bit count](https://img.shields.io/badge/Bits-8-yellowgreen)
58

69
This solution contains three implementations in arm64 assembly. Two use bits to store prime number flags (one with precalculated bit masks), the other uses bytes. The basic algorithm used is that of the original C#/C++ implementations.
710

@@ -19,7 +22,7 @@ A Dockerfile has been provided.
1922

2023
## Output
2124
```
22-
rbergen_arm64_byte;908;5.002;1
23-
rbergen_arm64_bitmap;793;5.005;1
24-
rbergen_arm64_bitshift;890;5.003;1
25+
rbergen_arm64_byte;908;5.002;1;algorithm=base,faithful=yes,bits=8
26+
rbergen_arm64_bitmap;793;5.005;1;algorithm=base,faithful=yes,bits=1
27+
rbergen_arm64_bitshift;890;5.003;1;algorithm=base,faithful=yes,bits=1
2528
```

PrimeAssembly/solution_2/primes_arm64_bitmap.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ printResults:
209209
.balign 4
210210

211211
outputFmt: // format string for output
212-
.asciz "rbergen_arm64_bitmap;%d;%d.%03d;1\n"
212+
.asciz "rbergen_arm64_bitmap;%d;%d.%03d;1;algorithm=base,faithful=yes,bits=1\n"
213213

214214
.balign 4
215215

PrimeAssembly/solution_2/primes_arm64_bitshift.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ printResults:
209209
.balign 4
210210

211211
outputFmt: // format string for output
212-
.asciz "rbergen_arm64_bitshift;%d;%d.%03d;1\n"
212+
.asciz "rbergen_arm64_bitshift;%d;%d.%03d;1;algorithm=base,faithful=yes,bits=1\n"
213213

214214
.balign 4
215215

PrimeAssembly/solution_2/primes_arm64_byte.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ printResults:
209209
.balign 4
210210

211211
outputFmt: // format string for output
212-
.asciz "rbergen_arm64_byte;%d;%d.%03d;1\n"
212+
.asciz "rbergen_arm64_byte;%d;%d.%03d;1;algorithm=base,faithful=yes,bits=8\n"
213213

214214
.balign 4
215215

PrimeAssemblyScript/solution_1/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# AssemblyScript implementation by donmahallem
22

3-
![Category](https://img.shields.io/badge/Category-faithful-green)
3+
![Algorithm](https://img.shields.io/badge/Algorithm-base-green)
4+
![Faithfulness](https://img.shields.io/badge/Faithful-yes-green)
5+
![Parallelism](https://img.shields.io/badge/Parallel-no-green)
6+
![Bit count](https://img.shields.io/badge/Bits-unknown-yellowgreen)
47

58
## Run instructions
69

PrimeAssemblyScript/solution_1/src/sieve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class PrimeSieve {
6161

6262
// Following 2 lines added by rbergen to conform to drag race output format
6363
console.log("");
64-
console.log("donmahallem;" + passes.toString() + ";" + duration.toString() + ";1");
64+
console.log("donmahallem;" + passes.toString() + ";" + duration.toString() + ";1;algorithm=base,faithful=yes");
6565

6666
}
6767

PrimeBASIC/solution_1/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.run

PrimeBASIC/solution_1/Dockerfile

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
FROM primeimages/freebasic:1.07.3 AS build
22

3+
34
WORKDIR /opt/app
4-
COPY runprimes.sh .
5-
RUN chmod a+x runprimes.sh
6-
COPY *.bas /opt/app/
7-
RUN find . -name 'prime_*.bas' -exec fbc {} \;
5+
COPY *.bas ./
6+
COPY run.sh .
7+
RUN chmod a+x run.sh
8+
RUN find . -name 'prime_*.bas' -exec fbc {} -x {}.run \;
89

910
FROM ubuntu:18.04
10-
COPY --from=build /opt/app/* /opt/app/
11+
COPY --from=build /opt/app/*.run /opt/app/
12+
COPY --from=build /opt/app/run.sh /opt/app/
13+
WORKDIR /opt/app
1114

12-
ENTRYPOINT [ "/opt/app/runprimes.sh" ]
15+
ENTRYPOINT [ "./run.sh" ]

PrimeBASIC/solution_1/README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# FreeBASIC solutions by rbergen
22

3-
![Category](https://img.shields.io/badge/Category-faithful-green)
3+
![Algorithm](https://img.shields.io/badge/Algorithm-base-green)
4+
![Algorithm](https://img.shields.io/badge/Algorithm-wheel-yellowgreen)
5+
![Faithfulness](https://img.shields.io/badge/Faithful-yes-green)
6+
![Parallelism](https://img.shields.io/badge/Parallel-no-green)
7+
![Bit count](https://img.shields.io/badge/Bits-1-green)
8+
![Bit count](https://img.shields.io/badge/Bits-unknown-yellowgreen)
49

510
This is a collection of implementations in FreeBASIC, of which:
611
1. one is effectively a FreeBASIC copy of the "8 of 30" implementation that [mckoss](https://github.com/mckoss) has written in C
@@ -22,8 +27,8 @@ A Dockerfile has been provided.
2227

2328
## Output
2429
```
25-
rbergen_8of30;4197;5.001;1
26-
rbergen_bit32;720;5.000;1
27-
rbergen_bit64;661;5.000;1
28-
rbergen_boolean;1720;5.001;1
30+
rbergen_8of30;4197;5.001;1;algorithm=wheel,faithful=yes,bits=1
31+
rbergen_bit32;720;5.000;1;algorithm=base,faithful=yes,bits=1
32+
rbergen_bit64;661;5.000;1;algorithm=base,faithful=yes,bits=1
33+
rbergen_boolean;1720;5.001;1;algorithm=base,faithful=yes
2934
```

PrimeBASIC/solution_1/prime_8of30.bas

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re
181181

182182
Delete Sieve
183183

184-
Print Using "rbergen__8of30;&;#.###;1"; PassCount; Duration
184+
Print Using "rbergen__8of30;&;#.###;1;algorithm=wheel,faithful=yes,bits=1"; PassCount; Duration

PrimeBASIC/solution_1/prime_bit32.bas

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re
167167

168168
Delete Sieve
169169

170-
Print Using "rbergen__bit32;&;#.###;1"; PassCount; Duration
170+
Print Using "rbergen__bit32;&;#.###;1;algorithm=base,faithful=yes,bits=1"; PassCount; Duration

PrimeBASIC/solution_1/prime_bit64.bas

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re
167167

168168
Delete Sieve
169169

170-
Print Using "rbergen__bit64;&;#.###;1"; PassCount; Duration
170+
Print Using "rbergen__bit64;&;#.###;1;algorithm=base,faithful=yes,bits=1"; PassCount; Duration

PrimeBASIC/solution_1/prime_boolean.bas

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re
132132

133133
Delete Sieve
134134

135-
Print Using "rbergen__boolean;&;#.###;1"; PassCount; Duration
135+
Print Using "rbergen__boolean;&;#.###;1;algorithm=base,faithful=yes"; PassCount; Duration

PrimeBASIC/solution_1/runprimes.sh PrimeBASIC/solution_1/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd $(dirname "${BASH_SOURCE[0]}")
44

5-
for file in prime_*[^.bas]; do
5+
for file in prime_*.run; do
66
if [ -x ${file} ]; then
77
./${file}
88
fi

PrimeBASIC/solution_2/PrimeVB.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ Module PrimeVB
7979
Console.WriteLine("WARNING: result is incorrect!")
8080
End If
8181

82-
Console.WriteLine("rbergen_vb;{0};{1};1", passCount, duration)
82+
Console.WriteLine("rbergen_vb;{0};{1};1;algorithm=base,faithful=yes,bits=1", passCount, duration)
8383
End Sub
8484
End Module

PrimeBASIC/solution_2/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Visual Basic solution by rbergen
22

3-
![Category](https://img.shields.io/badge/Category-faithful-green)
3+
![Algorithm](https://img.shields.io/badge/Algorithm-base-green)
4+
![Faithfulness](https://img.shields.io/badge/Faithful-yes-green)
5+
![Parallelism](https://img.shields.io/badge/Parallel-no-green)
6+
![Bit count](https://img.shields.io/badge/Bits-1-green)
47

58
This is an implementation in Visual Basic.
69

@@ -17,5 +20,5 @@ A Dockerfile has been provided.
1720

1821
## Output
1922
```
20-
rbergen_vb;2457;5.0012308;1
23+
rbergen_vb;2457;5.0012308;1;algorithm=base,faithful=yes,bits=1
2124
```

PrimeC/solution_1/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# C solution by mckoss
22

3-
![Category](https://img.shields.io/badge/Category-faithful-green)
3+
![Algorithm](https://img.shields.io/badge/Algorithm-wheel-yellowgreen)
4+
![Faithfulness](https://img.shields.io/badge/Faithful-yes-green)
5+
![Parallelism](https://img.shields.io/badge/Parallel-no-green)
6+
![Bit count](https://img.shields.io/badge/Bits-1-green)
47

58
Single threaded implementation in C of prime number sieve.
69

@@ -55,5 +58,5 @@ Word size: 64 bits.
5558
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, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, ...
5659
Found 78498 primes up to 1000000.
5760
58-
mckoss-c830;25186;5.0;1
61+
mckoss-c830;25186;5.0;1;algorithm=wheel,faithful=yes,bits=1
5962
```

PrimeC/solution_1/sieve.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void timedTest(int secs, SIEVE *primeFinder(int), char *title) {
260260

261261
float elapsed = (float) currentTicks - startTicks;
262262

263-
printf("%s;%d;%0.1f;1\n", title, passes, elapsed / CLOCKS_PER_SEC);
263+
printf("%s;%d;%0.1f;1;algorithm=wheel,faithful=yes,bits=1\n", title, passes, elapsed / CLOCKS_PER_SEC);
264264
fflush(stdout);
265265
}
266266

0 commit comments

Comments
 (0)