From 279cd6f376f9e4c40bb432c9c20ca4c491040c58 Mon Sep 17 00:00:00 2001 From: Carine Morel Date: Tue, 2 Jul 2024 16:42:48 +0200 Subject: [PATCH] Back to the classic multicore-magic-dscheck way as cyclic deps are a real thing apparently. --- dune-project | 3 +- src/dscheck/dune | 4 +- ...re_magic.ml => multicore_magic_dscheck.ml} | 11 +++++- src/dscheck/multicore_magic_dscheck.mli | 39 +++++++++++++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) rename src/dscheck/{multicore_magic.ml => multicore_magic_dscheck.ml} (80%) create mode 100644 src/dscheck/multicore_magic_dscheck.mli diff --git a/dune-project b/dune-project index 3501c51..d2d9438 100644 --- a/dune-project +++ b/dune-project @@ -44,7 +44,8 @@ (package (name multicore-magic-dscheck) - (synopsis "Low-level multiscore utilities for OCaml") + (synopsis + "A implementation of multicore-magic API using the atomic module of DScheck to make DScheck tests possible in libraries using multicore-magic.") (depends (ocaml (>= 4.12.0)) diff --git a/src/dscheck/dune b/src/dscheck/dune index b649616..86455e9 100644 --- a/src/dscheck/dune +++ b/src/dscheck/dune @@ -1,6 +1,4 @@ (library (name multicore_magic_dscheck) (public_name multicore-magic-dscheck) - (wrapped false) - (root_module Deps) - (libraries multicore-magic dscheck)) \ No newline at end of file + (libraries multicore-magic dscheck)) diff --git a/src/dscheck/multicore_magic.ml b/src/dscheck/multicore_magic_dscheck.ml similarity index 80% rename from src/dscheck/multicore_magic.ml rename to src/dscheck/multicore_magic_dscheck.ml index 600a2ae..b47354a 100644 --- a/src/dscheck/multicore_magic.ml +++ b/src/dscheck/multicore_magic_dscheck.ml @@ -1,9 +1,14 @@ -include Deps.Multicore_magic -module Atomic = Deps.Dscheck.TracedAtomic +module Atomic = Dscheck.TracedAtomic + +let copy_as_padded = Fun.id +let make_padded_array = Array.make +let length_of_padded_array = Array.length +let length_of_padded_array_minus_1 xs = Array.length xs - 1 module Transparent_atomic = struct include Atomic + let make_contended = make let fenceless_get = get let fenceless_set = set end @@ -35,3 +40,5 @@ module Atomic_array = struct let[@inline] unsafe_compare_and_set xs i b a = Atomic.compare_and_set (at xs i) b a end + +let instantaneous_domain_index () = 0 diff --git a/src/dscheck/multicore_magic_dscheck.mli b/src/dscheck/multicore_magic_dscheck.mli new file mode 100644 index 0000000..faa3163 --- /dev/null +++ b/src/dscheck/multicore_magic_dscheck.mli @@ -0,0 +1,39 @@ +module Atomic = Dscheck.TracedAtomic + +val copy_as_padded : 'a -> 'a +val make_padded_array : int -> 'a -> 'a array +val length_of_padded_array : 'a array -> int +val length_of_padded_array_minus_1 : 'a array -> int +val fenceless_get : 'a Atomic.t -> 'a +val fenceless_set : 'a Atomic.t -> 'a -> unit +val fence : int Atomic.t -> unit + +module Transparent_atomic : sig + type !'a t = 'a Atomic.t + + val make : 'a -> 'a t + val make_contended : 'a -> 'a t + val get : 'a t -> 'a + val fenceless_get : 'a t -> 'a + val set : 'a t -> 'a -> unit + val fenceless_set : 'a t -> 'a -> unit + val exchange : 'a t -> 'a -> 'a + val compare_and_set : 'a t -> 'a -> 'a -> bool + val fetch_and_add : int t -> int -> int + val incr : int t -> unit + val decr : int t -> unit +end + +module Atomic_array : sig + type !'a t + + val make : int -> 'a -> 'a t + val of_array : 'a array -> 'a t + val init : int -> (int -> 'a) -> 'a t + val length : 'a t -> int + val unsafe_fenceless_get : 'a t -> int -> 'a + val unsafe_fenceless_set : 'a t -> int -> 'a -> unit + val unsafe_compare_and_set : 'a t -> int -> 'a -> 'a -> bool +end + +val instantaneous_domain_index : unit -> int