-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP : Trying with unwrapped lib and a module named multicore_magic. C…
…ycling deps issue.
- Loading branch information
Showing
6 changed files
with
41 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
(library | ||
(name multicore_magic_dscheck) | ||
(package multicore-magic-dscheck) | ||
(libraries multicore-magic dscheck)) | ||
(public_name multicore-magic-dscheck) | ||
(wrapped false) | ||
(root_module Deps) | ||
(libraries multicore-magic dscheck)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
include Deps.Multicore_magic | ||
module Atomic = Deps.Dscheck.TracedAtomic | ||
|
||
module Transparent_atomic = struct | ||
include Atomic | ||
|
||
let fenceless_get = get | ||
let fenceless_set = set | ||
end | ||
|
||
let[@inline] fenceless_get (atomic : 'a Atomic.t) = | ||
!(Sys.opaque_identity (Obj.magic atomic : 'a ref)) | ||
|
||
let[@inline] fenceless_set (atomic : 'a Atomic.t) value = | ||
(Obj.magic atomic : 'a ref) := value | ||
|
||
let[@inline] fence atomic = Atomic.fetch_and_add atomic 0 |> ignore | ||
|
||
module Atomic_array = struct | ||
type 'a t = 'a Atomic.t array | ||
|
||
let[@inline] at (type a) (xs : a t) i : a Atomic.t = | ||
(* ['a t] does not contain [float]s. *) | ||
Obj.magic (Array.unsafe_get (Obj.magic xs : a ref array) i) | ||
|
||
let[@inline] make n v = Array.init n @@ fun _ -> Atomic.make v | ||
let[@inline] init n fn = Array.init n @@ fun i -> Atomic.make (fn i) | ||
let[@inline] of_array xs = init (Array.length xs) (Array.unsafe_get xs) | ||
|
||
external length : 'a array -> int = "%array_length" | ||
|
||
let[@inline] unsafe_fenceless_set xs i v = Obj.magic (at xs i) := v | ||
let[@inline] unsafe_fenceless_get xs i = !(Obj.magic (at xs i)) | ||
|
||
let[@inline] unsafe_compare_and_set xs i b a = | ||
Atomic.compare_and_set (at xs i) b a | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.