Closed computablee closed 1 year ago
From what I've understood of the Stack Overflow you shared, all threads execute concurrently until they encounter an ordered region, then they execute sequentially. There are two approaches mentioned: the static
and the dynamic
one. I'm assuming the goal is to implement a behavior similar to the dynamic
one, right?
@diogolopes18-cyber The static
versus dynamic
question is with regards to the scheduler passed to OpenMP.Parallel.For
. The implementation of ordered
shouldn't depend on the schedule. A naive pseudocode implementation would be
while (current_thread.current_iteration != this_ordered_region.current_iteration)
spin.SpinOnce();
action();
++this_ordered_region.current_iteration;
I've gone ahead and implemented this myself.
OpenMP supports an ordered construct. It is a little complex and I believe it is best explained here.
I was thinking of implementing it like this:
The functionality is a little tricky to implement. We'll need to store each thread's current working iteration in the
Init
class. Then we need some way to impose an order on the action. There might be a best way to do this efficiently without spinwaits, but I can't think of one off the top of my head. Let's discuss before I assign this issue to anyone.