-
Notifications
You must be signed in to change notification settings - Fork 81
Introduce backwards compatible infrastructure for parallelism #1708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arkocal
merged 27 commits into
goblint:master
from
arkocal:parallelism_backwards_compat_1
May 15, 2025
Merged
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b1d786f
Parallelism support: Modules with backward comp
arkocal 1667683
Parallelism: Add domain_shims
arkocal f9ed034
Parallelism: Make messages thread-safe
FelixKrayer bc33346
Parallelism: Introduce thread-pool
arkocal 67a1c61
Parallelism: Introduce domain safe lazy
arkocal 3b9d901
Parallelism: Apply thread-safe Lazy on mutexAttrDomain
arkocal 539a853
Parallelism: Workout for timing
arkocal 3f7d226
Parallelism: Docs for utils
arkocal 48c76c0
Make wideningTokenLifter thread safe
arkocal 7fe63ef
Parallelism: adding parallel_domains option. Default set to 2 for dev…
FelixKrayer 490d047
Gobview: Drop support for Ocaml < 5.0.0
arkocal 16db900
Gobview: Drop support for Ocaml < 5.0.0
arkocal dec26b3
Gobview: Drop support for Ocaml < 5.0.0
arkocal f423d8e
Gobview: Move to unlocked test to use Ocaml 5.0.0
arkocal ccb2a6f
Merge branch 'master' of github.com:goblint/analyzer into parallelism…
arkocal a18cd77
Parallelism: Update documentation for parallel domains
arkocal 9e1614d
Parallelism: Timing: Only use DLS when necessary
arkocal 92043ca
Parallelism: Introduce mock thread pool
arkocal aed8d63
Introduce mli files for parallel utils and further minor fixes.
arkocal 9400b5a
Parallelism: Make dummy threadpool run sequentially
arkocal f4862bd
Add exceptions to lib modules
arkocal 9c9afa3
Fix typo
arkocal 1112d45
Domain safe lazy: Switch to suggested implementation from domain-loca…
arkocal fbb39d8
Cleanup
arkocal 68316aa
Timing: make enabling a simple ref and corresponding fix for multiple…
arkocal 05a6869
Add domainslib to depopts
arkocal 57b2e21
Add domainslib to deptopts in .opam
arkocal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
sim642 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,9 @@ | ||
type 'a t = GobMutex.t * ('a Stdlib.Lazy.t) | ||
|
||
let from_fun f = (GobMutex.create (), Stdlib.Lazy.from_fun f) | ||
|
||
let force (mtx, blk) = | ||
GobMutex.lock mtx; | ||
let value = Stdlib.Lazy.force blk in | ||
GobMutex.unlock mtx; | ||
value |
This file contains hidden or 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,6 @@ | ||
(** Lazy type which protects against concurrent calls of 'force'. *) | ||
sim642 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
type 'a t | ||
|
||
val from_fun: (unit -> 'a) -> 'a t | ||
val force: 'a t -> 'a |
This file contains hidden or 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,18 @@ | ||
(include_subdirs no) | ||
|
||
(library | ||
(name goblint_parallel) | ||
(public_name goblint.parallel) | ||
(libraries | ||
batteries | ||
sim642 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(select gobMutex.ml from | ||
(domainslib -> gobMutex.domainslib.ml) | ||
( -> gobMutex.no-domainslib.ml) | ||
) | ||
(select threadpool.ml from | ||
(domainslib -> threadpool.domainslib.ml) | ||
(-> threadpool.no-domainslib.ml) | ||
sim642 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
sim642 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
domain_shims | ||
domain-local-await) | ||
) |
This file contains hidden or 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,51 @@ | ||
(* Simple Mutex Implementation using Domain-Local Await (https://github.com/ocaml-multicore/domain-local-await) | ||
Copyright © 2023 Vesa Karvonen | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, | ||
provided that the above copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) | ||
sim642 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
type state = | ||
| Unlocked | ||
| Locked of (unit -> unit) list | ||
|
||
type t = state Atomic.t | ||
|
||
let create () = Atomic.make Unlocked | ||
|
||
let unlock t = | ||
match Atomic.exchange t Unlocked with | ||
| Unlocked -> invalid_arg "mutex: already unlocked" | ||
| Locked awaiters -> List.iter ((|>) ()) awaiters | ||
|
||
let rec lock t = | ||
match Atomic.get t with | ||
| Unlocked -> | ||
if not (Atomic.compare_and_set t Unlocked (Locked [])) then | ||
lock t | ||
| Locked awaiters as before -> | ||
let dla = Domain_local_await.prepare_for_await () in | ||
let after = Locked (dla.release :: awaiters) in | ||
if Atomic.compare_and_set t before after then | ||
match dla.await () with | ||
| () -> lock t | ||
| exception cancellation_exn -> | ||
let rec cleanup () = | ||
match Atomic.get t with | ||
| Unlocked -> () | ||
| Locked awaiters as before -> | ||
if List.for_all ((==) dla.release) awaiters then | ||
let after = | ||
Locked (List.filter ((!=) dla.release) awaiters) | ||
in | ||
if not (Atomic.compare_and_set t before after) then | ||
cleanup () | ||
in | ||
cleanup (); | ||
raise cancellation_exn | ||
else | ||
lock t |
This file contains hidden or 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,6 @@ | ||
type state = NoOp | ||
type t = state | ||
|
||
let create () = NoOp | ||
let unlock _ = () | ||
let lock _ = () |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.