Skip to content

Commit

Permalink
Merge pull request #81 from ocaml-multicore/generate-opam
Browse files Browse the repository at this point in the history
Generate opam files automatically
  • Loading branch information
lyrm authored Oct 16, 2023
2 parents ed73c87 + b2301e6 commit 49e4e59
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
profile = default
version = 0.25.1
version = 0.26.0
29 changes: 26 additions & 3 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
(lang dune 3.0)
(lang dune 3.2)
(name saturn)
(generate_opam_files true)
(source (github ocaml-multicore/saturn))
(license ISC)
(authors "KC Sivaramakrishnan")
(maintainers "Carine Morel" "KC Sivaramakrishnan" "Sudha Parimala")
(documentation "https://ocaml-multicore.github.io/saturn/")
(package
(name saturn)
(synopsis "Collection of parallelism-safe data structures for Multicore OCaml"))
(synopsis "Collection of parallelism-safe data structures for Multicore OCaml")
(depends
(ocaml (>= 4.12))
(domain_shims (>= 0.1.0))
(saturn_lockfree (= :version))
(qcheck (and (>= 0.18.1) :with-test))
(qcheck-stm (and (>= 0.2) :with-test))
(qcheck-alcotest (and (>= 0.18.1) :with-test))
(yojson (and (>= 2.0.2) :with-test))
(dscheck (and (>= 0.1.0) :with-test))))
(package
(name saturn_lockfree)
(synopsis "Collection of lock-free data structures for Multicore OCaml"))
(synopsis "Collection of lock-free data structures for Multicore OCaml")
(depends
(ocaml (>= 4.12))
(domain_shims (>= 0.1.0))
(qcheck (and (>= 0.18.1) :with-test))
(qcheck-stm (and (>= 0.2) :with-test))
(qcheck-alcotest (and (>= 0.18.1) :with-test))
(yojson (and (>= 2.0.2) :with-test))
(dscheck (and (>= 0.1.0) :with-test))))
47 changes: 30 additions & 17 deletions saturn.opam
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
maintainer:"KC Sivaramakrishnan <[email protected]>"
authors: ["KC Sivaramakrishnan <[email protected]>"]
homepage: "https://github.com/ocaml-multicore/saturn"
doc: "https://ocaml-multicore.github.io/saturn"
synopsis: "Parallelism-safe data structures for multicore OCaml"
synopsis:
"Collection of parallelism-safe data structures for Multicore OCaml"
maintainer: ["Carine Morel" "KC Sivaramakrishnan" "Sudha Parimala"]
authors: ["KC Sivaramakrishnan"]
license: "ISC"
dev-repo: "git+https://github.com/ocaml-multicore/saturn.git"
homepage: "https://github.com/ocaml-multicore/saturn"
doc: "https://ocaml-multicore.github.io/saturn/"
bug-reports: "https://github.com/ocaml-multicore/saturn/issues"
tags: []
depends: [
"dune" {>= "3.2"}
"ocaml" {>= "4.12"}
"dune" {>= "3.0"}
"domain_shims" {>= "0.1.0"}
"qcheck" {with-test & >= "0.18.1"}
"qcheck-stm" {with-test & >= "0.2"}
"qcheck-alcotest" {with-test & >= "0.18.1"}
"alcotest" {with-test & >= "1.6.0"}
"yojson" {with-test &>= "2.0.2"}
"dscheck" {with-test & >= "0.1.0"}
"saturn_lockfree" {= version}
"qcheck" {>= "0.18.1" & with-test}
"qcheck-stm" {>= "0.2" & with-test}
"qcheck-alcotest" {>= "0.18.1" & with-test}
"yojson" {>= "2.0.2" & with-test}
"dscheck" {>= "0.1.0" & with-test}
"odoc" {with-doc}
]
available: arch != "x86_32" & arch != "arm32" & arch != "ppc64"
depopts: []
build: ["dune" "build" "-p" name "-j" jobs]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/ocaml-multicore/saturn.git"
45 changes: 28 additions & 17 deletions saturn_lockfree.opam
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
maintainer:"KC Sivaramakrishnan <[email protected]>"
authors: ["KC Sivaramakrishnan <[email protected]>"]
homepage: "https://github.com/ocaml-multicore/saturn"
doc: "https://ocaml-multicore.github.io/saturn"
synopsis: "Lock-free data structures for multicore OCaml"
synopsis: "Collection of lock-free data structures for Multicore OCaml"
maintainer: ["Carine Morel" "KC Sivaramakrishnan" "Sudha Parimala"]
authors: ["KC Sivaramakrishnan"]
license: "ISC"
dev-repo: "git+https://github.com/ocaml-multicore/saturn.git"
homepage: "https://github.com/ocaml-multicore/saturn"
doc: "https://ocaml-multicore.github.io/saturn/"
bug-reports: "https://github.com/ocaml-multicore/saturn/issues"
tags: []
depends: [
"dune" {>= "3.2"}
"ocaml" {>= "4.12"}
"dune" {>= "3.0"}
"domain_shims" {>= "0.1.0"}
"qcheck" {with-test & >= "0.18.1"}
"qcheck-stm" {with-test & >= "0.2"}
"qcheck-alcotest" {with-test & >= "0.18.1"}
"alcotest" {with-test & >= "1.6.0"}
"yojson" {with-test &>= "2.0.2"}
"dscheck" {with-test & >= "0.1.0"}
"qcheck" {>= "0.18.1" & with-test}
"qcheck-stm" {>= "0.2" & with-test}
"qcheck-alcotest" {>= "0.18.1" & with-test}
"yojson" {>= "2.0.2" & with-test}
"dscheck" {>= "0.1.0" & with-test}
"odoc" {with-doc}
]
available: arch != "x86_32" & arch != "arm32" & arch != "ppc64"
depopts: []
build: ["dune" "build" "-p" name "-j" jobs]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/ocaml-multicore/saturn.git"
6 changes: 3 additions & 3 deletions src_lockfree/ws_deque.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module CArray = struct
(* Because [size t] is a power of two, [i mod (size t)] is the same as
[i land (size t - 1)], that is, [i land (mask t)]. *)
Int.logand i (mask t)
[@@inline]
[@@inline]

