Skip to content

Commit 718613f

Browse files
committed
Temporary Experiment 5
1 parent f240f42 commit 718613f

File tree

8 files changed

+2521
-2425
lines changed

8 files changed

+2521
-2425
lines changed

arrayjit/lib/rand.ml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,35 @@ module Random_for_tests = struct
2727
let int high = Int32.(to_int_trunc @@ (rand_int32 () % of_int_trunc high))
2828
end
2929

30+
module Random_for_dummy_tests = struct
31+
let rand = ref (1l : Int32.t)
32+
33+
let rand_int32 () =
34+
let open Int32 in
35+
rand := !rand + 1l;
36+
if equal !rand 10000l then rand := 1l;
37+
!rand
38+
39+
let init seed = rand := Int32.(of_int_trunc seed + 1l)
40+
41+
let float_range low high =
42+
let raw = Int32.(to_float @@ rand_int32 ()) in
43+
(raw /. 10000. *. (high -. low)) +. low
44+
45+
let char () = Char.of_int_exn @@ Int32.(to_int_trunc @@ (rand_int32 () % 256l))
46+
let int high = Int32.(to_int_trunc @@ (rand_int32 () % of_int_trunc high))
47+
end
48+
3049
let random_config = Utils.get_global_arg ~arg_name:"randomness_lib" ~default:"stdlib"
3150

3251
let random_lib =
3352
match random_config with
3453
| "stdlib" -> (module Base.Random : Random)
3554
| "for_tests" -> (module Random_for_tests : Random)
55+
| "for_dummy_tests" -> (module Random_for_dummy_tests : Random)
3656
| _ ->
3757
invalid_arg
3858
@@ "Rand.random_lib: invalid setting of the global argument randomness_lib, expected one of: \
39-
stdlib, for_tests; found: " ^ random_config
59+
stdlib, for_tests, for_dummy_tests; found: " ^ random_config
4060

4161
module Lib = (val random_lib)

test/einsum_trivia.ml

Lines changed: 1269 additions & 1269 deletions
Large diffs are not rendered by default.

test/hello_world_op.ml

Lines changed: 375 additions & 435 deletions
Large diffs are not rendered by default.

test/micrograd_demo.ml

Lines changed: 200 additions & 200 deletions
Large diffs are not rendered by default.

test/moons_demo_parallel.ml

Lines changed: 137 additions & 1 deletion
Large diffs are not rendered by default.

test/ocannl_config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
randomness_lib=for_tests
1+
randomness_lib=for_dummy_tests
22
log_main_domain_to_stdout=true
33
backend=cc
44
log_level=0
5-
print_decimals_precision=9
5+
print_decimals_precision=2

test/primitive_ops.ml

Lines changed: 315 additions & 315 deletions
Large diffs are not rendered by default.

test/zero2hero_1of7.ml

Lines changed: 202 additions & 202 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)