[Mlir-commits] [mlir] 163dbfe - [mlir][OpenMP] Add order clause definition to simd construct
Dominik Adamski
llvmlistbot at llvm.org
Fri Nov 18 04:11:16 PST 2022
Author: Dominik Adamski
Date: 2022-11-18T06:08:04-06:00
New Revision: 163dbfe869f550bd2d22520fda109876a1122eda
URL: https://github.com/llvm/llvm-project/commit/163dbfe869f550bd2d22520fda109876a1122eda
DIFF: https://github.com/llvm/llvm-project/commit/163dbfe869f550bd2d22520fda109876a1122eda.diff
LOG: [mlir][OpenMP] Add order clause definition to simd construct
Update simd construct definition and add mlir tests to prove
that order(concurrent) clause is correctly modeled for simd
construct.
Added:
Modified:
flang/lib/Lower/OpenMP.cpp
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/test/Dialect/OpenMP/invalid.mlir
mlir/test/Dialect/OpenMP/ops.mlir
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index d487fdf29b9fc..7abb7c967373f 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -1214,7 +1214,9 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
TypeRange resultType;
auto SimdLoopOp = firOpBuilder.create<mlir::omp::SimdLoopOp>(
currentLocation, resultType, lowerBound, upperBound, step, alignedVars,
- nullptr, ifClauseOperand, simdlenClauseOperand, safelenClauseOperand,
+ nullptr, ifClauseOperand,
+ orderClauseOperand.dyn_cast_or_null<omp::ClauseOrderKindAttr>(),
+ simdlenClauseOperand, safelenClauseOperand,
/*inclusive=*/firOpBuilder.getUnitAttr());
createBodyOfOp<omp::SimdLoopOp>(SimdLoopOp, converter, currentLocation,
eval, &loopOpClauseList, iv);
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 999e2bec5551a..dc23153fa76f6 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -393,6 +393,10 @@ def SimdLoopOp : OpenMP_Op<"simdloop", [AttrSizedOperandSegments,
iterations to be executed concurrently is one, regardless of whether
a simdlen clause is speciļ¬ed.
+ The optional `order` attribute specifies which order the iterations of the
+ associate loops are executed in. Currently the only option for this
+ attribute is "concurrent".
+
When a simdlen clause is present, the preferred number of iterations to be
executed concurrently is the value provided to the simdlen clause.
@@ -415,6 +419,7 @@ def SimdLoopOp : OpenMP_Op<"simdloop", [AttrSizedOperandSegments,
Variadic<OpenMP_PointerLikeType>:$aligned_vars,
OptionalAttr<I64ArrayAttr>:$alignment_values,
Optional<I1>:$if_expr,
+ OptionalAttr<OrderKindAttr>:$order_val,
ConfinedAttr<OptionalAttr<I64Attr>, [IntPositive]>:$simdlen,
ConfinedAttr<OptionalAttr<I64Attr>, [IntPositive]>:$safelen,
UnitAttr:$inclusive
@@ -426,6 +431,7 @@ def SimdLoopOp : OpenMP_Op<"simdloop", [AttrSizedOperandSegments,
custom<AlignedClause>($aligned_vars, type($aligned_vars),
$alignment_values) `)`
|`if` `(` $if_expr `)`
+ |`order` `(` custom<ClauseAttr>($order_val) `)`
|`simdlen` `(` $simdlen `)`
|`safelen` `(` $safelen `)`
) `for` custom<LoopControl>($region, $lowerBound, $upperBound, $step,
diff --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir
index e0097846db546..58d6a28c7a7e9 100644
--- a/mlir/test/Dialect/OpenMP/invalid.mlir
+++ b/mlir/test/Dialect/OpenMP/invalid.mlir
@@ -283,6 +283,16 @@ func.func @omp_simdloop_aligned_the_same_var(%arg0 : index, %arg1 : index,
// -----
+func.func @omp_simdloop_order_value(%lb : index, %ub : index, %step : index) {
+ // expected-error @below {{invalid clause value: 'default'}}
+ omp.simdloop order(default) for (%iv): index = (%lb) to (%ub) step (%step) {
+ omp.yield
+ }
+ return
+}
+
+// -----
+
func.func @omp_simdloop_pretty_simdlen(%lb : index, %ub : index, %step : index) -> () {
// expected-error @below {{op attribute 'simdlen' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive}}
omp.simdloop simdlen(0) for (%iv): index = (%lb) to (%ub) step (%step) {
diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index ba276047a742c..ae19cb844e1e4 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -398,6 +398,16 @@ func.func @omp_simdloop_pretty_if(%lb : index, %ub : index, %step : index, %if_c
return
}
+// CHECK-LABEL: omp_simdloop_pretty_order
+func.func @omp_simdloop_pretty_order(%lb : index, %ub : index, %step : index) -> () {
+ // CHECK: omp.simdloop order(concurrent)
+ // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
+ omp.simdloop order(concurrent) for (%iv): index = (%lb) to (%ub) step (%step) {
+ omp.yield
+ }
+ return
+}
+
// CHECK-LABEL: omp_simdloop_pretty_simdlen
func.func @omp_simdloop_pretty_simdlen(%lb : index, %ub : index, %step : index) -> () {
// CHECK: omp.simdloop simdlen(2) for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
More information about the Mlir-commits
mailing list