[OpenMP] Fix task wait doesn't work as expected in serialized team
authorShilei Tian <tianshilei1992@gmail.com>
Tue, 31 Aug 2021 16:15:38 +0000 (12:15 -0400)
committerShilei Tian <tianshilei1992@gmail.com>
Tue, 31 Aug 2021 16:15:46 +0000 (12:15 -0400)
commit8442967fe32453ada32913d1e0fdd97b19520df2
treec7e83a908a670497025bc59b955ab4189596116c
parent6c0181c00f4ea0bcb7e4d05055412083b8270cc8
[OpenMP] Fix task wait doesn't work as expected in serialized team

As discussed in D107121, task wait doesn't work when a regular task T depends on
a detached task or a hidden helper task T' in a serialized team. The root cause is,
since the team is serialized, the last task will not be tracked by
`td_incomplete_child_tasks`. When T' is finished, it first releases its
dependences, and then decrements its parent counter. So far so good. For the thread
that is running task wait, if at the moment it is still spinning and trying to
execute tasks, it is fine because it can detect the new task and execute it.
However, if it happends to finish the function `flag.execute_tasks(...)`, it will
be broken because `td_incomplete_child_tasks` is 0 now.

In this patch, we update the rule to track children tasks a little bit. If the
task team encounters a proxy task or a hidden helper task, all following tasks
will be tracked.

Reviewed By: AndreyChurbanov

Differential Revision: https://reviews.llvm.org/D107496
openmp/runtime/src/kmp_tasking.cpp
openmp/runtime/test/tasking/hidden_helper_task/depend.cpp
openmp/runtime/test/tasking/hidden_helper_task/gtid.cpp