From 38001356cdeaa1d2df2ab334b7e28cd065612162 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 4 Apr 2022 14:31:30 +0100 Subject: [PATCH 01/21] added two serial benchmarks namely: hamming and soli with their respective dune files with corresponding runs in run_config.json --- benchmarks/hamming/dune | 6 ++ benchmarks/hamming/hamming.ml | 94 ++++++++++++++++ benchmarks/soli/dune | 5 + benchmarks/soli/soli.ml | 100 ++++++++++++++++++ .../files/invoke-configure.sh | 16 +++ .../ocaml-base-compiler.4.14.0+domains/opam | 19 ++++ .../files/invoke-configure.sh | 16 +++ .../ocaml-base-compiler.5.0.0+stable/opam | 19 ++++ .../files/invoke-configure.sh | 16 +++ .../ocaml-base-compiler.5.0.0+trunk/opam | 19 ++++ .../packages/ocaml/ocaml.4.14.0+domains/opam | 27 +++++ .../packages/ocaml/ocaml.5.0.0+stable/opam | 27 +++++ run_config.json | 26 +++++ 13 files changed, 390 insertions(+) create mode 100644 benchmarks/hamming/dune create mode 100644 benchmarks/hamming/hamming.ml create mode 100644 benchmarks/soli/dune create mode 100644 benchmarks/soli/soli.ml create mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh create mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam create mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh create mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam create mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh create mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam create mode 100644 dependencies/packages/ocaml/ocaml.4.14.0+domains/opam create mode 100644 dependencies/packages/ocaml/ocaml.5.0.0+stable/opam diff --git a/benchmarks/hamming/dune b/benchmarks/hamming/dune new file mode 100644 index 0000000000..ae053fffac --- /dev/null +++ b/benchmarks/hamming/dune @@ -0,0 +1,6 @@ + +(executable + (name hamming) + (modes byte exe)) + (alias (name hamming) + (deps hamming.exe)) \ No newline at end of file diff --git a/benchmarks/hamming/hamming.ml b/benchmarks/hamming/hamming.ml new file mode 100644 index 0000000000..0c9a614408 --- /dev/null +++ b/benchmarks/hamming/hamming.ml @@ -0,0 +1,94 @@ +(* TEST +*) + +(* We cannot use bignums because we don't do custom runtimes, but + int64 is a bit short, so we roll our own 37-digit numbers... +*) + +let n0 = Int64.of_int 0;; +let n1 = Int64.of_int 1;; +let n2 = Int64.of_int 2;; +let n3 = Int64.of_int 3;; +let n5 = Int64.of_int 5;; + +let ( % ) = Int64.rem;; +let ( * ) = Int64.mul;; +let ( / ) = Int64.div;; +let ( + ) = Int64.add;; +let digit = Int64.of_string "1000000000000000000";; + +let mul n (pl, ph) = ((n * pl) % digit, n * ph + (n * pl) / digit);; +let cmp (nl, nh) (pl, ph) = + if nh < ph then -1 + else if nh > ph then 1 + else if nl < pl then -1 + else if nl > pl then 1 + else 0 +;; + +let x2 = fun p -> mul n2 p;; +let x3 = fun p -> mul n3 p;; +let x5 = fun p -> mul n5 p;; + +let nn1 = (n1, n0);; + +let pr (nl, nh) = + if compare nh n0 = 0 + then Printf.printf "%Ld\n" nl + else Printf.printf "%Ld%018Ld\n" nh nl +;; + +(* + (* bignum version *) +open Num;; +let nn1 = num_of_int 1;; +let x2 = fun p -> (num_of_int 2) */ p;; +let x3 = fun p -> (num_of_int 3) */ p;; +let x5 = fun p -> (num_of_int 5) */ p;; +let cmp n p = sign_num (n -/ p);; +let pr n = Printf.printf "%s\n" (string_of_num n);; +*) + + +(* This is where the interesting stuff begins. *) + +open Lazy;; + +type 'a lcons = Cons of 'a * 'a lcons Lazy.t;; +type 'a llist = 'a lcons Lazy.t;; + +let rec map f l = + lazy ( + match force l with + | Cons (x, ll) -> Cons (f x, map f ll) + ) +;; + +let rec merge cmp l1 l2 = + lazy ( + match force l1, force l2 with + | Cons (x1, ll1), Cons (x2, ll2) + -> let c = cmp x1 x2 in + if c = 0 + then Cons (x1, merge cmp ll1 ll2) + else if c < 0 + then Cons (x1, merge cmp ll1 l2) + else Cons (x2, merge cmp l1 ll2) + ) +;; + +let rec iter_interval f l (start, stop) = + if stop = 0 then () + else match force l with + | Cons (x, ll) + -> if start <= 0 then f x; + iter_interval f ll (start-1, stop-1) +;; + +let rec hamming = lazy (Cons (nn1, merge cmp ham2 (merge cmp ham3 ham5))) + and ham2 = lazy (force (map x2 hamming)) + and ham3 = lazy (force (map x3 hamming)) + and ham5 = lazy (force (map x5 hamming)) +;; + +iter_interval pr hamming (88000, 88100);; \ No newline at end of file diff --git a/benchmarks/soli/dune b/benchmarks/soli/dune new file mode 100644 index 0000000000..133e9c9c43 --- /dev/null +++ b/benchmarks/soli/dune @@ -0,0 +1,5 @@ +(executable + (name soli) + (modes byte exe)) + + (alias (name buildbench) (deps soli.exe)) \ No newline at end of file diff --git a/benchmarks/soli/soli.ml b/benchmarks/soli/soli.ml new file mode 100644 index 0000000000..0e6f9bf18a --- /dev/null +++ b/benchmarks/soli/soli.ml @@ -0,0 +1,100 @@ +(* TEST + flags += " -unsafe " +*) + +type peg = Out | Empty | Peg + +let board = [| + [| Out; Out; Out; Out; Out; Out; Out; Out; Out|]; + [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; + [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; + [| Out; Peg; Peg; Peg; Peg; Peg; Peg; Peg; Out|]; + [| Out; Peg; Peg; Peg; Empty; Peg; Peg; Peg; Out|]; + [| Out; Peg; Peg; Peg; Peg; Peg; Peg; Peg; Out|]; + [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; + [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; + [| Out; Out; Out; Out; Out; Out; Out; Out; Out|] +|] + + +let print_peg = function + Out -> print_string "." + | Empty -> print_string " " + | Peg -> print_string "$" + + +let print_board board = + for i=0 to 8 do + for j=0 to 8 do + print_peg board.(i).(j) + done; + print_newline() + done + + +type direction = { dx: int; dy: int } + +let dir = [| {dx = 0; dy = 1}; {dx = 1; dy = 0}; + {dx = 0; dy = -1}; {dx = -1; dy = 0} |] + +type move = { x1: int; y1: int; x2: int; y2: int } + +let moves = Array.make 31 {x1=0;y1=0;x2=0;y2=0} + +let counter = ref 0 + +exception Found + +let rec solve m = + counter := !counter + 1; + if m = 31 then + begin match board.(4).(4) with Peg -> true | _ -> false end + else + try + if !counter mod 500 = 0 then begin + print_int !counter; print_newline() + end; + for i=1 to 7 do + for j=1 to 7 do + match board.(i).(j) with + Peg -> + for k=0 to 3 do + let d1 = dir.(k).dx in + let d2 = dir.(k).dy in + let i1 = i+d1 in + let i2 = i1+d1 in + let j1 = j+d2 in + let j2 = j1+d2 in + match board.(i1).(j1) with + Peg -> + begin match board.(i2).(j2) with + Empty -> +(* + print_int i; print_string ", "; + print_int j; print_string ") dir "; + print_int k; print_string "\n"; +*) + board.(i).(j) <- Empty; + board.(i1).(j1) <- Empty; + board.(i2).(j2) <- Peg; + if solve(m+1) then begin + moves.(m) <- { x1=i; y1=j; x2=i2; y2=j2 }; + raise Found + end; + board.(i).(j) <- Peg; + board.(i1).(j1) <- Peg; + board.(i2).(j2) <- Empty + | _ -> () + end + | _ -> () + done + | _ -> + () + done + done; + false + with Found -> + true + + +let _ = if solve 0 then (print_string "\n"; print_board board) \ No newline at end of file diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh new file mode 100644 index 0000000000..30095bb280 --- /dev/null +++ b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh @@ -0,0 +1,16 @@ +prefix="$1" +os="$2" +if [ -e configure.ac ]; then + exec ./configure ${OCAMLCONFIGOPTION} --prefix "$prefix" --with-default-string=unsafe +else + unsafe_string='' + if grep -q 'default_safe_string=true' configure; then + unsafe_string='-no-force-safe-string -default-unsafe-string' + fi + case "$os" in + macos|freebsd|openbsd) + exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string -cc cc -aspp "cc -c";; + *) + exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string;; + esac +fi diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam new file mode 100644 index 0000000000..39649573ac --- /dev/null +++ b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam @@ -0,0 +1,19 @@ +opam-version: "2.0" +synopsis: "OCaml compiler" +maintainer: "platform@lists.ocaml.org" +depends: [ + "ocaml" {= _:version & post} + "base-unix" {post} + "base-bigarray" {post} + "base-threads" {post} +] +conflict-class: "ocaml-core-compiler" +flags: compiler +build: [ + ["sh" "invoke-configure.sh" prefix os] + [make "-j" jobs "world"] + [make "-j" jobs "world.opt"] +] +install: [make "install"] +url { src: "https://github.com/ocaml-multicore/ocaml-multicore/archive/refs/heads/5.00.zip" } +setenv: [ [ ORUN_CONFIG_ocaml_url = "https://github.com/ocaml-multicore/ocaml-multicore/archive/refs/heads/5.00.zip" ] ] diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh new file mode 100644 index 0000000000..30095bb280 --- /dev/null +++ b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh @@ -0,0 +1,16 @@ +prefix="$1" +os="$2" +if [ -e configure.ac ]; then + exec ./configure ${OCAMLCONFIGOPTION} --prefix "$prefix" --with-default-string=unsafe +else + unsafe_string='' + if grep -q 'default_safe_string=true' configure; then + unsafe_string='-no-force-safe-string -default-unsafe-string' + fi + case "$os" in + macos|freebsd|openbsd) + exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string -cc cc -aspp "cc -c";; + *) + exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string;; + esac +fi diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam new file mode 100644 index 0000000000..31d8202c0d --- /dev/null +++ b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam @@ -0,0 +1,19 @@ +opam-version: "2.0" +synopsis: "OCaml compiler" +maintainer: "platform@lists.ocaml.org" +depends: [ + "ocaml" {= _:version & post} + "base-unix" {post} + "base-bigarray" {post} + "base-threads" {post} +] +conflict-class: "ocaml-core-compiler" +flags: compiler +build: [ + ["sh" "invoke-configure.sh" prefix os] + [make "-j" jobs "world"] + [make "-j" jobs "world.opt"] +] +install: [make "install"] +url { src: "https://github.com/ocaml/ocaml/archive/2422a5984a8cc597a44c214946677e562d8808bf.zip" } +setenv: [ [ ORUN_CONFIG_ocaml_url = "https://github.com/ocaml/ocaml/archive/2422a5984a8cc597a44c214946677e562d8808bf.zip" ] ] diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh new file mode 100644 index 0000000000..30095bb280 --- /dev/null +++ b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh @@ -0,0 +1,16 @@ +prefix="$1" +os="$2" +if [ -e configure.ac ]; then + exec ./configure ${OCAMLCONFIGOPTION} --prefix "$prefix" --with-default-string=unsafe +else + unsafe_string='' + if grep -q 'default_safe_string=true' configure; then + unsafe_string='-no-force-safe-string -default-unsafe-string' + fi + case "$os" in + macos|freebsd|openbsd) + exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string -cc cc -aspp "cc -c";; + *) + exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string;; + esac +fi diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam new file mode 100644 index 0000000000..8399752b6e --- /dev/null +++ b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam @@ -0,0 +1,19 @@ +opam-version: "2.0" +synopsis: "OCaml compiler" +maintainer: "platform@lists.ocaml.org" +depends: [ + "ocaml" {= _:version & post} + "base-unix" {post} + "base-bigarray" {post} + "base-threads" {post} +] +conflict-class: "ocaml-core-compiler" +flags: compiler +build: [ + ["sh" "invoke-configure.sh" prefix os] + [make "-j" jobs "world"] + [make "-j" jobs "world.opt"] +] +install: [make "install"] +url { src: "https://github.com/ocaml/ocaml/archive/trunk.tar.gz" } +setenv: [ [ ORUN_CONFIG_ocaml_url = "https://github.com/ocaml/ocaml/archive/trunk.tar.gz" ] ] diff --git a/dependencies/packages/ocaml/ocaml.4.14.0+domains/opam b/dependencies/packages/ocaml/ocaml.4.14.0+domains/opam new file mode 100644 index 0000000000..3598e70698 --- /dev/null +++ b/dependencies/packages/ocaml/ocaml.4.14.0+domains/opam @@ -0,0 +1,27 @@ +opam-version: "2.0" +synopsis: "The OCaml compiler (virtual package)" +description: """ +This package requires a matching implementation of OCaml, +and polls it to initialise specific variables like `ocaml:native-dynlink`""" +maintainer: "platform@lists.ocaml.org" +depends: [ + "ocaml-config" + "ocaml-base-compiler" {= _:version} +] +setenv: [ + [CAML_LD_LIBRARY_PATH = "%{_:stubsdir}%"] + [CAML_LD_LIBRARY_PATH += "%{lib}%/stublibs"] + [OCAML_TOPLEVEL_PATH = "%{toplevel}%"] +] +build: ["ocaml" "%{ocaml-config:share}%/gen_ocaml_config.ml" _:version _:name] +build-env: CAML_LD_LIBRARY_PATH = "" +homepage: "https://ocaml.org" +bug-reports: "https://caml.inria.fr/mantis/" +authors: [ + "Xavier Leroy" + "Damien Doligez" + "Alain Frisch" + "Jacques Garrigue" + "Didier Rémy" + "Jérôme Vouillon" +] diff --git a/dependencies/packages/ocaml/ocaml.5.0.0+stable/opam b/dependencies/packages/ocaml/ocaml.5.0.0+stable/opam new file mode 100644 index 0000000000..3598e70698 --- /dev/null +++ b/dependencies/packages/ocaml/ocaml.5.0.0+stable/opam @@ -0,0 +1,27 @@ +opam-version: "2.0" +synopsis: "The OCaml compiler (virtual package)" +description: """ +This package requires a matching implementation of OCaml, +and polls it to initialise specific variables like `ocaml:native-dynlink`""" +maintainer: "platform@lists.ocaml.org" +depends: [ + "ocaml-config" + "ocaml-base-compiler" {= _:version} +] +setenv: [ + [CAML_LD_LIBRARY_PATH = "%{_:stubsdir}%"] + [CAML_LD_LIBRARY_PATH += "%{lib}%/stublibs"] + [OCAML_TOPLEVEL_PATH = "%{toplevel}%"] +] +build: ["ocaml" "%{ocaml-config:share}%/gen_ocaml_config.ml" _:version _:name] +build-env: CAML_LD_LIBRARY_PATH = "" +homepage: "https://ocaml.org" +bug-reports: "https://caml.inria.fr/mantis/" +authors: [ + "Xavier Leroy" + "Damien Doligez" + "Alain Frisch" + "Jacques Garrigue" + "Didier Rémy" + "Jérôme Vouillon" +] diff --git a/run_config.json b/run_config.json index f69838778c..d959eb3b25 100644 --- a/run_config.json +++ b/run_config.json @@ -1520,6 +1520,32 @@ "params": "" } ] + }, + { + "executable": "benchmarks/soli/soli.exe", + "name": "soli", + "tags": [ + "1s_10s", + "macro_bench" + ], + "runs": [ + { + "params": "1024" + } + ] + }, + { + "executable": "benchmarks/hamming/hamming.exe", + "name": "hamming", + "tags": [ + "1s_10s", + "macro_bench" + ], + "runs": [ + { + "params": "1024" + } + ] } ] } From 243ab2e5eab1ce84d5998a95abf52894b656e4c0 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 6 Apr 2022 04:25:57 +0100 Subject: [PATCH 02/21] Delete opam Compiler opam removed --- .../packages/ocaml/ocaml.5.0.0+stable/opam | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 dependencies/packages/ocaml/ocaml.5.0.0+stable/opam diff --git a/dependencies/packages/ocaml/ocaml.5.0.0+stable/opam b/dependencies/packages/ocaml/ocaml.5.0.0+stable/opam deleted file mode 100644 index 3598e70698..0000000000 --- a/dependencies/packages/ocaml/ocaml.5.0.0+stable/opam +++ /dev/null @@ -1,27 +0,0 @@ -opam-version: "2.0" -synopsis: "The OCaml compiler (virtual package)" -description: """ -This package requires a matching implementation of OCaml, -and polls it to initialise specific variables like `ocaml:native-dynlink`""" -maintainer: "platform@lists.ocaml.org" -depends: [ - "ocaml-config" - "ocaml-base-compiler" {= _:version} -] -setenv: [ - [CAML_LD_LIBRARY_PATH = "%{_:stubsdir}%"] - [CAML_LD_LIBRARY_PATH += "%{lib}%/stublibs"] - [OCAML_TOPLEVEL_PATH = "%{toplevel}%"] -] -build: ["ocaml" "%{ocaml-config:share}%/gen_ocaml_config.ml" _:version _:name] -build-env: CAML_LD_LIBRARY_PATH = "" -homepage: "https://ocaml.org" -bug-reports: "https://caml.inria.fr/mantis/" -authors: [ - "Xavier Leroy" - "Damien Doligez" - "Alain Frisch" - "Jacques Garrigue" - "Didier Rémy" - "Jérôme Vouillon" -] From 39865930351add0e52d45058e0b38da3df706013 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 6 Apr 2022 10:36:20 +0100 Subject: [PATCH 03/21] Update dune --- benchmarks/hamming/dune | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmarks/hamming/dune b/benchmarks/hamming/dune index ae053fffac..26f0416d99 100644 --- a/benchmarks/hamming/dune +++ b/benchmarks/hamming/dune @@ -2,5 +2,5 @@ (executable (name hamming) (modes byte exe)) - (alias (name hamming) - (deps hamming.exe)) \ No newline at end of file + (alias (name buildbench) + (deps hamming.exe)) From 0e8035e29582aad1318a4bdde685b4f7e65788c1 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 6 Apr 2022 10:38:04 +0100 Subject: [PATCH 04/21] Delete opam --- .../ocaml-base-compiler.4.14.0+domains/opam | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam deleted file mode 100644 index 39649573ac..0000000000 --- a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/opam +++ /dev/null @@ -1,19 +0,0 @@ -opam-version: "2.0" -synopsis: "OCaml compiler" -maintainer: "platform@lists.ocaml.org" -depends: [ - "ocaml" {= _:version & post} - "base-unix" {post} - "base-bigarray" {post} - "base-threads" {post} -] -conflict-class: "ocaml-core-compiler" -flags: compiler -build: [ - ["sh" "invoke-configure.sh" prefix os] - [make "-j" jobs "world"] - [make "-j" jobs "world.opt"] -] -install: [make "install"] -url { src: "https://github.com/ocaml-multicore/ocaml-multicore/archive/refs/heads/5.00.zip" } -setenv: [ [ ORUN_CONFIG_ocaml_url = "https://github.com/ocaml-multicore/ocaml-multicore/archive/refs/heads/5.00.zip" ] ] From 29bc05845f1f7274df202a761acdab58ce823059 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 6 Apr 2022 10:38:29 +0100 Subject: [PATCH 05/21] Delete opam --- .../ocaml-base-compiler.5.0.0+stable/opam | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam deleted file mode 100644 index 31d8202c0d..0000000000 --- a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/opam +++ /dev/null @@ -1,19 +0,0 @@ -opam-version: "2.0" -synopsis: "OCaml compiler" -maintainer: "platform@lists.ocaml.org" -depends: [ - "ocaml" {= _:version & post} - "base-unix" {post} - "base-bigarray" {post} - "base-threads" {post} -] -conflict-class: "ocaml-core-compiler" -flags: compiler -build: [ - ["sh" "invoke-configure.sh" prefix os] - [make "-j" jobs "world"] - [make "-j" jobs "world.opt"] -] -install: [make "install"] -url { src: "https://github.com/ocaml/ocaml/archive/2422a5984a8cc597a44c214946677e562d8808bf.zip" } -setenv: [ [ ORUN_CONFIG_ocaml_url = "https://github.com/ocaml/ocaml/archive/2422a5984a8cc597a44c214946677e562d8808bf.zip" ] ] From 2c644665fd7ab44e3d010028d1314b2f1321f5e9 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 6 Apr 2022 10:39:03 +0100 Subject: [PATCH 06/21] Delete opam --- .../ocaml-base-compiler.5.0.0+trunk/opam | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam deleted file mode 100644 index 8399752b6e..0000000000 --- a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/opam +++ /dev/null @@ -1,19 +0,0 @@ -opam-version: "2.0" -synopsis: "OCaml compiler" -maintainer: "platform@lists.ocaml.org" -depends: [ - "ocaml" {= _:version & post} - "base-unix" {post} - "base-bigarray" {post} - "base-threads" {post} -] -conflict-class: "ocaml-core-compiler" -flags: compiler -build: [ - ["sh" "invoke-configure.sh" prefix os] - [make "-j" jobs "world"] - [make "-j" jobs "world.opt"] -] -install: [make "install"] -url { src: "https://github.com/ocaml/ocaml/archive/trunk.tar.gz" } -setenv: [ [ ORUN_CONFIG_ocaml_url = "https://github.com/ocaml/ocaml/archive/trunk.tar.gz" ] ] From eba9e583d379a2c905b7b764bc5627e99f0767f6 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 6 Apr 2022 10:40:00 +0100 Subject: [PATCH 07/21] Delete opam --- .../packages/ocaml/ocaml.4.14.0+domains/opam | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 dependencies/packages/ocaml/ocaml.4.14.0+domains/opam diff --git a/dependencies/packages/ocaml/ocaml.4.14.0+domains/opam b/dependencies/packages/ocaml/ocaml.4.14.0+domains/opam deleted file mode 100644 index 3598e70698..0000000000 --- a/dependencies/packages/ocaml/ocaml.4.14.0+domains/opam +++ /dev/null @@ -1,27 +0,0 @@ -opam-version: "2.0" -synopsis: "The OCaml compiler (virtual package)" -description: """ -This package requires a matching implementation of OCaml, -and polls it to initialise specific variables like `ocaml:native-dynlink`""" -maintainer: "platform@lists.ocaml.org" -depends: [ - "ocaml-config" - "ocaml-base-compiler" {= _:version} -] -setenv: [ - [CAML_LD_LIBRARY_PATH = "%{_:stubsdir}%"] - [CAML_LD_LIBRARY_PATH += "%{lib}%/stublibs"] - [OCAML_TOPLEVEL_PATH = "%{toplevel}%"] -] -build: ["ocaml" "%{ocaml-config:share}%/gen_ocaml_config.ml" _:version _:name] -build-env: CAML_LD_LIBRARY_PATH = "" -homepage: "https://ocaml.org" -bug-reports: "https://caml.inria.fr/mantis/" -authors: [ - "Xavier Leroy" - "Damien Doligez" - "Alain Frisch" - "Jacques Garrigue" - "Didier Rémy" - "Jérôme Vouillon" -] From 540336452f24c1c3bbc8bb228abc5e5bc57281b4 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Thu, 7 Apr 2022 15:20:42 +0100 Subject: [PATCH 08/21] Delete invoke-configure.sh --- .../files/invoke-configure.sh | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh deleted file mode 100644 index 30095bb280..0000000000 --- a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.4.14.0+domains/files/invoke-configure.sh +++ /dev/null @@ -1,16 +0,0 @@ -prefix="$1" -os="$2" -if [ -e configure.ac ]; then - exec ./configure ${OCAMLCONFIGOPTION} --prefix "$prefix" --with-default-string=unsafe -else - unsafe_string='' - if grep -q 'default_safe_string=true' configure; then - unsafe_string='-no-force-safe-string -default-unsafe-string' - fi - case "$os" in - macos|freebsd|openbsd) - exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string -cc cc -aspp "cc -c";; - *) - exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string;; - esac -fi From fa850308a82872d552d15e0efd9ee5d67caf9833 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Thu, 7 Apr 2022 15:22:26 +0100 Subject: [PATCH 09/21] Delete invoke-configure.sh --- .../files/invoke-configure.sh | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh deleted file mode 100644 index 30095bb280..0000000000 --- a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+stable/files/invoke-configure.sh +++ /dev/null @@ -1,16 +0,0 @@ -prefix="$1" -os="$2" -if [ -e configure.ac ]; then - exec ./configure ${OCAMLCONFIGOPTION} --prefix "$prefix" --with-default-string=unsafe -else - unsafe_string='' - if grep -q 'default_safe_string=true' configure; then - unsafe_string='-no-force-safe-string -default-unsafe-string' - fi - case "$os" in - macos|freebsd|openbsd) - exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string -cc cc -aspp "cc -c";; - *) - exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string;; - esac -fi From 677b6c72c875dbfbf47df963bf12a5477062438d Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Thu, 7 Apr 2022 15:23:28 +0100 Subject: [PATCH 10/21] Delete invoke-configure.sh --- .../files/invoke-configure.sh | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh diff --git a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh b/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh deleted file mode 100644 index 30095bb280..0000000000 --- a/dependencies/packages/ocaml-base-compiler/ocaml-base-compiler.5.0.0+trunk/files/invoke-configure.sh +++ /dev/null @@ -1,16 +0,0 @@ -prefix="$1" -os="$2" -if [ -e configure.ac ]; then - exec ./configure ${OCAMLCONFIGOPTION} --prefix "$prefix" --with-default-string=unsafe -else - unsafe_string='' - if grep -q 'default_safe_string=true' configure; then - unsafe_string='-no-force-safe-string -default-unsafe-string' - fi - case "$os" in - macos|freebsd|openbsd) - exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string -cc cc -aspp "cc -c";; - *) - exec ./configure ${OCAMLCONFIGOPTION} -prefix "$prefix" $unsafe_string;; - esac -fi From 0d858dcb06fa7ba5f5554c2daaf9b8a4bf007d93 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Fri, 8 Apr 2022 15:08:49 +0100 Subject: [PATCH 11/21] test --- wget-log | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 wget-log diff --git a/wget-log b/wget-log new file mode 100644 index 0000000000..664fb81d1a --- /dev/null +++ b/wget-log @@ -0,0 +1,28 @@ +failed: Connection timed out. +Connecting to github.com (github.com)|192.48.79.30|:443... failed: Connection timed out. +Connecting to github.com (github.com)|192.52.178.30|:443... failed: Connection timed out. +Connecting to github.com (github.com)|192.55.83.30|:443... failed: Connection timed out. +Connecting to github.com (github.com)|2001:500:d937::30|:443... failed: Network is unreachable. +Resolving github.com (github.com)... 140.82.121.3, 192.55.83.30, 192.52.178.30, ... +Connecting to github.com (github.com)|140.82.121.3|:443... connected. +HTTP request sent, awaiting response... 302 Found +Location: https://codeload.github.com/ocaml/ocaml/zip/b73cbbea4bc40ffd26a459d594a39b99cec4273d [following] +Spider mode enabled. Check if remote file exists. +--2022-04-08 13:45:05-- https://codeload.github.com/ocaml/ocaml/zip/b73cbbea4bc40ffd26a459d594a39b99cec4273d +Connecting to codeload.github.com (codeload.github.com)|140.82.121.10|:443... connected. +HTTP request sent, awaiting response... 200 OK +Length: unspecified [application/zip] +Remote file exists. + +Spider mode enabled. Check if remote file exists. +--2022-04-08 13:45:05-- https://github.com/sadiqj/ocaml/archive/refs/heads/eventring-pr.zip +Connecting to github.com (github.com)|140.82.121.3|:443... connected. +HTTP request sent, awaiting response... 302 Found +Location: https://codeload.github.com/sadiqj/ocaml/zip/refs/heads/eventring-pr [following] +Spider mode enabled. Check if remote file exists. +--2022-04-08 13:45:06-- https://codeload.github.com/sadiqj/ocaml/zip/refs/heads/eventring-pr +Connecting to codeload.github.com (codeload.github.com)|140.82.121.10|:443... connected. +HTTP request sent, awaiting response... 200 OK +Length: unspecified [application/zip] +Remote file exists. + From 8384c851e9a896bc5e41f9abe6e15f8636034afa Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 11 Apr 2022 13:42:39 +0100 Subject: [PATCH 12/21] changed params values --- benchmarks/hamming/dune | 2 ++ benchmarks/soli/dune | 2 ++ run_config.json | 15 ++++++++++----- wget-log | 28 ---------------------------- 4 files changed, 14 insertions(+), 33 deletions(-) delete mode 100644 wget-log diff --git a/benchmarks/hamming/dune b/benchmarks/hamming/dune index 26f0416d99..c73bfa1655 100644 --- a/benchmarks/hamming/dune +++ b/benchmarks/hamming/dune @@ -1,4 +1,6 @@ +;; Adapted from OCamlPro's ocamlbench-repo +;; See https://github.com/OCamlPro/ocamlbench-repo (executable (name hamming) (modes byte exe)) diff --git a/benchmarks/soli/dune b/benchmarks/soli/dune index 133e9c9c43..0cee37989a 100644 --- a/benchmarks/soli/dune +++ b/benchmarks/soli/dune @@ -1,3 +1,5 @@ +;; Adapted from OCamlPro's ocamlbench-repo +;; See https://github.com/OCamlPro/ocamlbench-repo (executable (name soli) (modes byte exe)) diff --git a/run_config.json b/run_config.json index d959eb3b25..e220c19d46 100644 --- a/run_config.json +++ b/run_config.json @@ -331,9 +331,11 @@ { "executable": "benchmarks/benchmarksgame/knucleotide3.exe", "name": "knucleotide3", + "tags": [ "10s_100s", "macro_bench" + ], "runs": [ { @@ -491,7 +493,8 @@ "name": "test_lwt", "tags": [ "10s_100s", - "macro_bench" + "macro_bench", + "run_in_ci" ], "runs": [ { @@ -1527,10 +1530,11 @@ "tags": [ "1s_10s", "macro_bench" + ], "runs": [ { - "params": "1024" + "params": "200" } ] }, @@ -1538,14 +1542,15 @@ "executable": "benchmarks/hamming/hamming.exe", "name": "hamming", "tags": [ - "1s_10s", + "10s_100s", "macro_bench" + ], "runs": [ { - "params": "1024" + "params": "200" } - ] + ] } ] } diff --git a/wget-log b/wget-log deleted file mode 100644 index 664fb81d1a..0000000000 --- a/wget-log +++ /dev/null @@ -1,28 +0,0 @@ -failed: Connection timed out. -Connecting to github.com (github.com)|192.48.79.30|:443... failed: Connection timed out. -Connecting to github.com (github.com)|192.52.178.30|:443... failed: Connection timed out. -Connecting to github.com (github.com)|192.55.83.30|:443... failed: Connection timed out. -Connecting to github.com (github.com)|2001:500:d937::30|:443... failed: Network is unreachable. -Resolving github.com (github.com)... 140.82.121.3, 192.55.83.30, 192.52.178.30, ... -Connecting to github.com (github.com)|140.82.121.3|:443... connected. -HTTP request sent, awaiting response... 302 Found -Location: https://codeload.github.com/ocaml/ocaml/zip/b73cbbea4bc40ffd26a459d594a39b99cec4273d [following] -Spider mode enabled. Check if remote file exists. ---2022-04-08 13:45:05-- https://codeload.github.com/ocaml/ocaml/zip/b73cbbea4bc40ffd26a459d594a39b99cec4273d -Connecting to codeload.github.com (codeload.github.com)|140.82.121.10|:443... connected. -HTTP request sent, awaiting response... 200 OK -Length: unspecified [application/zip] -Remote file exists. - -Spider mode enabled. Check if remote file exists. ---2022-04-08 13:45:05-- https://github.com/sadiqj/ocaml/archive/refs/heads/eventring-pr.zip -Connecting to github.com (github.com)|140.82.121.3|:443... connected. -HTTP request sent, awaiting response... 302 Found -Location: https://codeload.github.com/sadiqj/ocaml/zip/refs/heads/eventring-pr [following] -Spider mode enabled. Check if remote file exists. ---2022-04-08 13:45:06-- https://codeload.github.com/sadiqj/ocaml/zip/refs/heads/eventring-pr -Connecting to codeload.github.com (codeload.github.com)|140.82.121.10|:443... connected. -HTTP request sent, awaiting response... 200 OK -Length: unspecified [application/zip] -Remote file exists. - From 7a5e851b6467f4ab6a119444b8c34304f9fd7624 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Thu, 14 Apr 2022 09:06:13 +0100 Subject: [PATCH 13/21] added mergesort parallel benchmark --- benchmarks/hamming/dune | 8 -- benchmarks/hamming/hamming.ml | 94 ---------------- benchmarks/mergesort/dune | 9 ++ benchmarks/mergesort/mergesort.ml | 169 +++++++++++++++++++++++++++++ benchmarks/soli/dune | 7 -- benchmarks/soli/soli.ml | 100 ----------------- multicore_parallel_run_config.json | 39 +++++-- run_config.json | 65 ++++------- 8 files changed, 229 insertions(+), 262 deletions(-) delete mode 100644 benchmarks/hamming/dune delete mode 100644 benchmarks/hamming/hamming.ml create mode 100644 benchmarks/mergesort/dune create mode 100644 benchmarks/mergesort/mergesort.ml delete mode 100644 benchmarks/soli/dune delete mode 100644 benchmarks/soli/soli.ml diff --git a/benchmarks/hamming/dune b/benchmarks/hamming/dune deleted file mode 100644 index c73bfa1655..0000000000 --- a/benchmarks/hamming/dune +++ /dev/null @@ -1,8 +0,0 @@ - -;; Adapted from OCamlPro's ocamlbench-repo -;; See https://github.com/OCamlPro/ocamlbench-repo -(executable - (name hamming) - (modes byte exe)) - (alias (name buildbench) - (deps hamming.exe)) diff --git a/benchmarks/hamming/hamming.ml b/benchmarks/hamming/hamming.ml deleted file mode 100644 index 0c9a614408..0000000000 --- a/benchmarks/hamming/hamming.ml +++ /dev/null @@ -1,94 +0,0 @@ -(* TEST -*) - -(* We cannot use bignums because we don't do custom runtimes, but - int64 is a bit short, so we roll our own 37-digit numbers... -*) - -let n0 = Int64.of_int 0;; -let n1 = Int64.of_int 1;; -let n2 = Int64.of_int 2;; -let n3 = Int64.of_int 3;; -let n5 = Int64.of_int 5;; - -let ( % ) = Int64.rem;; -let ( * ) = Int64.mul;; -let ( / ) = Int64.div;; -let ( + ) = Int64.add;; -let digit = Int64.of_string "1000000000000000000";; - -let mul n (pl, ph) = ((n * pl) % digit, n * ph + (n * pl) / digit);; -let cmp (nl, nh) (pl, ph) = - if nh < ph then -1 - else if nh > ph then 1 - else if nl < pl then -1 - else if nl > pl then 1 - else 0 -;; - -let x2 = fun p -> mul n2 p;; -let x3 = fun p -> mul n3 p;; -let x5 = fun p -> mul n5 p;; - -let nn1 = (n1, n0);; - -let pr (nl, nh) = - if compare nh n0 = 0 - then Printf.printf "%Ld\n" nl - else Printf.printf "%Ld%018Ld\n" nh nl -;; - -(* - (* bignum version *) -open Num;; -let nn1 = num_of_int 1;; -let x2 = fun p -> (num_of_int 2) */ p;; -let x3 = fun p -> (num_of_int 3) */ p;; -let x5 = fun p -> (num_of_int 5) */ p;; -let cmp n p = sign_num (n -/ p);; -let pr n = Printf.printf "%s\n" (string_of_num n);; -*) - - -(* This is where the interesting stuff begins. *) - -open Lazy;; - -type 'a lcons = Cons of 'a * 'a lcons Lazy.t;; -type 'a llist = 'a lcons Lazy.t;; - -let rec map f l = - lazy ( - match force l with - | Cons (x, ll) -> Cons (f x, map f ll) - ) -;; - -let rec merge cmp l1 l2 = - lazy ( - match force l1, force l2 with - | Cons (x1, ll1), Cons (x2, ll2) - -> let c = cmp x1 x2 in - if c = 0 - then Cons (x1, merge cmp ll1 ll2) - else if c < 0 - then Cons (x1, merge cmp ll1 l2) - else Cons (x2, merge cmp l1 ll2) - ) -;; - -let rec iter_interval f l (start, stop) = - if stop = 0 then () - else match force l with - | Cons (x, ll) - -> if start <= 0 then f x; - iter_interval f ll (start-1, stop-1) -;; - -let rec hamming = lazy (Cons (nn1, merge cmp ham2 (merge cmp ham3 ham5))) - and ham2 = lazy (force (map x2 hamming)) - and ham3 = lazy (force (map x3 hamming)) - and ham5 = lazy (force (map x5 hamming)) -;; - -iter_interval pr hamming (88000, 88100);; \ No newline at end of file diff --git a/benchmarks/mergesort/dune b/benchmarks/mergesort/dune new file mode 100644 index 0000000000..22f3660597 --- /dev/null +++ b/benchmarks/mergesort/dune @@ -0,0 +1,9 @@ +(executable + (name mergesort) + (libraries domainslib)) + +(alias + (name multibench_parallel) + (deps mergesort.exe)) + + diff --git a/benchmarks/mergesort/mergesort.ml b/benchmarks/mergesort/mergesort.ml new file mode 100644 index 0000000000..29101edd84 --- /dev/null +++ b/benchmarks/mergesort/mergesort.ml @@ -0,0 +1,169 @@ +(* similar to Maple's mergesort: https://github.com/MPLLang/mpl/blob/master/examples/lib/Mergesort.sml *) + +open Common +module A = Array +module T = Domainslib.Task +module AS = CCArray_slice + +let goto_seqmerge = 4096 +let goto_quicksort = 8192 + +let rec binary_search' (lo : int) (hi :int) (f : 'a -> 'a -> int) (s : 'a AS.t) (x : 'a) : int = + let n = hi - lo in + if n == 0 + then lo + else let mid = lo + (n / 2) in + let pivot = AS.get s mid in + let cmp = f x pivot in + if cmp < 0 + then binary_search' lo mid f s x + else if cmp > 0 + then binary_search' (mid+1) hi f s x + else mid + +let binary_search (f : 'a -> 'a -> int) (s : 'a AS.t) (x : 'a) : int = + binary_search' 0 (AS.length s) f s x + +let write_loop_seq (idx : int) (offset : int) (end_idx : int) (from : 'a AS.t) (to0 : 'a AS.t) : 'a AS.t = + for i = idx to (end_idx-1) do + AS.set to0 (i+offset) (AS.get from i) + done; + to0 + +let write_loop pool (idx : int) (offset : int) (end_idx : int) (from : 'a AS.t) (to0 : 'a AS.t) :'a AS.t = + T.parallel_for ~start:idx ~finish:(end_idx-1) + ~body:(fun i -> AS.set to0 (i+offset) (AS.get from i)) + pool; + to0 + +(* i1 index into s1 + * i2 index into s2 + * j index into output *) +let rec write_merge_seq_loop (i1 : int) (i2 : int) (j : int) (n1 : int) (n2 : int) (f : 'a -> 'a -> int) (s1 : 'a AS.t) (s2 : 'a AS.t) (t : 'a AS.t) : 'a AS.t = + if i1 == n1 + then let tmp1 = AS.sub s2 i2 (n2-i2) in + let t2 = write_loop_seq 0 j (n2-i2) tmp1 t in + t2 + else if i2 == n2 + then let tmp1 = AS.sub s1 i1 (n1-i1) in + let t1 = write_loop_seq 0 j (n1-i1) tmp1 t in + t1 + else let x1 = AS.get s1 i1 in + let x2 = AS.get s2 i2 in + if (f x1 x2) < 0 + then let _ = AS.set t j x1 in + let res = write_merge_seq_loop (i1+1) i2 (j+1) n1 n2 f s1 s2 t in + res + else let _ = AS.set t j x2 in + let res = write_merge_seq_loop i1 (i2+1) (j+1) n1 n2 f s1 s2 t in + res + +let write_merge_seq (f : 'a -> 'a -> int) (s1 : 'a AS.t) (s2 : 'a AS.t) (t : 'a AS.t) : 'a AS.t = + let n1 = AS.length s1 in + let n2 = AS.length s2 in + let _ = write_merge_seq_loop 0 0 0 n1 n2 f s1 s2 t in + t + +let rec write_merge pool (f : 'a -> 'a -> int) (s1 : 'a AS.t) (s2 : 'a AS.t) (t : 'a AS.t) : 'a AS.t = + if AS.length t < goto_seqmerge + then write_merge_seq f s1 s2 t + else + let n1 = AS.length s1 in + let n2 = AS.length s2 in + if n1 == 0 + then write_loop pool 0 0 n2 s2 t + else let mid1 = n1 / 2 in + let pivot = AS.get s1 mid1 in + let mid2 = binary_search f s2 pivot in + let l1 = AS.sub s1 0 mid1 in + let r1 = AS.sub s1 (mid1+1) (n1 - (mid1+1)) in + let l2 = AS.sub s2 0 mid2 in + let r2 = AS.sub s2 mid2 (n2-mid2) in + let _ = AS.set t (mid1+mid2) pivot in + let len_t = AS.length t in + let tl = AS.sub t 0 (mid1+mid2) in + let tr = AS.sub t (mid1+mid2+1) (len_t - (mid1+mid2+1)) in + let tl1_f = T.async pool (fun _ -> write_merge pool f l1 l2 tl) in + let tr1 = write_merge pool f r1 r2 tr in + let tl1 = T.await pool tl1_f in + t + +let rec write_sort1 pool (f : 'a -> 'a -> int) (s : 'a AS.t) (t : 'a AS.t) : 'a AS.t = + let len = AS.length s in + if len < goto_quicksort + then (Qsort.sortInPlace f s; + s) + else + let half = len / 2 in + let (sl, sr) = (AS.sub s 0 half, AS.sub s half (len-half)) in + let (tl, tr) = (AS.sub t 0 half, AS.sub t half (len-half)) in + let tl1_f = T.async pool (fun _ -> write_sort2 pool f sl tl) in + let tr1 = write_sort2 pool f sr tr in + let tl1 = T.await pool tl1_f in + let res = write_merge pool f tl1 tr1 s in + (* let res = write_merge_seq f tl1 tr1 s in *) + res + +and write_sort1_seq (f : 'a -> 'a -> int) (s : 'a AS.t) (t : 'a AS.t) : 'a AS.t = + let len = AS.length s in + if len < goto_quicksort + then (Qsort.sortInPlace f s; + s) + else + let half = len / 2 in + let (sl, sr) = (AS.sub s 0 half, AS.sub s half (len-half)) in + let (tl, tr) = (AS.sub t 0 half, AS.sub t half (len-half)) in + let tl1 = write_sort2_seq f sl tl in + let tr1 = write_sort2_seq f sr tr in + let res = write_merge_seq f tl1 tr1 s in + res + +and write_sort2 pool (f : 'a -> 'a -> int) (s : 'a AS.t) (t : 'a AS.t) : 'a AS.t = + let len = AS.length s in + if len < goto_quicksort + then + let t1 = write_loop pool 0 0 len s t in + Qsort.sortInPlace f t1; + t1 + else + let half = len / 2 in + let (sl, sr) = (AS.sub s 0 half, AS.sub s half (len-half)) in + let (tl, tr) = (AS.sub t 0 half, AS.sub t half (len-half)) in + let sl1_f = T.async pool (fun _ -> write_sort1 pool f sl tl) in + let sr1 = write_sort1 pool f sr tr in + let sl1 = T.await pool sl1_f in + let res = write_merge pool f sl1 sr1 t in + (* let res = write_merge_seq f sl1 sr1 t in *) + res + +and write_sort2_seq (f : 'a -> 'a -> int) (s : 'a AS.t) (t : 'a AS.t) : 'a AS.t = + let len = AS.length s in + if len < goto_quicksort + then + let t1 = write_loop_seq 0 0 len s t in + (Qsort.sortInPlace f t1; + t1) + else + let half = len / 2 in + let (sl, sr) = (AS.sub s 0 half, AS.sub s half (len-half)) in + let (tl, tr) = (AS.sub t 0 half, AS.sub t half (len-half)) in + let sl1 = write_sort1_seq f sl tl in + let sr1 = write_sort1_seq f sr tr in + let res = write_merge_seq f sl1 sr1 t in + res + +let mergesort pool (f : 'a -> 'a -> int) (vec : 'a array) : 'a array = + let vec2 = A.copy vec in + let s = AS.full vec2 in + let t = AS.full (A.make (A.length vec2) (A.get vec2 0)) in + let s1 = write_sort1 pool f s t in + AS.underlying s1 + +let mergesort_seq (f : 'a -> 'a -> int) (vec : 'a array) : 'a array = + let vec2 = A.copy vec in + let s = AS.full vec2 in + let t = AS.full (A.make (A.length vec2) (A.get vec2 0)) in + (* Qsort.sortInPlace f s; + * AS.underlying s *) + let s1 = write_sort1_seq f s t in + AS.underlying s1 \ No newline at end of file diff --git a/benchmarks/soli/dune b/benchmarks/soli/dune deleted file mode 100644 index 0cee37989a..0000000000 --- a/benchmarks/soli/dune +++ /dev/null @@ -1,7 +0,0 @@ -;; Adapted from OCamlPro's ocamlbench-repo -;; See https://github.com/OCamlPro/ocamlbench-repo -(executable - (name soli) - (modes byte exe)) - - (alias (name buildbench) (deps soli.exe)) \ No newline at end of file diff --git a/benchmarks/soli/soli.ml b/benchmarks/soli/soli.ml deleted file mode 100644 index 0e6f9bf18a..0000000000 --- a/benchmarks/soli/soli.ml +++ /dev/null @@ -1,100 +0,0 @@ -(* TEST - flags += " -unsafe " -*) - -type peg = Out | Empty | Peg - -let board = [| - [| Out; Out; Out; Out; Out; Out; Out; Out; Out|]; - [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; - [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; - [| Out; Peg; Peg; Peg; Peg; Peg; Peg; Peg; Out|]; - [| Out; Peg; Peg; Peg; Empty; Peg; Peg; Peg; Out|]; - [| Out; Peg; Peg; Peg; Peg; Peg; Peg; Peg; Out|]; - [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; - [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out|]; - [| Out; Out; Out; Out; Out; Out; Out; Out; Out|] -|] - - -let print_peg = function - Out -> print_string "." - | Empty -> print_string " " - | Peg -> print_string "$" - - -let print_board board = - for i=0 to 8 do - for j=0 to 8 do - print_peg board.(i).(j) - done; - print_newline() - done - - -type direction = { dx: int; dy: int } - -let dir = [| {dx = 0; dy = 1}; {dx = 1; dy = 0}; - {dx = 0; dy = -1}; {dx = -1; dy = 0} |] - -type move = { x1: int; y1: int; x2: int; y2: int } - -let moves = Array.make 31 {x1=0;y1=0;x2=0;y2=0} - -let counter = ref 0 - -exception Found - -let rec solve m = - counter := !counter + 1; - if m = 31 then - begin match board.(4).(4) with Peg -> true | _ -> false end - else - try - if !counter mod 500 = 0 then begin - print_int !counter; print_newline() - end; - for i=1 to 7 do - for j=1 to 7 do - match board.(i).(j) with - Peg -> - for k=0 to 3 do - let d1 = dir.(k).dx in - let d2 = dir.(k).dy in - let i1 = i+d1 in - let i2 = i1+d1 in - let j1 = j+d2 in - let j2 = j1+d2 in - match board.(i1).(j1) with - Peg -> - begin match board.(i2).(j2) with - Empty -> -(* - print_int i; print_string ", "; - print_int j; print_string ") dir "; - print_int k; print_string "\n"; -*) - board.(i).(j) <- Empty; - board.(i1).(j1) <- Empty; - board.(i2).(j2) <- Peg; - if solve(m+1) then begin - moves.(m) <- { x1=i; y1=j; x2=i2; y2=j2 }; - raise Found - end; - board.(i).(j) <- Peg; - board.(i1).(j1) <- Peg; - board.(i2).(j2) <- Empty - | _ -> () - end - | _ -> () - done - | _ -> - () - done - done; - false - with Found -> - true - - -let _ = if solve 0 then (print_string "\n"; print_board board) \ No newline at end of file diff --git a/multicore_parallel_run_config.json b/multicore_parallel_run_config.json index 9b77953c50..08eb475315 100644 --- a/multicore_parallel_run_config.json +++ b/multicore_parallel_run_config.json @@ -35,7 +35,7 @@ { "executable": "benchmarks/multicore-minilight/parallel/minilight_multicore.exe", "name": "minilight_multicore", - "tags": ["macro_bench", "run_in_ci","gt_100s"], + "tags": ["macro_bench","gt_100s"], "runs": [ { "params": "1 roomfront.ml.txt", @@ -122,7 +122,7 @@ { "executable": "benchmarks/multicore-numerical/mandelbrot6_multicore.exe", "name": "mandelbrot6_multicore", - "tags": ["macro_bench", "run_in_ci","10s_100s"], + "tags": ["macro_bench","10s_100s"], "runs": [ { "params": "1 16_000", "paramwrapper": "taskset --cpu-list 2-13"}, { "params": "2 16_000", "paramwrapper": "taskset --cpu-list 2-13" }, @@ -146,7 +146,7 @@ { "executable": "benchmarks/multicore-numerical/matrix_multiplication_multicore.exe", "name": "matrix_multiplication_multicore", - "tags": ["macro_bench", "run_in_ci","1s_10s"], + "tags": ["macro_bench", "1s_10s"], "runs": [ { "params": "1 1024", "paramwrapper": "taskset --cpu-list 2-13"}, { "params": "2 1024", "paramwrapper": "taskset --cpu-list 2-13" }, @@ -350,7 +350,7 @@ { "executable": "benchmarks/multicore-numerical/evolutionary_algorithm_multicore.exe", "name": "evolutionary_algorithm_multicore", - "tags": ["macro_bench", "run_in_ci","10s_100s"], + "tags": ["macro_bench", "10s_100s"], "runs": [ { "params": "1 10000 10000", "paramwrapper": "taskset --cpu-list 2-13"} ] @@ -358,7 +358,7 @@ { "executable": "benchmarks/multicore-numerical/evolutionary_algorithm_multicore.exe", "name": "evolutionary_algorithm_multicore", - "tags": ["macro_bench", "run_in_ci","gt_100s"], + "tags": ["macro_bench","gt_100s"], "runs": [ { "params": "2 10000 10000", "paramwrapper": "taskset --cpu-list 2-13" }, { "params": "4 10000 10000", "paramwrapper": "taskset --cpu-list 2-13" }, @@ -381,7 +381,7 @@ { "executable": "benchmarks/decompress/test_decompress_multicore.exe", "name": "test_decompress_multicore", - "tags": ["macro_bench", "run_in_ci","1s_10s"], + "tags": ["macro_bench","1s_10s"], "runs": [ { "params": "1 64 1_048_576", "paramwrapper": "taskset --cpu-list 2-13"} ] @@ -701,6 +701,31 @@ } ] }, + { + "executable": "benchmarks/multicore-numerical/mergesort_multicore.exe", + "name": "mergesort_multicore", + "tags": [ + "run_in_ci", + "my_bench" + ], + "runs": [ + { "params": "1024", "paramwrapper": "taskset --cpu-list 2-13" } + ] + }, + { + "executable": "benchmarks/mergesort/mergesort.exe", + "name": "mergesort", + "tags": ["run_in_ci", + "my_bench" + ], + + "runs": [ + + + { "params": "1024", "paramwrapper": "taskset --cpu-list 2-13" } + + ] + }, { "executable": "benchmarks/multicore-structures/test_stack_parallel.exe", "name": "stack_parallel", @@ -712,4 +737,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/run_config.json b/run_config.json index e220c19d46..2544472a4f 100644 --- a/run_config.json +++ b/run_config.json @@ -2,19 +2,19 @@ "wrappers": [ { "name": "orun", - "command": "orun -o %{output} -- taskset --cpu-list 5 %{command}" + "command": "orun -o %{output} -- taskset --cpu-list 1 %{command}" }, { "name": "perfstat", - "command": "perf stat -o %{output} -- taskset --cpu-list 5 %{command}" + "command": "perf stat -o %{output} -- taskset --cpu-list 1 %{command}" }, { "name": "pausetimes_trunk", - "command": "bash pausetimes_trunk %{output} taskset --cpu-list 5 %{command}" + "command": "bash pausetimes_trunk %{output} taskset --cpu-list 1 %{command}" }, { "name": "pausetimes_multicore", - "command": "bash pausetimes_multicore %{output} taskset --cpu-list 5 %{command}" + "command": "bash pausetimes_multicore %{output} taskset --cpu-list 1 %{command}" } ], "benchmarks": [ @@ -91,8 +91,8 @@ "name": "test_decompress", "tags": [ "1s_10s", - "macro_bench", - "run_in_ci" + "macro_bench" + ], "runs": [ { @@ -105,8 +105,8 @@ "name": "yojson_ydump", "tags": [ "lt_1s", - "macro_bench", - "run_in_ci" + "macro_bench" + ], "runs": [ { @@ -146,8 +146,8 @@ "name": "thread_ring_lwt_mvar", "tags": [ "1s_10s", - "macro_bench", - "run_in_ci" + "macro_bench" + ], "runs": [ { @@ -361,8 +361,8 @@ "name": "revcomp2", "tags": [ "1s_10s", - "macro_bench", - "run_in_ci" + "macro_bench" + ], "runs": [ { @@ -493,8 +493,8 @@ "name": "test_lwt", "tags": [ "10s_100s", - "macro_bench", - "run_in_ci" + "macro_bench" + ], "runs": [ { @@ -635,8 +635,8 @@ "name": "zarith_pi", "tags": [ "1s_10s", - "macro_bench", - "run_in_ci" + "macro_bench" + ], "runs": [ { @@ -673,8 +673,8 @@ "name": "menhir", "tags": [ "1s_10s", - "macro_bench", - "run_in_ci" + "macro_bench" + ], "runs": [ { @@ -1518,39 +1518,12 @@ "1s_10s", "macro_bench" ], - "runs": [ - { - "params": "" - } - ] - }, - { - "executable": "benchmarks/soli/soli.exe", - "name": "soli", - "tags": [ - "1s_10s", - "macro_bench" - - ], "runs": [ { "params": "200" } ] - }, - { - "executable": "benchmarks/hamming/hamming.exe", - "name": "hamming", - "tags": [ - "10s_100s", - "macro_bench" - - ], - "runs": [ - { - "params": "200" - } - ] } + ] } From 47eabb7eb9e722d4d35efb1c0089d9c2afa31999 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Thu, 14 Apr 2022 14:56:46 +0100 Subject: [PATCH 14/21] update mergesort dune --- benchmarks/mergesort/dune | 3 +- multicore_parallel_run_config.json | 46 ++++++++++++------------------ 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/benchmarks/mergesort/dune b/benchmarks/mergesort/dune index 22f3660597..0a14f0f73c 100644 --- a/benchmarks/mergesort/dune +++ b/benchmarks/mergesort/dune @@ -1,6 +1,7 @@ (executable (name mergesort) - (libraries domainslib)) + (modules mergesort) + (modes native byte)) (alias (name multibench_parallel) diff --git a/multicore_parallel_run_config.json b/multicore_parallel_run_config.json index 08eb475315..254c439116 100644 --- a/multicore_parallel_run_config.json +++ b/multicore_parallel_run_config.json @@ -35,7 +35,7 @@ { "executable": "benchmarks/multicore-minilight/parallel/minilight_multicore.exe", "name": "minilight_multicore", - "tags": ["macro_bench","gt_100s"], + "tags": ["macro_bench", "run_in_ci","gt_100s"], "runs": [ { "params": "1 roomfront.ml.txt", @@ -122,7 +122,7 @@ { "executable": "benchmarks/multicore-numerical/mandelbrot6_multicore.exe", "name": "mandelbrot6_multicore", - "tags": ["macro_bench","10s_100s"], + "tags": ["macro_bench", "run_in_ci","10s_100s"], "runs": [ { "params": "1 16_000", "paramwrapper": "taskset --cpu-list 2-13"}, { "params": "2 16_000", "paramwrapper": "taskset --cpu-list 2-13" }, @@ -146,7 +146,7 @@ { "executable": "benchmarks/multicore-numerical/matrix_multiplication_multicore.exe", "name": "matrix_multiplication_multicore", - "tags": ["macro_bench", "1s_10s"], + "tags": ["macro_bench", "run_in_ci","1s_10s"], "runs": [ { "params": "1 1024", "paramwrapper": "taskset --cpu-list 2-13"}, { "params": "2 1024", "paramwrapper": "taskset --cpu-list 2-13" }, @@ -350,7 +350,7 @@ { "executable": "benchmarks/multicore-numerical/evolutionary_algorithm_multicore.exe", "name": "evolutionary_algorithm_multicore", - "tags": ["macro_bench", "10s_100s"], + "tags": ["macro_bench", "run_in_ci","10s_100s"], "runs": [ { "params": "1 10000 10000", "paramwrapper": "taskset --cpu-list 2-13"} ] @@ -358,7 +358,7 @@ { "executable": "benchmarks/multicore-numerical/evolutionary_algorithm_multicore.exe", "name": "evolutionary_algorithm_multicore", - "tags": ["macro_bench","gt_100s"], + "tags": ["macro_bench", "run_in_ci","gt_100s"], "runs": [ { "params": "2 10000 10000", "paramwrapper": "taskset --cpu-list 2-13" }, { "params": "4 10000 10000", "paramwrapper": "taskset --cpu-list 2-13" }, @@ -381,7 +381,7 @@ { "executable": "benchmarks/decompress/test_decompress_multicore.exe", "name": "test_decompress_multicore", - "tags": ["macro_bench","1s_10s"], + "tags": ["macro_bench", "run_in_ci","1s_10s"], "runs": [ { "params": "1 64 1_048_576", "paramwrapper": "taskset --cpu-list 2-13"} ] @@ -701,13 +701,20 @@ } ] }, + { + "executable": "benchmarks/multicore-structures/test_stack_parallel.exe", + "name": "stack_parallel", + "tags": [], + "runs": [ + { + "params": "100000" + } + ] + }, { "executable": "benchmarks/multicore-numerical/mergesort_multicore.exe", "name": "mergesort_multicore", - "tags": [ - "run_in_ci", - "my_bench" - ], + "tags": ["run_in_ci", "macro_bench", "my_bench" ], "runs": [ { "params": "1024", "paramwrapper": "taskset --cpu-list 2-13" } ] @@ -715,26 +722,11 @@ { "executable": "benchmarks/mergesort/mergesort.exe", "name": "mergesort", - "tags": ["run_in_ci", - "my_bench" - ], + "tags": ["1s_10s", "macro_bench", "my_bench"], "runs": [ - - - { "params": "1024", "paramwrapper": "taskset --cpu-list 2-13" } - + { "params": "16", "paramwrapper": "taskset --cpu-list 2-13" } ] - }, - { - "executable": "benchmarks/multicore-structures/test_stack_parallel.exe", - "name": "stack_parallel", - "tags": [], - "runs": [ - { - "params": "100000" - } - ] } ] } \ No newline at end of file From f5371f4e82433200f9b701456302e5df01af163b Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 18 Apr 2022 14:42:18 +0100 Subject: [PATCH 15/21] Create common.ml --- benchmarks/mergesort/common.ml | 131 +++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 benchmarks/mergesort/common.ml diff --git a/benchmarks/mergesort/common.ml b/benchmarks/mergesort/common.ml new file mode 100644 index 0000000000..f3cc7f9635 --- /dev/null +++ b/benchmarks/mergesort/common.ml @@ -0,0 +1,131 @@ +module T = Domainslib.Task +module A = Array +module AS = CCArray_slice + +type point3d = float * float * float + +let print_point3d (x,y,z) = + print_string ("(" ^ Float.to_string x ^ ", " ^ Float.to_string y ^ ", " ^ Float.to_string z ^ ")") + +let compare_point3d (axis : int) ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : int = + if axis == 0 + then Float.compare x1 x2 + else if axis == 1 + then Float.compare y1 y2 + else Float.compare z1 z2 + +let dist_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : float = + let (d1, d2, d3) = (x1 -. x2, y1 -. y2, z1 -. z2) in + (d1 *. d1) +. (d2 *. d2) +. (d3 *. d3) + +let min_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : point3d = + ((Float.min x1 x2), (Float.min y1 y2), (Float.min z1 z2)) + +let max_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : point3d = + ((Float.max x1 x2), (Float.max y1 y2), (Float.max z1 z2)) + +let coord (i : int) ((x,y,z) : point3d) = + match i with + 0 -> x + | 1 -> y + | 2 -> z + | _ -> z + +type point2d = float * float + +let compare_point2d (axis : int) ((x1,y1) : point2d) ((x2,y2) : point2d) : int = + if axis == 0 + then Float.compare x1 x2 + else Float.compare y2 y2 + +let dist_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : float = + let (d1, d2) = (x1 -. x2, y1 -. y2) in + (d1 *. d1) +. (d2 *. d2) + +let min_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : point2d = + ((Float.min x1 x2), (Float.min y1 y2)) + +let max_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : point2d = + ((Float.max x1 x2), (Float.max y1 y2)) + + +(* https://stackoverflow.com/questions/5774934 *) +let read_file (filename : string) : string list = + let lines = ref [] in + let chan = open_in filename in + try + while true; do + lines := input_line chan :: !lines + done; !lines + with End_of_file -> + close_in chan; + List.rev !lines ;; + +(* A.init n (fun i -> let line = List.nth lines i in + * if (String.length line) == 0 + * then (0.01, 0.01, 0.01) + * else + * let words = String.split_on_char ' ' line in + * let a = Float.of_string (List.nth words 0) in + * let b = Float.of_string (List.nth words 1) in + * let c = Float.of_string (List.nth words 2) in + * (a, b, c)) + *) + +let read3DArrayFile (fp : string) : point3d array = + let lines = read_file fp in + let n = List.length lines in + let _ = print_endline ("length: " ^ string_of_int n ^ "\n") in + let pool = T.setup_pool ~num_domains:48 in + let result = A.make n (0.01, 0.01, 0.01) in + let _ = T.parallel_for ~start:0 ~finish:(n-1) + ~body:(fun i -> let line = List.nth lines i in + if (String.length line) == 0 + then () + else + let words = String.split_on_char ' ' line in + let a = Float.of_string (List.nth words 0) in + let b = Float.of_string (List.nth words 1) in + let c = Float.of_string (List.nth words 2) in + A.set result i (a, b, c); + ()) + pool in + let _ = T.teardown_pool pool in + result + + +let read2DArrayFile (fp : string) : point2d array = + let lines = read_file fp in + let n = List.length lines in + let pool = T.setup_pool ~num_domains:48 in + let result = A.make n (0.01, 0.01) in + let _ = T.parallel_for ~start:0 ~finish:(n-1) + ~body:(fun i -> let line = List.nth lines i in + if (String.length line) == 0 + then () + else + let words = String.split_on_char ' ' line in + let a = Float.of_string (List.nth words 0) in + let b = Float.of_string (List.nth words 1) in + A.set result i (a, b); + ()) + pool in + let _ = T.teardown_pool pool in + result + +let get_rand (n : int) : int = + let t = Unix.gettimeofday () in + let i = Float.round t in + (Float.hash i) mod n + +let filter_array (f : ('a -> bool)) (arr : 'a array) : 'a array = + let module A = Array in + A.of_list (List.filter f (A.to_list arr)) + +let print_array f arr = + let _ = A.iter (fun x -> print_string (f x ^ " ")) arr in + print_endline "\n" + +let print_slice f arr = + let _ = AS.iter (fun x -> print_string (f x ^ " ")) arr in + print_endline "\n" From d6a43430932dbcf222ada04ff47d361e7c9b0efa Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 18 Apr 2022 14:47:49 +0100 Subject: [PATCH 16/21] Delete common.ml --- benchmarks/mergesort/common.ml | 131 --------------------------------- 1 file changed, 131 deletions(-) delete mode 100644 benchmarks/mergesort/common.ml diff --git a/benchmarks/mergesort/common.ml b/benchmarks/mergesort/common.ml deleted file mode 100644 index f3cc7f9635..0000000000 --- a/benchmarks/mergesort/common.ml +++ /dev/null @@ -1,131 +0,0 @@ -module T = Domainslib.Task -module A = Array -module AS = CCArray_slice - -type point3d = float * float * float - -let print_point3d (x,y,z) = - print_string ("(" ^ Float.to_string x ^ ", " ^ Float.to_string y ^ ", " ^ Float.to_string z ^ ")") - -let compare_point3d (axis : int) ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : int = - if axis == 0 - then Float.compare x1 x2 - else if axis == 1 - then Float.compare y1 y2 - else Float.compare z1 z2 - -let dist_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : float = - let (d1, d2, d3) = (x1 -. x2, y1 -. y2, z1 -. z2) in - (d1 *. d1) +. (d2 *. d2) +. (d3 *. d3) - -let min_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : point3d = - ((Float.min x1 x2), (Float.min y1 y2), (Float.min z1 z2)) - -let max_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : point3d = - ((Float.max x1 x2), (Float.max y1 y2), (Float.max z1 z2)) - -let coord (i : int) ((x,y,z) : point3d) = - match i with - 0 -> x - | 1 -> y - | 2 -> z - | _ -> z - -type point2d = float * float - -let compare_point2d (axis : int) ((x1,y1) : point2d) ((x2,y2) : point2d) : int = - if axis == 0 - then Float.compare x1 x2 - else Float.compare y2 y2 - -let dist_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : float = - let (d1, d2) = (x1 -. x2, y1 -. y2) in - (d1 *. d1) +. (d2 *. d2) - -let min_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : point2d = - ((Float.min x1 x2), (Float.min y1 y2)) - -let max_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : point2d = - ((Float.max x1 x2), (Float.max y1 y2)) - - -(* https://stackoverflow.com/questions/5774934 *) -let read_file (filename : string) : string list = - let lines = ref [] in - let chan = open_in filename in - try - while true; do - lines := input_line chan :: !lines - done; !lines - with End_of_file -> - close_in chan; - List.rev !lines ;; - -(* A.init n (fun i -> let line = List.nth lines i in - * if (String.length line) == 0 - * then (0.01, 0.01, 0.01) - * else - * let words = String.split_on_char ' ' line in - * let a = Float.of_string (List.nth words 0) in - * let b = Float.of_string (List.nth words 1) in - * let c = Float.of_string (List.nth words 2) in - * (a, b, c)) - *) - -let read3DArrayFile (fp : string) : point3d array = - let lines = read_file fp in - let n = List.length lines in - let _ = print_endline ("length: " ^ string_of_int n ^ "\n") in - let pool = T.setup_pool ~num_domains:48 in - let result = A.make n (0.01, 0.01, 0.01) in - let _ = T.parallel_for ~start:0 ~finish:(n-1) - ~body:(fun i -> let line = List.nth lines i in - if (String.length line) == 0 - then () - else - let words = String.split_on_char ' ' line in - let a = Float.of_string (List.nth words 0) in - let b = Float.of_string (List.nth words 1) in - let c = Float.of_string (List.nth words 2) in - A.set result i (a, b, c); - ()) - pool in - let _ = T.teardown_pool pool in - result - - -let read2DArrayFile (fp : string) : point2d array = - let lines = read_file fp in - let n = List.length lines in - let pool = T.setup_pool ~num_domains:48 in - let result = A.make n (0.01, 0.01) in - let _ = T.parallel_for ~start:0 ~finish:(n-1) - ~body:(fun i -> let line = List.nth lines i in - if (String.length line) == 0 - then () - else - let words = String.split_on_char ' ' line in - let a = Float.of_string (List.nth words 0) in - let b = Float.of_string (List.nth words 1) in - A.set result i (a, b); - ()) - pool in - let _ = T.teardown_pool pool in - result - -let get_rand (n : int) : int = - let t = Unix.gettimeofday () in - let i = Float.round t in - (Float.hash i) mod n - -let filter_array (f : ('a -> bool)) (arr : 'a array) : 'a array = - let module A = Array in - A.of_list (List.filter f (A.to_list arr)) - -let print_array f arr = - let _ = A.iter (fun x -> print_string (f x ^ " ")) arr in - print_endline "\n" - -let print_slice f arr = - let _ = AS.iter (fun x -> print_string (f x ^ " ")) arr in - print_endline "\n" From 2865c3d2d59e6226065d73de604652c7fb606d54 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 18 Apr 2022 14:53:15 +0100 Subject: [PATCH 17/21] Create common.ml --- benchmarks/mergesort/common.ml | 131 +++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 benchmarks/mergesort/common.ml diff --git a/benchmarks/mergesort/common.ml b/benchmarks/mergesort/common.ml new file mode 100644 index 0000000000..0a367455ce --- /dev/null +++ b/benchmarks/mergesort/common.ml @@ -0,0 +1,131 @@ + module T = Domainslib.Task +module A = Array +module AS = CCArray_slice + +type point3d = float * float * float + +let print_point3d (x,y,z) = + print_string ("(" ^ Float.to_string x ^ ", " ^ Float.to_string y ^ ", " ^ Float.to_string z ^ ")") + +let compare_point3d (axis : int) ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : int = + if axis == 0 + then Float.compare x1 x2 + else if axis == 1 + then Float.compare y1 y2 + else Float.compare z1 z2 + +let dist_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : float = + let (d1, d2, d3) = (x1 -. x2, y1 -. y2, z1 -. z2) in + (d1 *. d1) +. (d2 *. d2) +. (d3 *. d3) + +let min_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : point3d = + ((Float.min x1 x2), (Float.min y1 y2), (Float.min z1 z2)) + +let max_point3d ((x1,y1,z1) : point3d) ((x2,y2,z2) : point3d) : point3d = + ((Float.max x1 x2), (Float.max y1 y2), (Float.max z1 z2)) + +let coord (i : int) ((x,y,z) : point3d) = + match i with + 0 -> x + | 1 -> y + | 2 -> z + | _ -> z + +type point2d = float * float + +let compare_point2d (axis : int) ((x1,y1) : point2d) ((x2,y2) : point2d) : int = + if axis == 0 + then Float.compare x1 x2 + else Float.compare y2 y2 + +let dist_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : float = + let (d1, d2) = (x1 -. x2, y1 -. y2) in + (d1 *. d1) +. (d2 *. d2) + +let min_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : point2d = + ((Float.min x1 x2), (Float.min y1 y2)) + +let max_point2d ((x1,y1) : point2d) ((x2,y2) : point2d) : point2d = + ((Float.max x1 x2), (Float.max y1 y2)) + + +(* https://stackoverflow.com/questions/5774934 *) +let read_file (filename : string) : string list = + let lines = ref [] in + let chan = open_in filename in + try + while true; do + lines := input_line chan :: !lines + done; !lines + with End_of_file -> + close_in chan; + List.rev !lines ;; + +(* A.init n (fun i -> let line = List.nth lines i in + * if (String.length line) == 0 + * then (0.01, 0.01, 0.01) + * else + * let words = String.split_on_char ' ' line in + * let a = Float.of_string (List.nth words 0) in + * let b = Float.of_string (List.nth words 1) in + * let c = Float.of_string (List.nth words 2) in + * (a, b, c)) + *) + +let read3DArrayFile (fp : string) : point3d array = + let lines = read_file fp in + let n = List.length lines in + let _ = print_endline ("length: " ^ string_of_int n ^ "\n") in + let pool = T.setup_pool ~num_domains:48 in + let result = A.make n (0.01, 0.01, 0.01) in + let _ = T.parallel_for ~start:0 ~finish:(n-1) + ~body:(fun i -> let line = List.nth lines i in + if (String.length line) == 0 + then () + else + let words = String.split_on_char ' ' line in + let a = Float.of_string (List.nth words 0) in + let b = Float.of_string (List.nth words 1) in + let c = Float.of_string (List.nth words 2) in + A.set result i (a, b, c); + ()) + pool in + let _ = T.teardown_pool pool in + result + + +let read2DArrayFile (fp : string) : point2d array = + let lines = read_file fp in + let n = List.length lines in + let pool = T.setup_pool ~num_domains:48 in + let result = A.make n (0.01, 0.01) in + let _ = T.parallel_for ~start:0 ~finish:(n-1) + ~body:(fun i -> let line = List.nth lines i in + if (String.length line) == 0 + then () + else + let words = String.split_on_char ' ' line in + let a = Float.of_string (List.nth words 0) in + let b = Float.of_string (List.nth words 1) in + A.set result i (a, b); + ()) + pool in + let _ = T.teardown_pool pool in + result + +let get_rand (n : int) : int = + let t = Unix.gettimeofday () in + let i = Float.round t in + (Float.hash i) mod n + +let filter_array (f : ('a -> bool)) (arr : 'a array) : 'a array = + let module A = Array in + A.of_list (List.filter f (A.to_list arr)) + +let print_array f arr = + let _ = A.iter (fun x -> print_string (f x ^ " ")) arr in + print_endline "\n" + +let print_slice f arr = + let _ = AS.iter (fun x -> print_string (f x ^ " ")) arr in + print_endline "\n" From 60a2bcdb0699c017466cb85e9d5dc9c7e54bc6cb Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 18 Apr 2022 15:39:31 +0100 Subject: [PATCH 18/21] Update dune --- benchmarks/mergesort/dune | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/benchmarks/mergesort/dune b/benchmarks/mergesort/dune index 0a14f0f73c..bf56a765a8 100644 --- a/benchmarks/mergesort/dune +++ b/benchmarks/mergesort/dune @@ -2,9 +2,14 @@ (name mergesort) (modules mergesort) (modes native byte)) +(executable + (name common) + (modes native byte) + (modules common)) +(alias + (name buildbench) + (deps common.exe)) (alias (name multibench_parallel) (deps mergesort.exe)) - - From 5c48579b2f17f727381f194eb993cd2afa07e03b Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 18 Apr 2022 15:46:15 +0100 Subject: [PATCH 19/21] Update dune --- benchmarks/mergesort/dune | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/mergesort/dune b/benchmarks/mergesort/dune index bf56a765a8..552f76b515 100644 --- a/benchmarks/mergesort/dune +++ b/benchmarks/mergesort/dune @@ -4,7 +4,7 @@ (modes native byte)) (executable (name common) - (modes native byte) + (modes native) (modules common)) (alias From a8e4e8adcabff25683a1017b9fcb357d94d85629 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Mon, 18 Apr 2022 16:13:53 +0100 Subject: [PATCH 20/21] Update dune --- benchmarks/mergesort/dune | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/benchmarks/mergesort/dune b/benchmarks/mergesort/dune index 552f76b515..83d15b6ad7 100644 --- a/benchmarks/mergesort/dune +++ b/benchmarks/mergesort/dune @@ -1,7 +1,6 @@ (executable (name mergesort) - (modules mergesort) - (modes native byte)) + (modules mergesort)) (executable (name common) (modes native) From a71ad9f0bfbe1aaf2cfd00e923de90f1b3f10823 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Tue, 19 Apr 2022 11:57:14 +0100 Subject: [PATCH 21/21] Update dune --- benchmarks/mergesort/dune | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/benchmarks/mergesort/dune b/benchmarks/mergesort/dune index 83d15b6ad7..7e286a5f91 100644 --- a/benchmarks/mergesort/dune +++ b/benchmarks/mergesort/dune @@ -1,14 +1,15 @@ (executable (name mergesort) - (modules mergesort)) -(executable + (modules mergesort) + (modes native) + (libraries domainslib containers)) + + (executable (name common) + (modules common) (modes native) - (modules common)) + (libraries domainslib containers)) -(alias - (name buildbench) - (deps common.exe)) (alias (name multibench_parallel) - (deps mergesort.exe)) + (deps mergesort.exe common.exe))