Skip to content

Commit

Permalink
Merge pull request #298 from shakthimaan/dev/build-and-run-byte-code-…
Browse files Browse the repository at this point in the history
…benchmarks

Support to build and run benchmarks in byte mode
  • Loading branch information
shakthimaan authored Mar 2, 2022
2 parents a6e33fb + b326158 commit 2e38ae9
Show file tree
Hide file tree
Showing 35 changed files with 835 additions and 45 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ _opam/opam-init/init.sh:
opam init --bare --no-setup --no-opamrc --disable-sandboxing ./dependencies

_opam/%: _opam/opam-init/init.sh ocaml-versions/%.json
$(eval CONFIG_SWITCH_NAME = $*)
rm -rf dependencies/packages/ocaml/ocaml.$*
rm -rf dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.$*
mkdir -p dependencies/packages/ocaml/ocaml.$*
Expand All @@ -124,8 +125,10 @@ _opam/%: _opam/opam-init/init.sh ocaml-versions/%.json
$(eval OCAML_RUN_PARAM = $(shell jq -r '.runparams // empty' ocaml-versions/$*.json))
opam update
OCAMLRUNPARAM="$(OCAML_RUN_PARAM)" OCAMLCONFIGOPTION="$(OCAML_CONFIG_OPTION)" opam switch create --keep-build-dir --yes $* ocaml-base-compiler.$*
@{ case "$*" in \
*5.0*) opam pin add -n --yes --switch $* sexplib0.v0.15.0 https://github.com/shakthimaan/sexplib0.git#multicore; \
esac };
opam pin add -n --yes --switch $* base.v0.14.3 https://github.com/janestreet/base.git#v0.14.3
opam pin add -n --yes --switch $* sexplib0.v0.15.0 https://github.com/shakthimaan/sexplib0.git#multicore
opam pin add -n --yes --switch $* eventlog-tools https://github.com/ocaml-multicore/eventlog-tools.git#multicore
opam pin add -n --yes --switch $* coq-core https://github.com/ejgallego/coq/archive/refs/tags/multicore-2021-09-29.tar.gz
opam pin add -n --yes --switch $* coq-stdlib https://github.com/ejgallego/coq/archive/refs/tags/multicore-2021-09-29.tar.gz
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ value is `buildbench` which runs the serial benchmarks. For executing the
parallel benchmarks use `multibench_parallel`. You can also setup a custom
bench and add only the benchmarks you care about.

Sandmark has support to build and execute the serial benchmarks in
byte mode. A separate `run_config_byte.json` file has been created for
the same. These benchmarks are relatively slower compared to their
native execution. You can use the following commands to run the serial
benchmarks in byte mode:

```bash
$ opam install dune.2.9.0
$ USE_SYS_DUNE_HACK=1 SANDMARK_CUSTOM_NAME=5.0.0 BUILD_BENCH_TARGET=bytebench \
RUN_CONFIG_JSON=run_config_byte.json make ocaml-versions/5.0.0+stable.bench
```

We can obtain throughput and latency results for the benchmarks. For obtaining
latency results, we can adjust the environment variable `RUN_BENCH_TARGET`.
The scripts for latencies are present in the `pausetimes/` directory. The
Expand Down
5 changes: 4 additions & 1 deletion benchmarks/bdd/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
;; Adapted from OCamlPro's ocamlbench-repo
;; See https://github.com/OCamlPro/ocamlbench-repo
(executable
(name bdd))
(name bdd)
(modes native byte))

(alias (name buildbench) (deps bdd.exe))

(alias (name bytebench) (deps bdd.bc))
7 changes: 7 additions & 0 deletions benchmarks/benchmarksgame/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(executables (names binarytrees5 fannkuchredux fannkuchredux2 fasta3 fasta6
knucleotide knucleotide3 mandelbrot6 nbody pidigits5
regexredux2 revcomp2 spectralnorm2)
(modes native byte)
(libraries unix str zarith))

(rule
Expand All @@ -19,5 +20,11 @@
nbody.exe pidigits5.exe regexredux2.exe revcomp2.exe
spectralnorm2.exe input25000000.txt input5000000.txt))

