[flang-commits] [flang] [flang][OpenMP] Support `bind` clause code-gen for standalone `loop`s (PR #122674)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Mon Jan 27 02:25:45 PST 2025
================
@@ -117,7 +120,27 @@ class GenericLoopConversionPattern
return result;
}
- /// Rewrites standalone `loop` directives to equivalent `simd` constructs.
+ void rewriteStandaloneLoop(mlir::omp::LoopOp loopOp,
+ mlir::ConversionPatternRewriter &rewriter) const {
+ using namespace mlir::omp;
+ std::optional<ClauseBindKind> bindKind = loopOp.getBindKind();
+
+ if (!bindKind.has_value())
+ return rewriteToSimdLoop(loopOp, rewriter);
+
+ switch (*loopOp.getBindKind()) {
+ case ClauseBindKind::Parallel:
+ return rewriteToWsloop(loopOp, rewriter);
+ case ClauseBindKind::Teams:
+ return rewriteToDistrbute(loopOp, rewriter);
----------------
ergawy wrote:
> I'm wondering if we should have a tag for such implicitly generated SIMD construct to distinguish them from the programmer actually having written `simd` in their code, so that we can still differentiate these loops later.
I think rather than generating a `simd` op, attaching an attribute that it was generated by a transformation pass, and then deciding later whether to actually lower it to `simd` or serialize it. I think it would be better to keep these heuristics in the `loop` directive rewriting pass itself and emit debug/warning info that summarize any decisions we would like the compiler to emit that help with debugging and performance diagnostics.
@skatrak would have a better informed opinion than me though.
https://github.com/llvm/llvm-project/pull/122674
More information about the flang-commits
mailing list