Skip to content

Commit 6169ebf

Browse files
committed
Adding masked operations to OpenMP Dialect
1 parent 2f2ea35 commit 6169ebf

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,4 +2149,45 @@ def DeclareReductionOp : OpenMP_Op<"declare_reduction", [Symbol,
21492149
let hasRegionVerifier = 1;
21502150
}
21512151

2152+
//===----------------------------------------------------------------------===//
2153+
// 2.19.5.4 reduction clause
2154+
//===----------------------------------------------------------------------===//
2155+
2156+
def ReductionOp : OpenMP_Op<"reduction"> {
2157+
let summary = "reduction construct";
2158+
let description = [{
2159+
Indicates the value that is produced by the current reduction-participating
2160+
entity for a reduction requested in some ancestor. The reduction is
2161+
identified by the accumulator, but the value of the accumulator may not be
2162+
updated immediately.
2163+
}];
2164+
2165+
let arguments= (ins AnyType:$operand, OpenMP_PointerLikeType:$accumulator);
2166+
let assemblyFormat = [{
2167+
$operand `,` $accumulator attr-dict `:` type($operand) `,` type($accumulator)
2168+
}];
2169+
let hasVerifier = 1;
2170+
}
2171+
2172+
//===----------------------------------------------------------------------===//
2173+
// [Spec 5.2] 10.5 masked Construct
2174+
//===----------------------------------------------------------------------===//
2175+
def MaskedOp : OpenMP_Op<"masked"> {
2176+
let summary = "masked construct";
2177+
let description = [{
2178+
Masked construct allows to specify a structured block to be executed by a subset of
2179+
threads of the current team. Filter clause allows to select the threads expected to
2180+
execute the region
2181+
}];
2182+
2183+
let arguments = (ins Optional<I32>:$filteredThreadId);
2184+
let regions = (region AnyRegion:$region);
2185+
2186+
let assemblyFormat = [{
2187+
oilist(
2188+
`filter` `(` $filteredThreadId `:` type($filteredThreadId) `)`
2189+
) $region attr-dict
2190+
}];
2191+
}
2192+
21522193
#endif // OPENMP_OPS

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ func.func @omp_master() -> () {
1616
return
1717
}
1818

19+
// CHECK-LABEL: omp_masked
20+
func.func @omp_masked(%filtered_thread_id : i32) -> () {
21+
22+
23+
// CHECK: omp.masked filter(%{{.*}} : i32)
24+
"omp.masked" (%filtered_thread_id) ({
25+
omp.terminator
26+
}) : (i32) -> ()
27+
28+
// CHECK: omp.masked
29+
"omp.masked" () ({
30+
omp.terminator
31+
}) : () -> ()
32+
return
33+
}
1934
func.func @omp_taskwait() -> () {
2035
// CHECK: omp.taskwait
2136
omp.taskwait

0 commit comments

Comments
 (0)