Closed computablee closed 1 year ago
I think this issue is now a non-issue. shared
can be implemented merely by declaring a variable outside of the ParallelRegion
or through the OpenMP.Shared<T>
class, and private
/firstprivate
can be implemented by declaring a variable inside of the ParallelRegion
. Marking this as "wontfix" and closing it for now. May re-open it later down the road.
This is a bit of a tricky one, and I'm not sure the best way to do this. Was thinking we could brainstorm in this issue before I assign anyone.
OpenMP supports
private
,firstprivate
, andshared
to parallel constructs as follows:I had an idea of implementing this in OpenMP.NET as follows:
There are lots of problems with this idea. Let's unpack.
First, you can't throw
ref
parameters into an array, at least not from any of my searches on Google. So theshared
parameter won't work. Second, we would have to trust the user that theaction
parameters are in-order for how they're presented to the function. Additionally, if the user swaps the placement ofpriv
andfirstpriv
in theParallelRegion
call, we have no way of knowing this, and arguments would be passed to theaction
out-of-order. It would be a nightmare from the usability perspective.Another glaringly obvious problem with this is that
ParallelRegion
acceptsAction action
as the lambda. If we were to start passing in reference parameters, we'd need to not only create some sort ofActionRef
delegate as described here, but it would add horrible complexity to the code. Consider the following example of a simpleParallelRegion
implementation with these new changes. For the sake of demonstrating this example in isolation, we pretend that you can only pass one variable toshared
.Under this idea, we would...
ActionRef
overloads as as many variables we're willing to support (horrible complexity).shared
and pass it as a reference parameter (not possible under C#'s type system).The issues with
shared
can be mitigated if we just never implement it, and explain to the user that OpenMP.NET works as shared-by-default (via closures). If we can't find a way to implementshared
, this would be a fine solution. However, the problems withActionRef
complexity and swappingpriv
andfirstpriv
remain issues.So it looks like implementing these clauses is going to be a very non-trivial endeavor. Let's brainstorm!