From 7af4113cd42f8ceca1c7f4a9f34f345d1c16f0d3 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Tue, 26 Apr 2022 14:05:04 +0100 Subject: [PATCH 1/3] added containers to packages --- Makefile | 2 +- benchmarks/quick-sort/dune | 7 +++ benchmarks/quick-sort/qsort.ml | 48 +++++++++++++++++++ .../packages/containers/containers.2.8.1/opam | 40 ++++++++++++++++ multicore_parallel_run_config.json | 10 ++++ run_all_parallel.sh | 1 + 6 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 benchmarks/quick-sort/dune create mode 100644 benchmarks/quick-sort/qsort.ml create mode 100644 dependencies/packages/containers/containers.2.8.1/opam diff --git a/Makefile b/Makefile index 5e348cb397..8a345872d5 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ START_TIME ?= WRAPPER = $(patsubst run_%,%,$(RUN_BENCH_TARGET)) -PACKAGES = sexplib0 re yojson react uuidm cpdf nbcodec minilight cubicle orun rungen +PACKAGES = sexplib0 re yojson react uuidm cpdf nbcodec minilight cubicle orun rungen containers ifeq ($(findstring multibench,$(BUILD_BENCH_TARGET)),multibench) PACKAGES += lockfree kcas domainslib ctypes diff --git a/benchmarks/quick-sort/dune b/benchmarks/quick-sort/dune new file mode 100644 index 0000000000..6c7879d161 --- /dev/null +++ b/benchmarks/quick-sort/dune @@ -0,0 +1,7 @@ +(executable + (name qsort) + (modules qsort) + (libraries containers)) +(alias (name multibench_parallel) + (deps qsort.exe)) + \ No newline at end of file diff --git a/benchmarks/quick-sort/qsort.ml b/benchmarks/quick-sort/qsort.ml new file mode 100644 index 0000000000..8fac1f4f44 --- /dev/null +++ b/benchmarks/quick-sort/qsort.ml @@ -0,0 +1,48 @@ +module AS = CCArray_slice +module A = Array + +let swap (arr : 'a AS.t) (i : int) (j : int) = + let temp = AS.get arr i in + AS.set arr i (AS.get arr j); + AS.set arr j temp + +let insert_sort (f : 'a -> 'a -> int) (arr : 'a AS.t) (start : int) (n : int) = + for i = start to n - 2 do + for j = i + 1 to n - 1 do + if f (AS.get arr j) (AS.get arr i) < 0 + then swap arr i j + else () + done + done + +let partition (f : 'a -> 'a -> int) (arr : 'a AS.t) (low : int) (high : int) = + let x = (AS.get arr high) and i = ref (low-1) in + if (high-low > 0) then + begin + for j= low to high - 1 do + if f (AS.get arr j) x <= 0 then + begin + i := !i+1; + swap arr !i j + end + done + end; + swap arr (!i+1) high; + !i+1 + +let rec quicksort (f : 'a -> 'a -> int) (arr : 'a AS.t) (low : int) (high : int) : unit = + if (high - low) <= 0 then () + (* else if (high - low) <= 8 + * then insert_sort f arr low (high+1) *) + else + let q = partition f arr low high in + quicksort f arr low (q-1); + quicksort f arr (q+1) high + +let sortInPlace (f : 'a -> 'a -> int) (arr : 'a AS.t) : unit = + quicksort f arr 0 (AS.length arr - 1) + +let sort (f : 'a -> 'a -> int) (arr : 'a array) : 'a array = + let result = A.copy arr in + quicksort f (AS.full result) 0 (A.length arr - 1) ; + result \ No newline at end of file diff --git a/dependencies/packages/containers/containers.2.8.1/opam b/dependencies/packages/containers/containers.2.8.1/opam new file mode 100644 index 0000000000..632b8480f8 --- /dev/null +++ b/dependencies/packages/containers/containers.2.8.1/opam @@ -0,0 +1,40 @@ +opam-version: "2.0" +maintainer: "simon.cruanes.2007@m4x.org" +synopsis: "A modular, clean and powerful extension of the OCaml standard library" +build: [ + ["dune" "build" "-p" name "-j" jobs] + ["dune" "build" "@doc" "-p" name ] {with-doc} + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +depends: [ + "ocaml" { >= "4.03.0" } + "ocaml" { with-test & < "4.11" } + "dune" { >= "1.1" } + "dune-configurator" + "seq" + "qtest" { with-test } + "qcheck" { with-test & < "0.14" } + "ounit" { with-test } + "iter" { with-test } + "gen" { with-test } + "uutf" { with-test } + "mdx" { with-test & >= "1.5.0" & < "2.0.0" } + "odoc" { with-doc } +] +depopts: [ + "base-unix" + "base-threads" +] +tags: [ "stdlib" "containers" "iterators" "list" "heap" "queue" ] +homepage: "https://github.com/c-cube/ocaml-containers/" +doc: "https://c-cube.github.io/ocaml-containers" +dev-repo: "git+https://github.com/c-cube/ocaml-containers.git" +bug-reports: "https://github.com/c-cube/ocaml-containers/issues/" +authors: "Simon Cruanes" +url { + src: "https://github.com/c-cube/ocaml-containers/archive/v2.8.1.tar.gz" + checksum: [ + "md5=d84e09c5d0abc501aa17cd502e31a038" + "sha512=8b832f4ada6035e80d81be0cfb7bdffb695ec67d465ed6097a144019e2b8a8f909095e78019c3da2d8181cc3cd730cd48f7519e87d3162442562103b7f36aabb" + ] +} \ No newline at end of file diff --git a/multicore_parallel_run_config.json b/multicore_parallel_run_config.json index ce5f69bc59..58a33ddd4e 100644 --- a/multicore_parallel_run_config.json +++ b/multicore_parallel_run_config.json @@ -734,6 +734,16 @@ "params": "100000" } ] + }, + { + "executable": "benchmarks/quick-sort/qsort.exe", + "name": "qsort", + "tags": ["my_bench"], + "runs": [ + { + "params": "" + } + ] } ] } diff --git a/run_all_parallel.sh b/run_all_parallel.sh index d8d558b21e..5047fcae15 100644 --- a/run_all_parallel.sh +++ b/run_all_parallel.sh @@ -7,6 +7,7 @@ # TAG='"macro_bench"' make multicore_parallel_run_config_filtered.json +#TAG='"my_bench"' make multicore_parallel_run_config_filtered.json USE_SYS_DUNE_HACK=1 \ RUN_BENCH_TARGET=run_orunchrt \ From 2cc8f6214b6eaedc8e25000664c559f1804c30e4 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 27 Apr 2022 09:20:03 +0100 Subject: [PATCH 2/3] added qsort to sandmark --- benchmarks/quick-sort/qsort.ml | 4 +- .../packages/containers/containers.3.7/opam | 41 +++++++++++++++++++ multicore_parallel_run_config.json | 2 +- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 dependencies/packages/containers/containers.3.7/opam diff --git a/benchmarks/quick-sort/qsort.ml b/benchmarks/quick-sort/qsort.ml index 8fac1f4f44..aa34125d38 100644 --- a/benchmarks/quick-sort/qsort.ml +++ b/benchmarks/quick-sort/qsort.ml @@ -1,4 +1,4 @@ -module AS = CCArray_slice +module AS = CCArray module A = Array let swap (arr : 'a AS.t) (i : int) (j : int) = @@ -44,5 +44,5 @@ let sortInPlace (f : 'a -> 'a -> int) (arr : 'a AS.t) : unit = let sort (f : 'a -> 'a -> int) (arr : 'a array) : 'a array = let result = A.copy arr in - quicksort f (AS.full result) 0 (A.length arr - 1) ; + quicksort f (A.fill result) 0 (A.length arr - 1) ; result \ No newline at end of file diff --git a/dependencies/packages/containers/containers.3.7/opam b/dependencies/packages/containers/containers.3.7/opam new file mode 100644 index 0000000000..9700c066c0 --- /dev/null +++ b/dependencies/packages/containers/containers.3.7/opam @@ -0,0 +1,41 @@ +opam-version: "2.0" +maintainer: "simon.cruanes.2007@m4x.org" +license: "BSD-2-Clause" +synopsis: "A modular, clean and powerful extension of the OCaml standard library" +build: [ + ["dune" "build" "-p" name "-j" jobs] + ["dune" "build" "@doc" "-p" name ] {with-doc} + ["dune" "runtest" "-p" name "-j" jobs] {with-test & arch != "x86_32" & arch != "arm32"} +] +depends: [ + "ocaml" { >= "4.03.0" } + "dune" { >= "2.0" } + "dune-configurator" + "seq" # compat + "either" # compat + "qtest" { with-test } + "qcheck" { with-test } + "ounit" { with-test } + "iter" { with-test } + "gen" { with-test } + "csexp" { with-test } + "uutf" { with-test } + "odoc" { with-doc } +] +depopts: [ + "base-unix" + "base-threads" +] +tags: [ "stdlib" "containers" "iterators" "list" "heap" "queue" ] +homepage: "https://github.com/c-cube/ocaml-containers/" +doc: "https://c-cube.github.io/ocaml-containers" +dev-repo: "git+https://github.com/c-cube/ocaml-containers.git" +bug-reports: "https://github.com/c-cube/ocaml-containers/issues/" +authors: "Simon Cruanes" +url { + src: "https://github.com/c-cube/ocaml-containers/archive/v3.7.tar.gz" + checksum: [ + "md5=58298b6d26c5198157e19b583e9eca2c" + "sha512=70f99a062f7696d4ed7a6336532261c93c49a9858a84a12f7f3d60190a5c664198e70be6281dc7c7932c07325dc9c579ff521367e4c7e083566910ba0f9ea760" + ] +} \ No newline at end of file diff --git a/multicore_parallel_run_config.json b/multicore_parallel_run_config.json index 58a33ddd4e..c999890aaa 100644 --- a/multicore_parallel_run_config.json +++ b/multicore_parallel_run_config.json @@ -741,7 +741,7 @@ "tags": ["my_bench"], "runs": [ { - "params": "" + "params": "", "paramwrapper": "taskset --cpu-list 1" } ] } From 75724fafecfbc925488619503889c9f2aac3aa24 Mon Sep 17 00:00:00 2001 From: Musong Ernest Akeh Date: Wed, 27 Apr 2022 09:46:15 +0100 Subject: [PATCH 3/3] removed containers.2.8.1 --- .../packages/containers/containers.2.8.1/opam | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 dependencies/packages/containers/containers.2.8.1/opam diff --git a/dependencies/packages/containers/containers.2.8.1/opam b/dependencies/packages/containers/containers.2.8.1/opam deleted file mode 100644 index 632b8480f8..0000000000 --- a/dependencies/packages/containers/containers.2.8.1/opam +++ /dev/null @@ -1,40 +0,0 @@ -opam-version: "2.0" -maintainer: "simon.cruanes.2007@m4x.org" -synopsis: "A modular, clean and powerful extension of the OCaml standard library" -build: [ - ["dune" "build" "-p" name "-j" jobs] - ["dune" "build" "@doc" "-p" name ] {with-doc} - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] -depends: [ - "ocaml" { >= "4.03.0" } - "ocaml" { with-test & < "4.11" } - "dune" { >= "1.1" } - "dune-configurator" - "seq" - "qtest" { with-test } - "qcheck" { with-test & < "0.14" } - "ounit" { with-test } - "iter" { with-test } - "gen" { with-test } - "uutf" { with-test } - "mdx" { with-test & >= "1.5.0" & < "2.0.0" } - "odoc" { with-doc } -] -depopts: [ - "base-unix" - "base-threads" -] -tags: [ "stdlib" "containers" "iterators" "list" "heap" "queue" ] -homepage: "https://github.com/c-cube/ocaml-containers/" -doc: "https://c-cube.github.io/ocaml-containers" -dev-repo: "git+https://github.com/c-cube/ocaml-containers.git" -bug-reports: "https://github.com/c-cube/ocaml-containers/issues/" -authors: "Simon Cruanes" -url { - src: "https://github.com/c-cube/ocaml-containers/archive/v2.8.1.tar.gz" - checksum: [ - "md5=d84e09c5d0abc501aa17cd502e31a038" - "sha512=8b832f4ada6035e80d81be0cfb7bdffb695ec67d465ed6097a144019e2b8a8f909095e78019c3da2d8181cc3cd730cd48f7519e87d3162442562103b7f36aabb" - ] -} \ No newline at end of file