Skip to content

Commit 00c9f3d

Browse files
committed
Add region to DeclMapperOp. Move map clause to new DeclMapperInfoOp.
1 parent 83b19a6 commit 00c9f3d

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def DistributeOp : OpenMP_Op<"distribute", traits = [
622622
will be executed in parallel by threads in the current context. These
623623
iterations are spread across threads that already exist in the enclosing
624624
region.
625-
625+
626626
The body region can only contain a single block which must contain a single
627627
operation. This operation must be another compatible loop wrapper or an
628628
`omp.loop_nest`.
@@ -1655,28 +1655,32 @@ def CancellationPointOp : OpenMP_Op<"cancellation_point", clauses = [
16551655
//===----------------------------------------------------------------------===//
16561656
// 2.19.7.3 Declare Mapper Directive
16571657
//===----------------------------------------------------------------------===//
1658-
def DeclareMapperOp : OpenMP_Op<"declare_mapper", traits = [
1659-
Symbol], clauses = [
1660-
OpenMP_MapClause
1661-
]> {
1658+
def DeclareMapperOp : OpenMP_Op<"declare_mapper", singleRegion = 1> {
16621659
let summary = "declare mapper directive";
16631660
let description = [{
16641661
The declare mapper directive declares a user-defined mapper for a given
16651662
type, and defines a mapper-identifier that can be used in a map clause.
16661663
}] # clausesDescription;
16671664

1668-
let arguments = !con((ins SymbolNameAttr:$sym_name,
1669-
OpenMP_PointerLikeType:$var_ptr,
1670-
TypeAttr:$var_type), clausesArgs);
1665+
let arguments = (ins SymbolNameAttr:$sym_name,
1666+
TypeAttr:$var_type);
1667+
1668+
let assemblyFormat = "$sym_name `:` $var_type $region attr-dict";
1669+
}
1670+
1671+
def DeclareMapperInfoOp : OpenMP_Op<"declare_mapper_info", clauses = [
1672+
OpenMP_MapClause
1673+
]> {
1674+
let summary = "declare mapper info";
1675+
let description = [{
1676+
This Op is used to capture the map information related to it's
1677+
parent DeclareMapperOp.]>
1678+
}] # clausesDescription;
16711679

16721680
let builders = [
1673-
OpBuilder<(ins CArg<"const DeclareMapperOperands &">:$clauses)>
1681+
OpBuilder<(ins CArg<"const DeclareMapperInfoOperands &">:$clauses)>
16741682
];
16751683

1676-
// Override clause-based assemblyFormat.
1677-
let assemblyFormat = "$sym_name `:` $var_ptr `:` type($var_ptr) `:` $var_type" # " oilist(" #
1678-
clausesOptAssemblyFormat # ") attr-dict";
1679-
16801684
let hasVerifier = 1;
16811685
}
16821686

@@ -1792,7 +1796,7 @@ def MaskedOp : OpenMP_Op<"masked", clauses = [
17921796
], singleRegion = 1> {
17931797
let summary = "masked construct";
17941798
let description = [{
1795-
Masked construct allows to specify a structured block to be executed by a subset of
1799+
Masked construct allows to specify a structured block to be executed by a subset of
17961800
threads of the current team.
17971801
}] # clausesDescription;
17981802

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,10 +2138,10 @@ LogicalResult DistributeOp::verifyRegions() {
21382138
}
21392139

21402140
//===----------------------------------------------------------------------===//
2141-
// DeclareMapperOp
2141+
// DeclareMapperInfoOp
21422142
//===----------------------------------------------------------------------===//
21432143

2144-
LogicalResult DeclareMapperOp::verify() {
2144+
LogicalResult DeclareMapperInfoOp::verify() {
21452145
return verifyMapClause(*this, getMapVars());
21462146
}
21472147

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -879,13 +879,15 @@ cleanup {
879879
omp.yield
880880
}
881881

882-
// CHECK: %[[DECL_VAR:.*]] = llvm.alloca %{{.*}}
883-
// CHECK: %[[DECL_MAP_INFO:.*]] = omp.map.info var_ptr(%[[DECL_VAR]] : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
884-
// CHECK: omp.declare_mapper @my_mapper : %[[DECL_VAR]] : !llvm.ptr : !llvm.struct<"my_type", (i32)> map_entries(%[[DECL_MAP_INFO]] : !llvm.ptr)
885-
%decl_c1 = arith.constant 1 : i64
886-
%decl_var = llvm.alloca %decl_c1 x !llvm.struct<"my_type", (i32)> : (i64) -> !llvm.ptr
887-
%decl_map_info = omp.map.info var_ptr(%decl_var : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
888-
omp.declare_mapper @my_mapper : %decl_var : !llvm.ptr : !llvm.struct<"my_type", (i32)> map_entries(%decl_map_info : !llvm.ptr)
882+
// CHECK: omp.declare_mapper @my_mapper : !llvm.struct<"my_type", (i32)>
883+
omp.declare_mapper @my_mapper : !llvm.struct<"my_type", (i32)> {
884+
^bb0(%arg: !llvm.ptr):
885+
// CHECK: %[[DECL_MAP_INFO:.*]] = omp.map.info var_ptr(%{{.*}} : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
886+
%decl_map_info = omp.map.info var_ptr(%arg : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
887+
// CHECK: omp.declare_mapper_info map_entries(%[[DECL_MAP_INFO]] : !llvm.ptr)
888+
omp.declare_mapper_info map_entries(%decl_map_info : !llvm.ptr)
889+
omp.terminator
890+
}
889891

890892
// CHECK-LABEL: func @wsloop_reduction
891893
func.func @wsloop_reduction(%lb : index, %ub : index, %step : index) {

0 commit comments

Comments
 (0)