computablee / DotMP

A collection of powerful abstractions for parallel programming in .NET with an OpenMP-like API.
https://computablee.github.io/DotMP/
GNU Lesser General Public License v2.1
29 stars 8 forks source link

`DotMP.Parallel.Single` should act as a barrier #47

Closed computablee closed 11 months ago

computablee commented 1 year ago

Currently, the DotMP.Parallel.Single construct behaves a bit differently than #pragma omp single.

  1. DotMP.Parallel.Single should act as an implicit barrier, but it does not.
  2. DotMP.Parallel.Single should not be permitted to be used inside of a work sharing region like Parallel.For or Parallel.ForReduction.

This shouldn't be too difficult of a fix-- Single needs to check if the in_for flag is set inside of the WorkShare singleton, and if it is, it should throw an exception. Additionally, and this is perhaps the easiest aspect to this PR... just add a Barrier() call to the end of the Single() method.

Make sure documentation is updated as well to reflect the changes!

blouflashdb commented 11 months ago

Which Exception should be thrown?

computablee commented 11 months ago

Probably CannotPerformNestedWorksharingException. That's a new exception that should be created inside Exceptions.cs.

computablee commented 11 months ago

Closed by #57