(alias (name bytebench)
(deps binarytrees5.bc fannkuchredux.bc fannkuchredux2.bc fasta3.bc
fasta6.bc knucleotide.bc knucleotide3.bc mandelbrot6.bc
nbody.bc pidigits5.bc regexredux2.bc revcomp2.bc
spectralnorm2.bc input25000000.txt input5000000.txt))

(alias (name multibench_parallel)
(deps binarytrees5.exe mandelbrot6.exe spectralnorm2.exe))
5 changes: 4 additions & 1 deletion benchmarks/chameneos/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
;; See https://github.com/OCamlPro/ocamlbench-repo
(executable
(name chameneos_redux_lwt)
(modes native byte)
(libraries lwt.unix))

(alias (name buildbench) (deps chameneos_redux_lwt.exe))
(alias (name buildbench) (deps chameneos_redux_lwt.exe))

(alias (name bytebench) (deps chameneos_redux_lwt.bc))
3 changes: 3 additions & 0 deletions benchmarks/decompress/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(executable
(name test_decompress)
(modes native byte)
(modules test_decompress)
(libraries bigstringaf checkseum.ocaml decompress.zl))

Expand All @@ -10,5 +11,7 @@

(alias (name buildbench)
(deps test_decompress.exe))
(alias (name bytebench)
(deps test_decompress.bc))
(alias (name multibench_parallel)
(deps test_decompress.exe test_decompress_multicore.exe))
5 changes: 4 additions & 1 deletion benchmarks/kb/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
;; Adapted from OCamlPro's ocamlbench-repo
;; See https://github.com/OCamlPro/ocamlbench-repo
(executables
(names kb kb_no_exc))
(names kb kb_no_exc)
(modes native byte))

(alias (name buildbench) (deps kb.exe kb_no_exc.exe))

(alias (name bytebench) (deps kb.bc kb_no_exc.bc))
7 changes: 5 additions & 2 deletions benchmarks/lexifi-g2pp/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
;; Adapted from OCamlPro's ocamlbench-repo
;; See https://github.com/OCamlPro/ocamlbench-repo
(executable
(name main))
(name main)
(modes native byte))

(alias (name buildbench) (deps main.exe))
(alias (name buildbench) (deps main.exe))

(alias (name bytebench) (deps main.bc))
5 changes: 5 additions & 0 deletions benchmarks/multicore-grammatrix/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(executable
(name grammatrix)
(modes native byte)
(modules grammatrix)
(libraries unix utls))
;;
Expand All @@ -12,6 +13,10 @@
(deps grammatrix.exe data/tox21_nrar_ligands_std_rand_01.csv
data/1k.csv data/4k.csv))

(alias (name bytebench)
(deps grammatrix.bc data/tox21_nrar_ligands_std_rand_01.csv
data/1k.csv data/4k.csv))

