[Openmp-commits] [openmp] Draft: [OpenMP] Fix td_tdg_task_id underflow with taskloop and taskgraph (PR #150877)

Josep Pinot via Openmp-commits openmp-commits at lists.llvm.org
Sun Jul 27 22:33:07 PDT 2025


https://github.com/jpinot updated https://github.com/llvm/llvm-project/pull/150877

>From c53fcbe5527d1aee3aca96eaf823d9092f8669c3 Mon Sep 17 00:00:00 2001
From: jpinot <josep.pinot at bsc.es>
Date: Thu, 17 Jul 2025 12:22:01 +0200
Subject: [PATCH] [OpenMP] Fix td_tdg_task_id underflow with taskloop and
 taskgraph

This patch addresses an issue where the td_tdg_task_id could underflow,
leading to a negative task ID, when a taskloop region was encountered
before a taskgraph clause.
---
 openmp/runtime/src/kmp_tasking.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index e4d92a78fd6b9..f4e5107627b73 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -4952,7 +4952,8 @@ static void __kmp_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int if_val,
   }
 
 #if OMPX_TASKGRAPH
-  KMP_ATOMIC_DEC(&__kmp_tdg_task_id);
+  if (taskdata->is_taskgraph)
+    KMP_ATOMIC_DEC(&__kmp_tdg_task_id);
 #endif
   // =========================================================================
   // calculate loop parameters



More information about the Openmp-commits mailing list