Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganisation of the repo structure #4

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
96b1761
mv ocaml src
Kerl13 Apr 26, 2020
4aa7f55
Sm64 C reference implementation as an ocaml module
Kerl13 Apr 26, 2020
485e691
Test Sm64 against reference implementation
Kerl13 Apr 26, 2020
8f44bdd
xoshiro256++ ref implementation as an OCaml module
Kerl13 Apr 27, 2020
95401e2
Merge x256pp_c/* and stubs.c
Kerl13 Apr 27, 2020
430acce
Test X256pp.Int64 against reference implementation
Kerl13 Apr 27, 2020
e7697eb
Test X256pp.Int against reference implementation
Kerl13 Apr 27, 2020
e1d51d1
The c/ folder is obsolete
Kerl13 Apr 27, 2020
640b0a2
Remove obsolete tests
Kerl13 Apr 28, 2020
adc429d
Remove duplicate code
Kerl13 May 6, 2020
e29fb07
git mv * prng/
Kerl13 May 15, 2020
b256544
Remove CAMLprim everywhere
Kerl13 May 15, 2020
76a40dd
consistency: #define WHATEVER_H 1
Kerl13 May 15, 2020
050a066
mv some stuff WIP
Kerl13 May 15, 2020
0012f45
Hide x256pp_state (and fix a linker issue)
Kerl13 May 15, 2020
2add6b4
More consistent naming of tests
Kerl13 May 15, 2020
7bed7ad
mv dune-project back to the root of the repository
Kerl13 May 15, 2020
c452226
Internal testutils library
Kerl13 May 18, 2020
f3d83cf
Test: diff the output pure ocaml vs. pure C code
Kerl13 May 18, 2020
05999c0
Test all rngs against a C reference implementation
Kerl13 May 18, 2020
822a6e8
"True" reference implementations
Kerl13 May 18, 2020
ad76e7e
Remove old benchmark
Kerl13 May 18, 2020
f873f3e
Arg.align is nice!
Kerl13 May 18, 2020
0e6951b
Cleaner dune files
Kerl13 May 24, 2020
096214d
Remove some warnings
Kerl13 May 24, 2020
2e264aa
More C compiler warnings
Kerl13 May 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions c/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions c/Makefile

This file was deleted.

24 changes: 0 additions & 24 deletions c/ocamlrandom.c

This file was deleted.

1 change: 0 additions & 1 deletion c/ocamlrandom.h

This file was deleted.

3 changes: 0 additions & 3 deletions c/splitmix64.h

This file was deleted.

14 changes: 0 additions & 14 deletions c/testocamlrandom.c

This file was deleted.

16 changes: 0 additions & 16 deletions c/testsplitmix.c

This file was deleted.

15 changes: 0 additions & 15 deletions c/testxoshiro.c

This file was deleted.

17 changes: 0 additions & 17 deletions compare.sh

This file was deleted.

File renamed without changes.
14 changes: 0 additions & 14 deletions ocaml/Makefile

This file was deleted.

57 changes: 0 additions & 57 deletions ocaml/bench.ml

This file was deleted.

4 changes: 0 additions & 4 deletions ocaml/dune

This file was deleted.

13 changes: 0 additions & 13 deletions ocaml/tests/dune

This file was deleted.

10 changes: 0 additions & 10 deletions ocaml/tests/ocamlrandom.ml

This file was deleted.

13 changes: 0 additions & 13 deletions ocaml/tests/splitmix.ml

This file was deleted.

15 changes: 0 additions & 15 deletions ocaml/tests/xoshiro.ml

This file was deleted.

5 changes: 0 additions & 5 deletions ocaml/xoshiro/dune

This file was deleted.

55 changes: 0 additions & 55 deletions ocaml/xoshiro/x256pp_c/x256pp.c

This file was deleted.

12 changes: 0 additions & 12 deletions ocaml/xoshiro/x256pp_c/x256pp.h

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions prng/src/splitmix/tests/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(executable
(name sm64_ocaml)
(libraries splitmix testutils))

(rule
(target sm64_c.exe)
(deps reference.h (:codedeps sm64_c.c reference.c ../../testutils/libtestutils.a))
(action
(run cc -Wall -Wextra -Wpedantic -o %{target} %{codedeps})))

(rule (with-stdout-to sm64_ocaml.output (run ./sm64_ocaml.exe --nb=1000)))
(rule (with-stdout-to sm64_c.output (run ./sm64_c.exe --nb=1000)))
(rule (alias runtest) (action (diff sm64_ocaml.output sm64_c.output)))
11 changes: 9 additions & 2 deletions c/splitmix64.c → prng/src/splitmix/tests/reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ See <http://creativecommons.org/publicdomain/zero/1.0/>. */
#include <stdint.h>

/* This is a fixed-increment version of Java 8's SplittableRandom generator
See http://dx.doi.org/10.1145/2714064.2660195 and
See http://dx.doi.org/10.1145/2714064.2660195 and
Niols marked this conversation as resolved.
Show resolved Hide resolved
http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html

It is a very fast generator passing BigCrush, and it can be useful if
for some reason you absolutely want 64 bits of state. */

static uint64_t x = 0xdead42beef37ca7a; /* The state can be seeded with any value. */
static uint64_t x; /* The state can be seeded with any value. */

uint64_t next() {
uint64_t z = (x += 0x9e3779b97f4a7c15);
Expand All @@ -24,3 +24,10 @@ uint64_t next() {
return z ^ (z >> 31);
}

// --------------------------------
// Above this line: verbatim copy of http://prng.di.unimi.it/splitmix64.c
Niols marked this conversation as resolved.
Show resolved Hide resolved
// Below: added by us for testing purpose

void seed(uint64_t s) {
x = s;
}
9 changes: 9 additions & 0 deletions prng/src/splitmix/tests/reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef SPLITMIX64_H
#define SPLITMIX64_H 1

#include <stdint.h>

uint64_t next();
void seed(uint64_t);

#endif
6 changes: 6 additions & 0 deletions prng/src/splitmix/tests/sm64_c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "reference.h" // seed, next
#include "../../testutils/testutils.h" // testutils_run

int main(int argc, char* argv[]) {
Niols marked this conversation as resolved.
Show resolved Hide resolved
return testutils_run(argc, argv, seed, next);
}
7 changes: 7 additions & 0 deletions prng/src/splitmix/tests/sm64_ocaml.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
open Splitmix

let () =
let state = ref 0L in
Testutils.run
~seed_f:(fun s -> state := s)
Kerl13 marked this conversation as resolved.
Show resolved Hide resolved
~next:(fun () -> Sm64.next state)
8 changes: 8 additions & 0 deletions prng/src/testutils/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(foreign_library
(archive_name testutils)
(language c)
(flags -Wall -Wextra -Wpedantic)
Kerl13 marked this conversation as resolved.
Show resolved Hide resolved
(names testutils))

(library
(name testutils))
Loading