[Openmp-commits] [PATCH] D77603: [OpenMP] Sync writes to child thread's data before reduction

Andrey Churbanov via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Apr 13 05:52:47 PDT 2020


AndreyChurbanov requested changes to this revision.
AndreyChurbanov added a comment.
This revision now requires changes to proceed.

Sorry, found one more issue.

I think the first MB should be moved inside the block:

  for (level...
    if (((tid...

Rational: current code will work for one level tree of threads.  For multiple levels tree, the parent thread on level 0 can become child on level 1, and it will miss MB for publishing its reduction data accumulated on level 0 to be used by its "new" parent on level 1. Former parent flushed its initial reduction data only, but not newly accumulated data (at line 612).

Once MB is moved inside the loop-if block - to before child thread flag releasing, it will work for all levels children (including those were parent at lower levels of the tree).

E.g. let's look at 8 threads t0 - t7 for current code.
At level 0 parent t0 has children t1, t2, t3; parent t4 has children t5, t6, t7.
At next level 1 parent t0 has one child t4, which didn't flush its reduction data after reducing data of the last child t7 at line 612. So t0 has a chance to reduce stale data of t4.
With suggested code thread t4 will flush its partial data right before its flag releasing (and won't flash initial data which is not needed, only final partial data matter).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77603/new/

https://reviews.llvm.org/D77603





More information about the Openmp-commits mailing list