Change/Fix to use a symmetric barrier to synchronize domains #509
+8
−3
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.
Unless I've misunderstood something, the idea is to synchronize the two domains before the two sequences of operations are run in parallel. The previous implementation used an asymmetric approach where one domain only spins on a flag and the other only sets the flag. That is not really guaranteed to synchronize the domains — the domain setting the flag might start running the operations before the domain spinning on the flag gets a chance to run. This PR changes the code to use a symmetric barrier: a counter is initialized with 2, both domains decrement the counter, and then spin until the counter becomes zero. This should improve the synchronization between the two domains.