[flang-commits] [flang] [NFC][mlir][OpenMP] Remove mentions of `target` from generic `loop` rewrite (PR #124528)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Mon Jan 27 06:22:55 PST 2025
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/124528
>From 7c4ec9b89b8af36cf49101c654ae8cd7e8fd4418 Mon Sep 17 00:00:00 2001
From: ergawy <kareem.ergawy at amd.com>
Date: Mon, 27 Jan 2025 04:56:13 -0600
Subject: [PATCH] [NFC][mlir][OpenMP] Remove mentions of `target` from generic
loop rewrite
This removes mentions of `target` from the generic `loop` rewrite pass
since there is not need for it anyway. It is enough to detect `loop`'s
nesting within `teams` or `parallel` directives.
---
.../OpenMP/GenericLoopConversion.cpp | 24 +++++++------------
.../generic-loop-rewriting-todo.mlir | 2 +-
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
index c95d625d7240b4..546943204e6534 100644
--- a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
+++ b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
@@ -29,11 +29,7 @@ namespace {
class GenericLoopConversionPattern
: public mlir::OpConversionPattern<mlir::omp::LoopOp> {
public:
- enum class GenericLoopCombinedInfo {
- Standalone,
- TargetTeamsLoop,
- TargetParallelLoop
- };
+ enum class GenericLoopCombinedInfo { Standalone, TeamsLoop, ParallelLoop };
using mlir::OpConversionPattern<mlir::omp::LoopOp>::OpConversionPattern;
@@ -55,10 +51,10 @@ class GenericLoopConversionPattern
case GenericLoopCombinedInfo::Standalone:
rewriteStandaloneLoop(loopOp, rewriter);
break;
- case GenericLoopCombinedInfo::TargetParallelLoop:
+ case GenericLoopCombinedInfo::ParallelLoop:
llvm_unreachable("not yet implemented: `parallel loop` direcitve");
break;
- case GenericLoopCombinedInfo::TargetTeamsLoop:
+ case GenericLoopCombinedInfo::TeamsLoop:
rewriteToDistributeParallelDo(loopOp, rewriter);
break;
}
@@ -74,10 +70,10 @@ class GenericLoopConversionPattern
switch (combinedInfo) {
case GenericLoopCombinedInfo::Standalone:
break;
- case GenericLoopCombinedInfo::TargetParallelLoop:
+ case GenericLoopCombinedInfo::ParallelLoop:
return loopOp.emitError(
- "not yet implemented: Combined `omp target parallel loop` directive");
- case GenericLoopCombinedInfo::TargetTeamsLoop:
+ "not yet implemented: Combined `parallel loop` directive");
+ case GenericLoopCombinedInfo::TeamsLoop:
break;
}
@@ -99,7 +95,7 @@ class GenericLoopConversionPattern
if (!loopOp.getReductionVars().empty())
return todo("reduction");
- // TODO For `target teams loop`, check similar constrains to what is checked
+ // TODO For `teams loop`, check similar constrains to what is checked
// by `TeamsLoopChecker` in SemaOpenMP.cpp.
return mlir::success();
}
@@ -111,13 +107,11 @@ class GenericLoopConversionPattern
GenericLoopCombinedInfo result = GenericLoopCombinedInfo::Standalone;
if (auto teamsOp = mlir::dyn_cast_if_present<mlir::omp::TeamsOp>(parentOp))
- if (mlir::isa_and_present<mlir::omp::TargetOp>(teamsOp->getParentOp()))
- result = GenericLoopCombinedInfo::TargetTeamsLoop;
+ result = GenericLoopCombinedInfo::TeamsLoop;
if (auto parallelOp =
mlir::dyn_cast_if_present<mlir::omp::ParallelOp>(parentOp))
- if (mlir::isa_and_present<mlir::omp::TargetOp>(parallelOp->getParentOp()))
- result = GenericLoopCombinedInfo::TargetParallelLoop;
+ result = GenericLoopCombinedInfo::ParallelLoop;
return result;
}
diff --git a/flang/test/Transforms/generic-loop-rewriting-todo.mlir b/flang/test/Transforms/generic-loop-rewriting-todo.mlir
index becd6b8dcb5cb4..3259ceca70d50d 100644
--- a/flang/test/Transforms/generic-loop-rewriting-todo.mlir
+++ b/flang/test/Transforms/generic-loop-rewriting-todo.mlir
@@ -6,7 +6,7 @@ func.func @_QPtarget_parallel_loop() {
%c0 = arith.constant 0 : i32
%c10 = arith.constant 10 : i32
%c1 = arith.constant 1 : i32
- // expected-error at below {{not yet implemented: Combined `omp target parallel loop` directive}}
+ // expected-error at below {{not yet implemented: Combined `parallel loop` directive}}
omp.loop {
omp.loop_nest (%arg3) : i32 = (%c0) to (%c10) inclusive step (%c1) {
omp.yield
More information about the flang-commits
mailing list