[Openmp-commits] [openmp] 57d8b8d - [openmp] Fixed hang if detached task was serialized.
via Openmp-commits
openmp-commits at lists.llvm.org
Mon May 18 05:33:05 PDT 2020
Author: AndreyChurbanov
Date: 2020-05-18T15:32:13+03:00
New Revision: 57d8b8d6f0b91b380ca3b270b4439c338ed67f53
URL: https://github.com/llvm/llvm-project/commit/57d8b8d6f0b91b380ca3b270b4439c338ed67f53
DIFF: https://github.com/llvm/llvm-project/commit/57d8b8d6f0b91b380ca3b270b4439c338ed67f53.diff
LOG: [openmp] Fixed hang if detached task was serialized.
The patch fixes https://bugs.llvm.org/show_bug.cgi?id=45904.
Differential Revision: https://reviews.llvm.org/D79944
Added:
openmp/runtime/test/tasking/omp_detach_taskwait.c
Modified:
openmp/runtime/src/kmp_tasking.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index fe8bcad0fa6f..c92851741060 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -916,8 +916,9 @@ static void __kmp_task_finish(kmp_int32 gtid, kmp_task_t *task,
taskdata->td_flags.complete = 1; // mark the task as completed
// Only need to keep track of count if team parallel and tasking not
- // serialized
- if (!(taskdata->td_flags.team_serial || taskdata->td_flags.tasking_ser)) {
+ // serialized, or task is detachable and event has already been fulfilled
+ if (!(taskdata->td_flags.team_serial || taskdata->td_flags.tasking_ser) ||
+ taskdata->td_flags.detachable == TASK_DETACHABLE) {
// Predecrement simulated by "- 1" calculation
children =
KMP_ATOMIC_DEC(&taskdata->td_parent->td_incomplete_child_tasks) - 1;
diff --git a/openmp/runtime/test/tasking/omp_detach_taskwait.c b/openmp/runtime/test/tasking/omp_detach_taskwait.c
new file mode 100644
index 000000000000..66c9b8364144
--- /dev/null
+++ b/openmp/runtime/test/tasking/omp_detach_taskwait.c
@@ -0,0 +1,26 @@
+// RUN: %libomp-compile -fopenmp-version=50 && env OMP_NUM_THREADS='3' %libomp-run
+// RUN: %libomp-compile -fopenmp-version=50 && env OMP_NUM_THREADS='1' %libomp-run
+
+// Checked gcc 9.2 still does not support detach clause on task construct.
+// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8, gcc-9
+// clang supports detach clause since version 11.
+// UNSUPPORTED: clang-10, clang-9, clang-8, clang-7
+// icc compiler does not support detach clause.
+// UNSUPPORTED: icc
+
+#include <omp.h>
+
+int main()
+{
+ #pragma omp parallel
+ #pragma omp master
+ {
+ omp_event_handle_t event;
+ #pragma omp task detach(event)
+ {
+ omp_fulfill_event(event);
+ }
+ #pragma omp taskwait
+ }
+ return 0;
+}
More information about the Openmp-commits
mailing list