(alias (name multibench_parallel)
(deps grammatrix.exe grammatrix_multicore.exe
data/tox21_nrar_ligands_std_rand_01.csv
Expand Down
14 changes: 14 additions & 0 deletions benchmarks/multicore-numerical/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

(executable
(name quicksort)
(modes native byte)
(modules quicksort))

(executable
Expand All @@ -29,6 +30,7 @@

(executable
(name game_of_life)
(modes native byte)
(modules game_of_life))

(executable
Expand All @@ -38,6 +40,7 @@

(executable
(name matrix_multiplication)
(modes native byte)
(modules matrix_multiplication))

(executable
Expand All @@ -52,6 +55,7 @@

(executable
(name LU_decomposition)
(modes native byte)
(modules LU_decomposition))

(executable
Expand All @@ -61,6 +65,7 @@

(executable
(name floyd_warshall)
(modes native byte)
(modules floyd_warshall))

(executable
Expand All @@ -70,6 +75,7 @@

(executable
(name nbody)
(modes native byte)
(modules nbody))

(executable
Expand All @@ -84,10 +90,12 @@

(executable
(name mergesort)
(modes native byte)
(modules mergesort))

(executable
(name evolutionary_algorithm)
(modes native byte)
(modules evolutionary_algorithm))

(executable
Expand All @@ -112,3 +120,9 @@
(deps game_of_life.exe matrix_multiplication.exe quicksort.exe
mergesort.exe floyd_warshall.exe LU_decomposition.exe
evolutionary_algorithm.exe))

(alias
(name bytebench)
(deps game_of_life.bc matrix_multiplication.bc quicksort.bc
mergesort.bc floyd_warshall.bc evolutionary_algorithm.bc
LU_decomposition.bc nbody.bc mergesort.bc))
19 changes: 15 additions & 4 deletions benchmarks/numerical-analysis/dune
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
;; Adapted from OCamlPro's ocamlbench-repo
;; See https://github.com/OCamlPro/ocamlbench-repo
(executable (name durand_kerner_aberth) (modules durand_kerner_aberth))
(executable (name fft) (modules fft))
(executable (name crout_decomposition) (modules crout_decomposition))
(executable (name qr_decomposition) (modules qr_decomposition))
(executable (name durand_kerner_aberth) (modes native byte) (modules durand_kerner_aberth))
(executable (name fft) (modes native byte) (modules fft))
(executable (name crout_decomposition) (modes native byte) (modules crout_decomposition))
(executable (name qr_decomposition) (modes native byte) (modules qr_decomposition))

(executable
(name levinson_durbin)
(modes native byte)
(modules levinson_durbin levinson_durbin_dataset))
(executable
(name naive_multilayer)
(modes native byte)
(modules naive_multilayer naive_multilayer_dataset))

(alias (name buildbench)
Expand All @@ -20,3 +22,12 @@
qr_decomposition.exe
levinson_durbin.exe
naive_multilayer.exe))

(alias (name bytebench)
(deps
durand_kerner_aberth.bc
fft.bc
crout_decomposition.bc
qr_decomposition.bc
levinson_durbin.bc
naive_multilayer.bc))
4 changes: 3 additions & 1 deletion benchmarks/sequence/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
;; Adapted from OCamlPro's ocamlbench-repo
;; See https://github.com/OCamlPro/ocamlbench-repo
(executable
(name sequence_cps))
(name sequence_cps)
(modes native byte))

(alias (name buildbench) (deps sequence_cps.exe))
(alias (name bytebench) (deps sequence_cps.bc))
10 changes: 7 additions & 3 deletions benchmarks/simple-tests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
(include finalise-dune.inc)

(executables
(names alloc) (modules alloc))
(names alloc)
(modes native byte)
(modules alloc))

(executables
(names alloc_multicore) (modules alloc_multicore))
(names alloc_multicore)
(modules alloc_multicore))

(executables
(names pingpong_multicore) (libraries domainslib) (modules pingpong_multicore))

(executables (names morestacks) (modules morestacks))
(executables (names morestacks) (modes native byte) (modules morestacks))

(alias (name buildbench) (deps alloc.exe morestacks.exe))
(alias (name bytebench) (deps alloc.bc morestacks.bc))
(alias (name multibench_parallel) (deps alloc_multicore.exe pingpong_multicore.exe))
4 changes: 3 additions & 1 deletion benchmarks/simple-tests/finalise-dune.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name finalise) (modules finalise))
(executable (name finalise) (modes native byte) (modules finalise))

(alias (name buildbench) (deps finalise.exe))

(alias (name bytebench) (deps finalise.bc))
6 changes: 4 additions & 2 deletions benchmarks/simple-tests/lazy-dune.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(executable (name lazylist) (modules lazylist))
(executable (name lazy_primes) (modules lazy_primes))
(executable (name lazylist) (modes native byte) (modules lazylist))
(executable (name lazy_primes) (modes native byte) (modules lazy_primes))

(alias (name buildbench) (deps lazylist.exe lazy_primes.exe))

(alias (name bytebench) (deps lazylist.bc))
4 changes: 3 additions & 1 deletion benchmarks/simple-tests/lists-dune.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name lists) (modules lists))
(executable (name lists) (modes native byte) (modules lists))

(alias (name buildbench) (deps lists.exe))

(alias (name bytebench) (deps lists.bc))
4 changes: 3 additions & 1 deletion benchmarks/simple-tests/stacks-dune.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name stacks) (modules stacks))
(executable (name stacks) (modes native byte) (modules stacks))

(alias (name buildbench) (deps stacks.exe))

(alias (name bytebench) (deps stacks.bc))
4 changes: 3 additions & 1 deletion benchmarks/simple-tests/stress-dune.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name stress) (modules stress))
(executable (name stress) (modes native byte) (modules stress))

(alias (name buildbench) (deps stress.exe))

(alias (name bytebench) (deps stress.bc))
4 changes: 3 additions & 1 deletion benchmarks/simple-tests/weak-dune.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(executable (name weakretain) (modules weakretain))
(executable (name weakretain) (modes native byte) (modules weakretain))
; (executable (name weak_htbl) (modules weak_htbl))

;(alias (name buildbench) (deps weakretain.exe weak_htbl.exe))
(alias (name buildbench) (deps weakretain.exe))

(alias (name bytebench) (deps weakretain.bc))
4 changes: 3 additions & 1 deletion benchmarks/stdlib/array.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name array_bench) (modules array_bench))
(executable (name array_bench) (modes native byte) (modules array_bench))

(alias (name buildbench) (deps array_bench.exe))

(alias (name bytebench) (deps array_bench.bc))
4 changes: 3 additions & 1 deletion benchmarks/stdlib/big_array.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name big_array_bench) (modules big_array_bench) (libraries bigarray))
(executable (name big_array_bench) (modes native byte) (modules big_array_bench) (libraries bigarray))

(alias (name buildbench) (deps big_array_bench.exe))

(alias (name bytebench) (deps big_array_bench.bc))
4 changes: 3 additions & 1 deletion benchmarks/stdlib/bytes.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name bytes_bench) (modules bytes_bench))
(executable (name bytes_bench) (modes native byte) (modules bytes_bench))

(alias (name buildbench) (deps bytes_bench.exe))

(alias (name bytebench) (deps bytes_bench.bc))
4 changes: 3 additions & 1 deletion benchmarks/stdlib/hashtbl.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name hashtbl_bench) (modules hashtbl_bench))
(executable (name hashtbl_bench) (modes native byte) (modules hashtbl_bench))

(alias (name buildbench) (deps hashtbl_bench.exe))

(alias (name bytebench) (deps hashtbl_bench.bc))
4 changes: 2 additions & 2 deletions benchmarks/stdlib/map.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(executable (name map_bench) (modules map_bench))
(executable (name map_bench) (modes native byte) (modules map_bench))

(alias (name buildbench) (deps map_bench.exe))
(alias (name bytebench) (deps map_bench.bc))
6 changes: 4 additions & 2 deletions benchmarks/stdlib/pervasives.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name pervasives_bench) (modules pervasives_bench))
(executable (name pervasives_bench) (modes native byte) (modules pervasives_bench))

(alias (name buildbench) (deps pervasives_bench.exe))
(alias (name buildbench) (deps pervasives_bench.exe))

(alias (name bytebench) (deps pervasives_bench.bc))
6 changes: 4 additions & 2 deletions benchmarks/stdlib/set.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name set_bench) (modules set_bench))
(executable (name set_bench) (modes native byte) (modules set_bench))

(alias (name buildbench) (deps set_bench.exe))
(alias (name buildbench) (deps set_bench.exe))

(alias (name bytebench) (deps set_bench.bc))
6 changes: 4 additions & 2 deletions benchmarks/stdlib/stack.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable (name stack_bench) (modules stack_bench))
(executable (name stack_bench) (modes native byte) (modules stack_bench))

(alias (name buildbench) (deps stack_bench.exe))
(alias (name buildbench) (deps stack_bench.exe))

(alias (name bytebench) (deps stack_bench.bc))
Loading

0 comments on commit 2e38ae9

Please sign in to comment.