[Mlir-commits] [mlir] [OpenMP][MLIR] Fix initTargetRuntimeAttrs, LoopTripCount calculation when host_eval vars is empty (PR #157717)
Sergio Afonso
llvmlistbot at llvm.org
Thu Sep 11 04:11:59 PDT 2025
skatrak wrote:
> This change is required for #140523 workdistribute construct lowering, where in a fir.do_loop unordered is identified under `target teams workdistribute` region and then lowered to `target{teams{parallel{distribute{wsloop{loop_nest}}}`.
>
> The test mentioned in this PR passes the verifier, but crashes at lowering from openmp to llvm ir. I'm unaware that host_eval clause needs to have loop bounds information even though they are constants.
If that's the case, then I think some changes would probably have to be done to workdistribute lowering. I think it should conform to the rules of the dialect, so we can properly codegen for the resulting target region. If you look at the current work being done for automatic offloading of do-concurrent (#155987), you can see it is able to follow these rules and produce the [expected MLIR]( https://mlir.llvm.org/docs/Dialects/OpenMPDialect/#host-evaluated-clauses-in-target-regions).
I think the core issue here is that, whenever `omp.workdistribute` is replaced with the corresponding set of nested operations, we need to check whether it's located in a target region and, in that case, find their value outside of the target region (or copy the constant) and pass that as `host_eval`. Ideally, I would try to do this earlier in Flang lowering, rather than as a transformation pass, because that's where we have all of the `host_eval` infrastructure prepared to do exactly this (see `processHostEvalClauses` and `HostEvalInfo` in flang/lib/Lower/OpenMP/OpenMP.cpp).
https://github.com/llvm/llvm-project/pull/157717
More information about the Mlir-commits
mailing list