[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
Mon Jul 28 04:29:10 PDT 2025


jpinot wrote:

> What is the purpose of the decrement?

Currently, when taskloop construct is invoked, clang [generates a runtime call to `__kmpc_omp_task_alloc()`](https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGOpenMPRuntime.cpp#L4609), which creates a task. This task is then [duplicated](https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_tasking.cpp#L4670) when `__kmp_taskloop` is call (were `td_tdg_task_id` is finally set). The decrement "resets" the value to the inital value (before call to `__kmpc_omp_task_alloc`).

The PR is still in Draft because this solution does not fit cases where multiple taskgraphs are been recorded at the same time. I want to move the `td_tdg_task_id` inside the `kmp_taskdata`( something like `kmp_tdg_task_id_next`) to be unique for each taskgraph (Note that after recording, [`td_tdg_task_id` is beeing reset to 0](https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_tasking.cpp#L5749) ).

@jprotze Do you have any suggestions?

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


More information about the Openmp-commits mailing list