[flang-commits] [flang] b3b4696 - [MLIR][OpenMP] NFC: Sort clauses alphabetically (1/2) (#101193)
via flang-commits
flang-commits at lists.llvm.org
Wed Jul 31 02:40:17 PDT 2024
Author: Sergio Afonso
Date: 2024-07-31T10:40:11+01:00
New Revision: b3b46963b772fcbc80cb2df0b7389c09830cf166
URL: https://github.com/llvm/llvm-project/commit/b3b46963b772fcbc80cb2df0b7389c09830cf166
DIFF: https://github.com/llvm/llvm-project/commit/b3b46963b772fcbc80cb2df0b7389c09830cf166.diff
LOG: [MLIR][OpenMP] NFC: Sort clauses alphabetically (1/2) (#101193)
This patch sorts the clause lists for the following OpenMP operations:
- omp.parallel
- omp.teams
- omp.sections
- omp.wsloop
- omp.distribute
- omp.task
This change results in the reordering of operation arguments, so
impacted unit tests are updated accordingly.
Added:
Modified:
flang/test/Lower/OpenMP/task.f90
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
mlir/test/Dialect/OpenMP/invalid.mlir
mlir/test/Dialect/OpenMP/ops.mlir
Removed:
################################################################################
diff --git a/flang/test/Lower/OpenMP/task.f90 b/flang/test/Lower/OpenMP/task.f90
index 71ff57cd8fa54..afbe2cbfa746e 100644
--- a/flang/test/Lower/OpenMP/task.f90
+++ b/flang/test/Lower/OpenMP/task.f90
@@ -227,7 +227,7 @@ subroutine task_multiple_clauses()
integer :: x, y, z
logical :: buzz
- !CHECK: omp.task if(%{{.+}}) final(%{{.+}}) priority(%{{.+}}) allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) {
+ !CHECK: omp.task allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) final(%{{.+}}) if(%{{.+}}) priority(%{{.+}}) {
!$omp task if(buzz) final(buzz) priority(z) allocate(omp_high_bw_mem_alloc: x) private(x) firstprivate(y)
!CHECK: %[[X_PRIV_ALLOCA:.+]] = fir.alloca i32 {bindc_name = "x", pinned, uniq_name = "_QFtask_multiple_clausesEx"}
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 16b6f624ce042..7d07e47582afc 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -132,13 +132,12 @@ def ParallelOp : OpenMP_Op<"parallel", traits = [
DeclareOpInterfaceMethods<OutlineableOpenMPOpInterface>,
RecursiveMemoryEffects
], clauses = [
- // TODO: Sort clauses alphabetically.
+ OpenMP_AllocateClauseSkip<assemblyFormat = true>,
OpenMP_IfClauseSkip<assemblyFormat = true>,
OpenMP_NumThreadsClauseSkip<assemblyFormat = true>,
- OpenMP_AllocateClauseSkip<assemblyFormat = true>,
- OpenMP_ReductionClauseSkip<assemblyFormat = true>,
+ OpenMP_PrivateClauseSkip<assemblyFormat = true>,
OpenMP_ProcBindClauseSkip<assemblyFormat = true>,
- OpenMP_PrivateClauseSkip<assemblyFormat = true>
+ OpenMP_ReductionClauseSkip<assemblyFormat = true>
], singleRegion = true> {
let summary = "parallel construct";
let description = [{
@@ -195,9 +194,8 @@ def TerminatorOp : OpenMP_Op<"terminator", [Terminator, Pure]> {
def TeamsOp : OpenMP_Op<"teams", traits = [
AttrSizedOperandSegments, RecursiveMemoryEffects
], clauses = [
- // TODO: Sort clauses alphabetically.
- OpenMP_NumTeamsClause, OpenMP_IfClause, OpenMP_ThreadLimitClause,
- OpenMP_AllocateClause, OpenMP_ReductionClause, OpenMP_PrivateClause
+ OpenMP_AllocateClause, OpenMP_IfClause, OpenMP_NumTeamsClause,
+ OpenMP_PrivateClause, OpenMP_ReductionClause, OpenMP_ThreadLimitClause
], singleRegion = true> {
let summary = "teams construct";
let description = [{
@@ -237,9 +235,8 @@ def SectionOp : OpenMP_Op<"section", [HasParent<"SectionsOp">],
def SectionsOp : OpenMP_Op<"sections", traits = [
AttrSizedOperandSegments
], clauses = [
- // TODO: Sort clauses alphabetically.
- OpenMP_ReductionClause, OpenMP_AllocateClause, OpenMP_NowaitClause,
- OpenMP_PrivateClause
+ OpenMP_AllocateClause, OpenMP_NowaitClause, OpenMP_PrivateClause,
+ OpenMP_ReductionClause
], singleRegion = true> {
let summary = "sections construct";
let description = [{
@@ -362,15 +359,14 @@ def WsloopOp : OpenMP_Op<"wsloop", traits = [
AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopWrapperInterface>,
RecursiveMemoryEffects, SingleBlock
], clauses = [
- // TODO: Sort clauses alphabetically.
+ OpenMP_AllocateClauseSkip<assemblyFormat = true>,
OpenMP_LinearClauseSkip<assemblyFormat = true>,
- OpenMP_ReductionClauseSkip<assemblyFormat = true>,
- OpenMP_ScheduleClauseSkip<assemblyFormat = true>,
OpenMP_NowaitClauseSkip<assemblyFormat = true>,
- OpenMP_OrderedClauseSkip<assemblyFormat = true>,
OpenMP_OrderClauseSkip<assemblyFormat = true>,
- OpenMP_AllocateClauseSkip<assemblyFormat = true>,
- OpenMP_PrivateClauseSkip<assemblyFormat = true>
+ OpenMP_OrderedClauseSkip<assemblyFormat = true>,
+ OpenMP_PrivateClauseSkip<assemblyFormat = true>,
+ OpenMP_ReductionClauseSkip<assemblyFormat = true>,
+ OpenMP_ScheduleClauseSkip<assemblyFormat = true>
], singleRegion = true> {
let summary = "worksharing-loop construct";
let description = [{
@@ -506,8 +502,7 @@ def DistributeOp : OpenMP_Op<"distribute", traits = [
AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopWrapperInterface>,
RecursiveMemoryEffects, SingleBlock
], clauses = [
- // TODO: Sort clauses alphabetically.
- OpenMP_DistScheduleClause, OpenMP_AllocateClause, OpenMP_OrderClause,
+ OpenMP_AllocateClause, OpenMP_DistScheduleClause, OpenMP_OrderClause,
OpenMP_PrivateClause
], singleRegion = true> {
let summary = "distribute construct";
@@ -560,11 +555,9 @@ def TaskOp : OpenMP_Op<"task", traits = [
OutlineableOpenMPOpInterface
], clauses = [
// TODO: Complete clause list (affinity, detach).
- // TODO: Sort clauses alphabetically.
- OpenMP_IfClause, OpenMP_FinalClause, OpenMP_UntiedClause,
- OpenMP_MergeableClause, OpenMP_InReductionClause,
- OpenMP_PriorityClause, OpenMP_DependClause, OpenMP_AllocateClause,
- OpenMP_PrivateClause
+ OpenMP_AllocateClause, OpenMP_DependClause, OpenMP_FinalClause,
+ OpenMP_IfClause, OpenMP_InReductionClause, OpenMP_MergeableClause,
+ OpenMP_PriorityClause, OpenMP_PrivateClause, OpenMP_UntiedClause
], singleRegion = true> {
let summary = "task construct";
let description = [{
diff --git a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
index 169171ab799b7..6d250237e0a33 100644
--- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
+++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
@@ -444,16 +444,16 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
// Create the parallel wrapper.
auto ompParallel = rewriter.create<omp::ParallelOp>(
loc,
- /* if_expr = */ Value{},
- /* num_threads = */ numThreadsVar,
/* allocate_vars = */ llvm::SmallVector<Value>{},
/* allocator_vars = */ llvm::SmallVector<Value>{},
+ /* if_expr = */ Value{},
+ /* num_threads = */ numThreadsVar,
+ /* private_vars = */ ValueRange(),
+ /* private_syms = */ nullptr,
+ /* proc_bind_kind = */ omp::ClauseProcBindKindAttr{},
/* reduction_vars = */ llvm::SmallVector<Value>{},
/* reduction_byref = */ DenseBoolArrayAttr{},
- /* reduction_syms = */ ArrayAttr{},
- /* proc_bind_kind = */ omp::ClauseProcBindKindAttr{},
- /* private_vars = */ ValueRange(),
- /* private_syms = */ nullptr);
+ /* reduction_syms = */ ArrayAttr{});
{
OpBuilder::InsertionGuard guard(rewriter);
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 51e9dbe8c801d..ee6b3306815ee 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -1475,12 +1475,12 @@ LogicalResult TargetOp::verify() {
void ParallelOp::build(OpBuilder &builder, OperationState &state,
ArrayRef<NamedAttribute> attributes) {
- ParallelOp::build(
- builder, state, /*if_expr=*/nullptr, /*num_threads=*/nullptr,
- /*allocate_vars=*/ValueRange(), /*allocator_vars=*/ValueRange(),
- /*reduction_vars=*/ValueRange(), /*reduction_byref=*/nullptr,
- /*reduction_syms=*/nullptr, /*proc_bind_kind=*/nullptr,
- /*private_vars=*/ValueRange(), /*private_syms=*/nullptr);
+ ParallelOp::build(builder, state, /*allocate_vars=*/ValueRange(),
+ /*allocator_vars=*/ValueRange(), /*if_expr=*/nullptr,
+ /*num_threads=*/nullptr, /*private_vars=*/ValueRange(),
+ /*private_syms=*/nullptr, /*proc_bind_kind=*/nullptr,
+ /*reduction_vars=*/ValueRange(),
+ /*reduction_byref=*/nullptr, /*reduction_syms=*/nullptr);
state.addAttributes(attributes);
}
@@ -1488,12 +1488,12 @@ void ParallelOp::build(OpBuilder &builder, OperationState &state,
const ParallelOperands &clauses) {
MLIRContext *ctx = builder.getContext();
- ParallelOp::build(
- builder, state, clauses.ifVar, clauses.numThreads, clauses.allocateVars,
- clauses.allocatorVars, clauses.reductionVars,
- makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
- makeArrayAttr(ctx, clauses.reductionSyms), clauses.procBindKind,
- clauses.privateVars, makeArrayAttr(ctx, clauses.privateSyms));
+ ParallelOp::build(builder, state, clauses.allocateVars, clauses.allocatorVars,
+ clauses.ifVar, clauses.numThreads, clauses.privateVars,
+ makeArrayAttr(ctx, clauses.privateSyms),
+ clauses.procBindKind, clauses.reductionVars,
+ makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
+ makeArrayAttr(ctx, clauses.reductionSyms));
}
template <typename OpType>
@@ -1582,12 +1582,13 @@ void TeamsOp::build(OpBuilder &builder, OperationState &state,
const TeamsOperands &clauses) {
MLIRContext *ctx = builder.getContext();
// TODO Store clauses in op: privateVars, privateSyms.
- TeamsOp::build(builder, state, clauses.numTeamsLower, clauses.numTeamsUpper,
- clauses.ifVar, clauses.threadLimit, clauses.allocateVars,
- clauses.allocatorVars, clauses.reductionVars,
+ TeamsOp::build(builder, state, clauses.allocateVars, clauses.allocatorVars,
+ clauses.ifVar, clauses.numTeamsLower, clauses.numTeamsUpper,
+ /*private_vars=*/{},
+ /*private_syms=*/nullptr, clauses.reductionVars,
makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
- makeArrayAttr(ctx, clauses.reductionSyms), /*private_vars=*/{},
- /*private_syms=*/nullptr);
+ makeArrayAttr(ctx, clauses.reductionSyms),
+ clauses.threadLimit);
}
LogicalResult TeamsOp::verify() {
@@ -1630,11 +1631,11 @@ void SectionsOp::build(OpBuilder &builder, OperationState &state,
const SectionsOperands &clauses) {
MLIRContext *ctx = builder.getContext();
// TODO Store clauses in op: privateVars, privateSyms.
- SectionsOp::build(builder, state, clauses.reductionVars,
+ SectionsOp::build(builder, state, clauses.allocateVars, clauses.allocatorVars,
+ clauses.nowait, /*private_vars=*/{},
+ /*private_syms=*/nullptr, clauses.reductionVars,
makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
- makeArrayAttr(ctx, clauses.reductionSyms),
- clauses.allocateVars, clauses.allocatorVars, clauses.nowait,
- /*private_vars=*/{}, /*private_syms=*/nullptr);
+ makeArrayAttr(ctx, clauses.reductionSyms));
}
LogicalResult SectionsOp::verify() {
@@ -1715,14 +1716,14 @@ void printWsloop(OpAsmPrinter &p, Operation *op, Region ®ion,
void WsloopOp::build(OpBuilder &builder, OperationState &state,
ArrayRef<NamedAttribute> attributes) {
- build(builder, state, /*linear_vars=*/ValueRange(),
- /*linear_step_vars=*/ValueRange(), /*reduction_vars=*/ValueRange(),
- /*reduction_byref=*/nullptr, /*reduction_syms=*/nullptr,
- /*schedule_kind=*/nullptr, /*schedule_chunk=*/nullptr,
- /*schedule_mod=*/nullptr, /*schedule_simd=*/false, /*nowait=*/false,
- /*ordered=*/nullptr, /*order=*/nullptr, /*order_mod=*/nullptr,
- /*allocate_vars=*/{}, /*allocator_vars=*/{}, /*private_vars=*/{},
- /*private_syms=*/nullptr);
+ build(builder, state, /*allocate_vars=*/{}, /*allocator_vars=*/{},
+ /*linear_vars=*/ValueRange(), /*linear_step_vars=*/ValueRange(),
+ /*nowait=*/false, /*order=*/nullptr, /*order_mod=*/nullptr,
+ /*ordered=*/nullptr, /*private_vars=*/{}, /*private_syms=*/nullptr,
+ /*reduction_vars=*/ValueRange(), /*reduction_byref=*/nullptr,
+ /*reduction_syms=*/nullptr, /*schedule_kind=*/nullptr,
+ /*schedule_chunk=*/nullptr, /*schedule_mod=*/nullptr,
+ /*schedule_simd=*/false);
state.addAttributes(attributes);
}
@@ -1731,15 +1732,15 @@ void WsloopOp::build(OpBuilder &builder, OperationState &state,
MLIRContext *ctx = builder.getContext();
// TODO: Store clauses in op: allocateVars, allocatorVars, privateVars,
// privateSyms.
- WsloopOp::build(builder, state, clauses.linearVars, clauses.linearStepVars,
- clauses.reductionVars,
- makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
- makeArrayAttr(ctx, clauses.reductionSyms),
- clauses.scheduleKind, clauses.scheduleChunk,
- clauses.scheduleMod, clauses.scheduleSimd, clauses.nowait,
- clauses.ordered, clauses.order, clauses.orderMod,
- /*allocate_vars=*/{}, /*allocator_vars=*/{},
- /*private_vars=*/{}, /*private_syms=*/nullptr);
+ WsloopOp::build(
+ builder, state,
+ /*allocate_vars=*/{}, /*allocator_vars=*/{}, clauses.linearVars,
+ clauses.linearStepVars, clauses.nowait, clauses.order, clauses.orderMod,
+ clauses.ordered, /*private_vars=*/{}, /*private_syms=*/nullptr,
+ clauses.reductionVars,
+ makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
+ makeArrayAttr(ctx, clauses.reductionSyms), clauses.scheduleKind,
+ clauses.scheduleChunk, clauses.scheduleMod, clauses.scheduleSimd);
}
LogicalResult WsloopOp::verify() {
@@ -1804,10 +1805,10 @@ LogicalResult SimdOp::verify() {
void DistributeOp::build(OpBuilder &builder, OperationState &state,
const DistributeOperands &clauses) {
// TODO Store clauses in op: privateVars, privateSyms.
- DistributeOp::build(builder, state, clauses.distScheduleStatic,
- clauses.distScheduleChunkSize, clauses.allocateVars,
- clauses.allocatorVars, clauses.order, clauses.orderMod,
- /*private_vars=*/{}, /*private_syms=*/nullptr);
+ DistributeOp::build(
+ builder, state, clauses.allocateVars, clauses.allocatorVars,
+ clauses.distScheduleStatic, clauses.distScheduleChunkSize, clauses.order,
+ clauses.orderMod, /*private_vars=*/{}, /*private_syms=*/nullptr);
}
LogicalResult DistributeOp::verify() {
@@ -1934,13 +1935,13 @@ void TaskOp::build(OpBuilder &builder, OperationState &state,
const TaskOperands &clauses) {
MLIRContext *ctx = builder.getContext();
// TODO Store clauses in op: privateVars, privateSyms.
- TaskOp::build(builder, state, clauses.ifVar, clauses.final, clauses.untied,
- clauses.mergeable, clauses.inReductionVars,
- makeDenseBoolArrayAttr(ctx, clauses.inReductionByref),
- makeArrayAttr(ctx, clauses.inReductionSyms), clauses.priority,
+ TaskOp::build(builder, state, clauses.allocateVars, clauses.allocatorVars,
makeArrayAttr(ctx, clauses.dependKinds), clauses.dependVars,
- clauses.allocateVars, clauses.allocatorVars,
- /*private_vars=*/{}, /*private_syms=*/nullptr);
+ clauses.final, clauses.ifVar, clauses.inReductionVars,
+ makeDenseBoolArrayAttr(ctx, clauses.inReductionByref),
+ makeArrayAttr(ctx, clauses.inReductionSyms), clauses.mergeable,
+ clauses.priority, /*private_vars=*/{}, /*private_syms=*/nullptr,
+ clauses.untied);
}
LogicalResult TaskOp::verify() {
diff --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir
index 28542587fb9bb..abbd80b709ca1 100644
--- a/mlir/test/Dialect/OpenMP/invalid.mlir
+++ b/mlir/test/Dialect/OpenMP/invalid.mlir
@@ -1394,7 +1394,7 @@ func.func @omp_teams_allocate(%data_var : memref<i32>) {
// expected-error @below {{expected equal sizes for allocate and allocator variables}}
"omp.teams" (%data_var) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 0,0,0,0,1,0,0,0>} : (memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 1,0,0,0,0,0,0,0>} : (memref<i32>) -> ()
omp.terminator
}
return
@@ -1407,7 +1407,7 @@ func.func @omp_teams_num_teams1(%lb : i32) {
// expected-error @below {{expected num_teams upper bound to be defined if the lower bound is defined}}
"omp.teams" (%lb) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,0,0,0,0,0,0,0>} : (i32) -> ()
+ }) {operandSegmentSizes = array<i32: 0,0,0,1,0,0,0,0>} : (i32) -> ()
omp.terminator
}
return
@@ -1432,7 +1432,7 @@ func.func @omp_sections(%data_var : memref<i32>) -> () {
// expected-error @below {{expected equal sizes for allocate and allocator variables}}
"omp.sections" (%data_var) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 0,1,0,0>} : (memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 1,0,0,0>} : (memref<i32>) -> ()
return
}
@@ -1442,7 +1442,7 @@ func.func @omp_sections(%data_var : memref<i32>) -> () {
// expected-error @below {{expected as many reduction symbol references as reduction variables}}
"omp.sections" (%data_var) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,0,0,0>} : (memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 0,0,0,1>} : (memref<i32>) -> ()
return
}
@@ -1623,7 +1623,7 @@ func.func @omp_task_depend(%data_var: memref<i32>) {
// expected-error @below {{op expected as many depend values as depend variables}}
"omp.task"(%data_var) ({
"omp.terminator"() : () -> ()
- }) {depend_kinds = [], operandSegmentSizes = array<i32: 0, 0, 0, 0, 1, 0, 0, 0>} : (memref<i32>) -> ()
+ }) {depend_kinds = [], operandSegmentSizes = array<i32: 0, 0, 1, 0, 0, 0, 0, 0>} : (memref<i32>) -> ()
"func.return"() : () -> ()
}
@@ -2137,7 +2137,7 @@ func.func @omp_target_depend(%data_var: memref<i32>) {
func.func @omp_distribute_schedule(%chunk_size : i32) -> () {
// expected-error @below {{op chunk size set without dist_schedule_static being present}}
- "omp.distribute"(%chunk_size) <{operandSegmentSizes = array<i32: 1, 0, 0, 0>}> ({
+ "omp.distribute"(%chunk_size) <{operandSegmentSizes = array<i32: 0, 0, 1, 0>}> ({
"omp.terminator"() : () -> ()
}) : (i32) -> ()
}
@@ -2146,7 +2146,7 @@ func.func @omp_distribute_schedule(%chunk_size : i32) -> () {
func.func @omp_distribute_allocate(%data_var : memref<i32>) -> () {
// expected-error @below {{expected equal sizes for allocate and allocator variables}}
- "omp.distribute"(%data_var) <{operandSegmentSizes = array<i32: 0, 1, 0, 0>}> ({
+ "omp.distribute"(%data_var) <{operandSegmentSizes = array<i32: 1, 0, 0, 0>}> ({
"omp.terminator"() : () -> ()
}) : (memref<i32>) -> ()
}
@@ -2340,7 +2340,7 @@ func.func @undefined_privatizer(%arg0: index) {
// -----
func.func @undefined_privatizer(%arg0: !llvm.ptr) {
// expected-error @below {{inconsistent number of private variables and privatizer op symbols, private vars: 1 vs. privatizer op symbols: 2}}
- "omp.parallel"(%arg0) <{operandSegmentSizes = array<i32: 0, 0, 0, 0, 0, 1>, private_syms = [@x.privatizer, @y.privatizer]}> ({
+ "omp.parallel"(%arg0) <{operandSegmentSizes = array<i32: 0, 0, 0, 0, 1, 0>, private_syms = [@x.privatizer, @y.privatizer]}> ({
^bb0(%arg2: !llvm.ptr):
omp.terminator
}) : (!llvm.ptr) -> ()
diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index 057d54c0c2f7c..dc291bc0444de 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -67,37 +67,37 @@ func.func @omp_terminator() -> () {
func.func @omp_parallel(%data_var : memref<i32>, %if_cond : i1, %num_threads : i32, %idx : index) -> () {
// CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : i32) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
- "omp.parallel" (%if_cond, %num_threads, %data_var, %data_var) ({
+ "omp.parallel" (%data_var, %data_var, %if_cond, %num_threads) ({
// test without if condition
// CHECK: omp.parallel num_threads(%{{.*}} : i32) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
- "omp.parallel"(%num_threads, %data_var, %data_var) ({
+ "omp.parallel"(%data_var, %data_var, %num_threads) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 0,1,1,1,0,0>} : (i32, memref<i32>, memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 1,1,0,1,0,0>} : (memref<i32>, memref<i32>, i32) -> ()
// CHECK: omp.barrier
omp.barrier
// test without num_threads
// CHECK: omp.parallel if(%{{.*}}) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
- "omp.parallel"(%if_cond, %data_var, %data_var) ({
+ "omp.parallel"(%data_var, %data_var, %if_cond) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,0,1,1,0,0>} : (i1, memref<i32>, memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 1,1,1,0,0,0>} : (memref<i32>, memref<i32>, i1) -> ()
// test without allocate
// CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : i32)
"omp.parallel"(%if_cond, %num_threads) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,1,0,0,0,0>} : (i1, i32) -> ()
+ }) {operandSegmentSizes = array<i32: 0,0,1,1,0,0>} : (i1, i32) -> ()
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,1,1,1,0,0>, proc_bind_kind = #omp<procbindkind spread>} : (i1, i32, memref<i32>, memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 1,1,1,1,0,0>, proc_bind_kind = #omp<procbindkind spread>} : (memref<i32>, memref<i32>, i1, i32) -> ()
// test with multiple parameters for single variadic argument
// CHECK: omp.parallel allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
"omp.parallel" (%data_var, %data_var) ({
omp.terminator
- }) {operandSegmentSizes = array<i32: 0,0,1,1,0,0>} : (memref<i32>, memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 1,1,0,0,0,0>} : (memref<i32>, memref<i32>) -> ()
// CHECK: omp.distribute
omp.distribute {
@@ -392,7 +392,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
omp.yield
}
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,1,0,0,0,0,0>, schedule_kind = #omp<schedulekind static>} :
+ }) {operandSegmentSizes = array<i32: 0,0,1,1,0,0,0>, schedule_kind = #omp<schedulekind static>} :
(memref<i32>, i32) -> ()
// CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref<i32>, %{{.*}} = %{{.*}} : memref<i32>) schedule(static) {
@@ -402,7 +402,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
omp.yield
}
omp.terminator
- }) {operandSegmentSizes = array<i32: 2,2,0,0,0,0,0>, schedule_kind = #omp<schedulekind static>} :
+ }) {operandSegmentSizes = array<i32: 0,0,2,2,0,0,0>, schedule_kind = #omp<schedulekind static>} :
(memref<i32>, memref<i32>, i32, i32) -> ()
// CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}}) ordered(2) {
@@ -412,7 +412,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
omp.yield
}
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,1,0,1,0,0,0>, schedule_kind = #omp<schedulekind dynamic>, ordered = 2} :
+ }) {operandSegmentSizes = array<i32: 0,0,1,1,0,0,1>, schedule_kind = #omp<schedulekind dynamic>, ordered = 2} :
(memref<i32>, i32, i32) -> ()
// CHECK: omp.wsloop schedule(auto) nowait {
@@ -1874,13 +1874,13 @@ func.func @omp_sectionsop(%data_var1 : memref<i32>, %data_var2 : memref<i32>,
"omp.sections" (%data_var1, %data_var1) ({
// CHECK: omp.terminator
omp.terminator
- }) {operandSegmentSizes = array<i32: 0,1,1,0>} : (memref<i32>, memref<i32>) -> ()
+ }) {operandSegmentSizes = array<i32: 1,1,0,0>} : (memref<i32>, memref<i32>) -> ()
// CHECK: omp.sections reduction(@add_f32 -> %{{.*}} : !llvm.ptr)
"omp.sections" (%redn_var) ({
// CHECK: omp.terminator
omp.terminator
- }) {operandSegmentSizes = array<i32: 1,0,0,0>, reduction_byref = array<i1: false>, reduction_syms=[@add_f32]} : (!llvm.ptr) -> ()
+ }) {operandSegmentSizes = array<i32: 0,0,0,1>, reduction_byref = array<i1: false>, reduction_syms=[@add_f32]} : (!llvm.ptr) -> ()
// CHECK: omp.sections nowait {
omp.sections nowait {
@@ -2098,14 +2098,14 @@ func.func @omp_task(%bool_var: i1, %i64_var: i64, %i32_var: i32, %data_var: memr
}
// Checking multiple clauses
- // CHECK: omp.task if(%[[bool_var]]) final(%[[bool_var]]) untied
- omp.task if(%bool_var) final(%bool_var) untied
+ // CHECK: omp.task allocate(%[[data_var]] : memref<i32> -> %[[data_var]] : memref<i32>)
+ omp.task allocate(%data_var : memref<i32> -> %data_var : memref<i32>)
+ // CHECK-SAME: final(%[[bool_var]]) if(%[[bool_var]])
+ final(%bool_var) if(%bool_var)
// CHECK-SAME: in_reduction(@add_f32 -> %[[redn_var1]] : !llvm.ptr, byref @add_f32 -> %[[redn_var2]] : !llvm.ptr)
in_reduction(@add_f32 -> %0 : !llvm.ptr, byref @add_f32 -> %1 : !llvm.ptr)
- // CHECK-SAME: priority(%[[i32_var]] : i32)
- priority(%i32_var : i32)
- // CHECK-SAME: allocate(%[[data_var]] : memref<i32> -> %[[data_var]] : memref<i32>)
- allocate(%data_var : memref<i32> -> %data_var : memref<i32>) {
+ // CHECK-SAME: priority(%[[i32_var]] : i32) untied
+ priority(%i32_var : i32) untied {
// CHECK: "test.foo"() : () -> ()
"test.foo"() : () -> ()
// CHECK: omp.terminator
More information about the flang-commits
mailing list