[Openmp-commits] [openmp] [OpenMP][OMPT] Emit `dispatch` callback for serial and zero-trip loops (PR #207773)

Jan André Reuter via Openmp-commits openmp-commits at lists.llvm.org
Tue Aug 4 07:44:21 PDT 2026


================
@@ -241,6 +259,24 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid,
           ompt_work_type, ompt_scope_begin, &(team_info->parallel_data),
           &(task_info->task_data), *pstride, codeptr);
     }
+    if (ompt_enabled.ompt_callback_dispatch) {
----------------
Thyre wrote:

I'm not that fond of the OMPT callback handling in that method.
Basically, three separate cases are handled in `__kmp_for_static_init`:

1. Special handling for zero-trip loops. Previously, only a _work-begin_ event was dispatched here.
2. Handling for a serialized team. Similarly, only a _work-begin_ event was dispatched.
3. Your "normal" for loop. Here, _work-begin_ and the dispatch callback were already implemented.

This PR adds the dispatch callback for the first two cases. Hence the exact same code twice.
In general, handling for both callbacks is pretty much the same for all three cases. One could question if an implementation ever provides a zero-trip loop for sections. We might be able to strip that part, but I think it doesn't hurt to keep it.

Maybe it's worth trying to refactor the dispatch of both callbacks to reduce duplication a bit.

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


More information about the Openmp-commits mailing list