[Openmp-commits] [openmp] [OpenMP] Ignore teams ICV setters in restricted contexts (PR #194428)
Deepak Eachempati via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jun 9 09:13:50 PDT 2026
dreachem wrote:
> @dreachem, I checked this case, and the current guard does not catch it.
>
> For `target if(0)`, clang constant-folds the `if` clause and lowers the region to a direct call of the outlined host-fallback function. There is no `__tgt_target_kernel` / offload runtime entry and no libomp team/task state change for the host entry point to observe.
>
> So when `omp_set_num_teams()` is called from that outlined fallback function, the current thread still has `t_level == 0` and `th_teams_microtask == NULL`, so neither guard condition fires and the ICV is updated.
>
> My understanding is that catching this specific `target if(0)` case would need to happen either in the frontend/lowering path or through some target-region entry state that the host runtime API can observe. I do not think it can be handled narrowly in the current `omp_set_num_teams()` / `omp_set_teams_thread_limit()` host entry-point guard.
>
> So I would suggest keeping this PR scoped to the contexts that libomp can currently observe directly: non-implicit parallel regions and active teams regions. I’m happy to file a follow-up issue for the `target if(0)` / target-region case if that sounds reasonable.
I think that's fine. The spec says the behavior is unspecified if the call is made in any of these contexts, so while there is some inconsistency in how we are addressing that unspecified behavior it is still within the bounds of a compliant implementation.
https://github.com/llvm/llvm-project/pull/194428
More information about the Openmp-commits
mailing list