diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp --- a/openmp/runtime/src/kmp_tasking.cpp +++ b/openmp/runtime/src/kmp_tasking.cpp @@ -884,7 +884,8 @@ // 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)) { + 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 --- /dev/null +++ b/openmp/runtime/test/tasking/omp_detach_taskwait.c @@ -0,0 +1,23 @@ +// 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 does not support detach clause on task construct, +// clang supports detach clause since version 11 +// UNSUPPORTED: gcc, clang-10, clang-9, clang-8, clang-7 + +#include + +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; +}