[Openmp-commits] [openmp] Draft: [OpenMP] Fix datarace with taskgraph dependencies and task stealing (PR #150880)
Josep Pinot via Openmp-commits
openmp-commits at lists.llvm.org
Sun Jul 27 22:30:33 PDT 2025
https://github.com/jpinot created https://github.com/llvm/llvm-project/pull/150880
This commit resolves a datarace that could occur when taskgraph with dependencies was enabled alongside task stealing. The problem occur because, during task stealing, the stealing thread could incorrectly add an extra node to the task dependency graph, while the original thread might fail to create the correct node, leading to a corrupted graph and potential execution issues.
>From cd9a91992a069416a5a2a82dae66eec7d434c31b Mon Sep 17 00:00:00 2001
From: jpinot <josep.pinot at bsc.es>
Date: Mon, 7 Jul 2025 10:53:46 +0200
Subject: [PATCH] [OpenMP] Fix datarace with taskgraph dependencies and task
stealing
This commit resolves a datarace that could occur when taskgraph with
dependencies was enabled alongside task stealing. The problem occur
because, during task stealing, the stealing thread could incorrectly add
an extra node to the task dependency graph, while the original thread
might fail to create the correct node, leading to a corrupted graph and
potential execution issues.
---
openmp/runtime/src/kmp_taskdeps.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/openmp/runtime/src/kmp_taskdeps.cpp b/openmp/runtime/src/kmp_taskdeps.cpp
index abbca752f0587..70443d7ff9507 100644
--- a/openmp/runtime/src/kmp_taskdeps.cpp
+++ b/openmp/runtime/src/kmp_taskdeps.cpp
@@ -329,6 +329,12 @@ __kmp_depnode_link_successor(kmp_int32 gtid, kmp_info_t *thread,
if (!(__kmp_tdg_is_recording(tdg_status)) && task)
#endif
__kmp_track_dependence(gtid, dep, node, task);
+#if OMPX_TASKGRAPH
+ else if (KMP_TASK_TO_TASKDATA(dep->dn.task)->td_flags.onced) {
+ KMP_RELEASE_DEPNODE(gtid, dep);
+ continue;
+ }
+#endif
dep->dn.successors = __kmp_add_node(thread, dep->dn.successors, node);
KA_TRACE(40, ("__kmp_process_deps: T#%d adding dependence from %p to "
"%p\n",
More information about the Openmp-commits
mailing list