let get t i = Array.unsafe_get t (index i t) [@@inline]
let put t i v = Array.unsafe_set t (index i t) v [@@inline]
Expand All @@ -66,7 +66,7 @@ module CArray = struct
dst
(index top dst) (* number of elements: *)
num
[@@inline]
[@@inline]

let grow t top bottom =
let sz = size t in
Expand Down Expand Up @@ -138,7 +138,7 @@ module M : S = struct
deque array get garbage collected *)
ptr := Obj.magic ();
res
[@@inline]
[@@inline]

let pop q =
if size q = 0 then raise Exit
Expand Down
7 changes: 7 additions & 0 deletions test/michael_scott_queue/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
(test
(name michael_scott_queue_dscheck)
(libraries atomic dscheck alcotest)
(enabled_if
(not
(and
(= %{arch_sixtyfour} false)
(= %{architecture} arm))))
(modules backoff michael_scott_queue michael_scott_queue_dscheck))

(test
Expand All @@ -18,5 +23,7 @@
(name stm_michael_scott_queue)
(modules stm_michael_scott_queue)
(libraries saturn qcheck-stm.sequential qcheck-stm.domain)
(enabled_if
(= %{arch_sixtyfour} true))
(action
(run %{test} --verbose)))
9 changes: 6 additions & 3 deletions test/mpmc_relaxed_queue/test_mpmc_relaxed_queue.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ let two_threads_spin_test () =
Domain.join dequeuer |> ignore;
()

let doms1 = if Sys.word_size >= 64 then 4 else 1
let doms2 = if Sys.word_size >= 64 then 8 else 1

let () =
let open Alcotest in
run "Mpmc_queue"
Expand All @@ -146,9 +149,9 @@ let () =
);
( "validate indices under load",
[
test_case " 4 prod. 4 cons." `Slow (run_test 4 4);
test_case " 8 prod. 1 cons." `Slow (run_test 8 1);
test_case " 1 prod. 8 cons." `Slow (run_test 1 8);
test_case " 4 prod. 4 cons." `Slow (run_test doms1 doms1);
test_case " 8 prod. 1 cons." `Slow (run_test doms2 1);
test_case " 1 prod. 8 cons." `Slow (run_test 1 doms2);
] );
]
@
Expand Down
2 changes: 2 additions & 0 deletions test/mpsc_queue/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
(name stm_mpsc_queue)
(modules stm_mpsc_queue)
(libraries saturn qcheck-stm.sequential qcheck-stm.domain)
(enabled_if
(= %{arch_sixtyfour} true))
(action
(run %{test} --verbose)))
2 changes: 1 addition & 1 deletion test/mpsc_queue/stm_mpsc_queue.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module MPSCConf = struct
(is_closed, if not is_closed then i :: List.rev s |> List.rev else s)
| Push_head i -> (is_closed, if not (is_closed && s = []) then i :: s else s)
| Is_empty -> (is_closed, s)
| Pop -> ( (is_closed, match s with [] -> s | _ :: s' -> s'))
| Pop -> (is_closed, match s with [] -> s | _ :: s' -> s')
| Close -> (true, s)

let precond _ _ = true
Expand Down
2 changes: 2 additions & 0 deletions test/spsc_queue/dune
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
(name stm_spsc_queue)
(modules stm_spsc_queue)
(libraries saturn qcheck-stm.sequential qcheck-stm.domain)
(enabled_if
(= %{arch_sixtyfour} true))
(action
(run %{test} --verbose)))
7 changes: 7 additions & 0 deletions test/treiber_stack/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
(test
(name treiber_stack_dscheck)
(libraries atomic dscheck alcotest)
(enabled_if
(not
(and
(= %{arch_sixtyfour} false)
(= %{architecture} arm))))
(modules backoff treiber_stack treiber_stack_dscheck))

(test
Expand All @@ -18,5 +23,7 @@
(name stm_treiber_stack)
(modules stm_treiber_stack)
(libraries saturn qcheck-stm.sequential qcheck-stm.domain)
(enabled_if
(= %{arch_sixtyfour} true))
(action
(run %{test} --verbose)))
7 changes: 7 additions & 0 deletions test/ws_deque/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
(test
(name qcheck_ws_deque)
(libraries barrier saturn qcheck "qcheck-alcotest")
(enabled_if
(not
(and
(= %{arch_sixtyfour} false)
(= %{architecture} arm))))
(modules qcheck_ws_deque))

(test
(name stm_ws_deque)
(modules stm_ws_deque)
(libraries saturn qcheck-stm.sequential qcheck-stm.domain)
(enabled_if
(= %{arch_sixtyfour} true))
(action
(run %{test} --verbose)))
2 changes: 1 addition & 1 deletion test/ws_deque/test_ws_deque.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let test_concurrent_workload () =
(* The desired number of steal attempts per thief. *)
let attempts = 100000 in
(* The number of thieves. *)
let thieves = 16 in
let thieves = if Sys.word_size >= 64 then 16 else 2 in
(* The queue. *)
let q = create () in
(* A generator of fresh elements. *)
Expand Down

0 comments on commit 49e4e59

Please sign in to comment.