Skip to content

Commit

Permalink
Back to the classic multicore-magic-dscheck way as cyclic deps are a …
Browse files Browse the repository at this point in the history
…real thing apparently.
  • Loading branch information
lyrm committed Jul 2, 2024
1 parent d03267b commit 279cd6f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
3 changes: 2 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions src/dscheck/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(library
(name multicore_magic_dscheck)
(public_name multicore-magic-dscheck)
(wrapped false)
(root_module Deps)
(libraries multicore-magic dscheck))
(libraries multicore-magic dscheck))
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
39 changes: 39 additions & 0 deletions src/dscheck/multicore_magic_dscheck.mli
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 279cd6f

Please sign in to comment.