diff --git a/openmp/runtime/src/kmp_taskdeps.cpp b/openmp/runtime/src/kmp_taskdeps.cpp index abbca752f0587..409948b9a85b6 100644 --- a/openmp/runtime/src/kmp_taskdeps.cpp +++ b/openmp/runtime/src/kmp_taskdeps.cpp @@ -321,9 +321,19 @@ __kmp_depnode_link_successor(kmp_int32 gtid, kmp_info_t *thread, __kmp_track_dependence(gtid, dep, node, task); } #endif - if (dep->dn.task) { + if (dep->dn.task +#if OMPX_TASKGRAPH + && __kmp_tdg_is_recording(tdg_status) && + !KMP_TASK_TO_TASKDATA(dep->dn.task)->td_flags.onced +#endif + ) { KMP_ACQUIRE_DEPNODE(gtid, dep); - if (dep->dn.task) { + if (dep->dn.task +#if OMPX_TASKGRAPH + && __kmp_tdg_is_recording(tdg_status) && + !KMP_TASK_TO_TASKDATA(dep->dn.task)->td_flags.onced +#endif + ) { if (!dep->dn.successors || dep->dn.successors->node != node) { #if OMPX_TASKGRAPH if (!(__kmp_tdg_is_recording(tdg_status)) && task) diff --git a/openmp/runtime/src/kmp_taskdeps.h b/openmp/runtime/src/kmp_taskdeps.h index f6bfb39218a21..04161aca7795e 100644 --- a/openmp/runtime/src/kmp_taskdeps.h +++ b/openmp/runtime/src/kmp_taskdeps.h @@ -146,6 +146,10 @@ static inline void __kmp_release_deps(kmp_int32 gtid, kmp_taskdata_t *task) { #endif node->dn.task = NULL; // mark this task as finished, so no new dependencies are generated +#if OMPX_TASKGRAPH + else + KMP_TASK_TO_TASKDATA(node->dn.task)->td_flags.onced = 1; +#endif KMP_RELEASE_DEPNODE(gtid, node); kmp_depnode_list_t *next;