[llvm-branch-commits] [mlir] [OpenMP][MLIR] Add thread_limit mlir->llvm lowering (PR #179608)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 8 06:02:32 PDT 2026
================
@@ -6287,7 +6310,7 @@ initTargetDefaultAttrs(omp::TargetOp targetOp, Operation *capturedOp,
attrs.MinTeams = minTeamsVal;
attrs.MaxTeams.front() = maxTeamsVal;
attrs.MinThreads = 1;
- attrs.MaxThreads.front() = combinedMaxThreadsVal;
+ attrs.MaxThreads = combinedMaxThreadsVals;
----------------
skatrak wrote:
Correct me if I'm wrong, but I'm seeing some inconsistencies regarding this:
- The `TargetKernelRuntimeAttrs` represents max threads as a single value, whereas `TargetKernelDefaultAttrs` can hold a list. If multiple dims are to be supported, both should be kept in sync. Otherwise, what happens if e.g. the second dim is not constant?
- The OMPIRBuilder discards additional dims in `MaxThreads` in both default and runtime structures. It only ever looks at their first element.
Basically, what this amounts to is that LLVM IR generation based on `MaxThreads` (e.g. the kernel environment global variable or the `omp_target_thread_limit` function attribute) only takes into account the first dim. If that's the intended behavior, then we probably want to make `TargetKernelDefaultAttrs::MaxThreads` a single value again. Otherwise, we need to make `TargetKernelRuntimeAttrs::MaxThreads` an array and properly handle multiple dimensions in the OMPIRBuilder for both structures.
https://github.com/llvm/llvm-project/pull/179608
More information about the llvm-branch-commits
mailing list