Skip to content

Parallelism support: PoC/Suggestion #1694

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

Closed
wants to merge 1 commit into from

Conversation

arkocal
Copy link
Contributor

@arkocal arkocal commented Feb 20, 2025

This PR should provide a base for discussion.

In order to maintain backwards compatibility, we need to provide stubs for functionality needed for parallelism when no libraries provide this. Also, to keep possibly diverging parts to a minimum, the utilities for parallelism are kept in a separate module.

This commit is a sketch of how we could go about it. In particular, it is not clear if ppx_optcomp is the best solution for this.

In order to maintain backwards compatibility, we need to provide
stubs for functionality needed for parallelism when no libraries
provide this. Also, to keep possibly diverging parts to a minimum,
the utilities for parallelism are kept in a separate module.

This commit is a sketch of how we could go about it. In particular,
it is not clear if `ppx_optcomp` is the best solution for this.
@@ -0,0 +1,62 @@
[%%if ocaml_version >= (5, 0, 0)]
(* Simple Mutex Implementation using Domain-Local Await (https://github.com/ocaml-multicore/domain-local-await)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's described as

At the time of writing this, the Stdlib Mutex implementation does not take into account the possibility of having an effects based scheduler and simply blocks the current domain (or (sys)thread) without giving a potential scheduler the opportunity to schedule another fiber on the domain.

Is this actually needed? Do the parallel solvers also use effects-based schedulers per-domain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time of writing it was needed for solvers using the domainslib library. I have included this as it is one of the simplest examples.

I am currently evaluating this and other workarounds that were implemented at the time, so this in particular might be replaced by the Stdlib or Batteries Mutex.

However, even then we will need to benchmark this. With 5.0.0 even mutexes that were guaranteed to always be free caused slowdowns. If this is still the case, a No-Op mutex could still be useful. (Of course, we can also go the middle-way and configure the behaviour of the Mutex at runtime)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the used Domainslib uses an internal scheduler. This incompatibility was something that took us a while to track down in one of our solvers (Helmut's variant iirc):

See also ocaml-multicore/domainslib#127

@sim642 sim642 added the parallel Parallel Goblint label Feb 20, 2025
@sim642
Copy link
Member

sim642 commented Apr 17, 2025

This should be superseded by #1708.

@sim642 sim642 closed this Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parallel Parallel Goblint question
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants