Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ struct IfClauseOps {
Value ifVar;
};

struct InclusiveClauseOps {
llvm::SmallVector<Value> inclusiveVars;
};

struct ExclusiveClauseOps {
llvm::SmallVector<Value> exclusiveVars;
};
struct InReductionClauseOps {
llvm::SmallVector<Value> inReductionVars;
llvm::SmallVector<bool> inReductionByref;
Expand Down Expand Up @@ -261,6 +268,8 @@ using LoopNestOperands = detail::Clauses<LoopRelatedOps>;

using MaskedOperands = detail::Clauses<FilterClauseOps>;

using ScanOperands = detail::Clauses<InclusiveClauseOps, ExclusiveClauseOps>;

using OrderedOperands = detail::Clauses<DoacrossClauseOps>;

using OrderedRegionOperands = detail::Clauses<ParallelizationLevelClauseOps>;
Expand Down
55 changes: 55 additions & 0 deletions mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,61 @@ class OpenMP_IsDevicePtrClauseSkip<

def OpenMP_IsDevicePtrClause : OpenMP_IsDevicePtrClauseSkip<>;

//===----------------------------------------------------------------------===//
// V5.2: [5.4.7] `inclusive` clause
//===----------------------------------------------------------------------===//

class OpenMP_InclusiveClauseSkip<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Move definitions for these new clauses to keep alphabetical sorting in the file.

bit traits = false, bit arguments = false, bit assemblyFormat = false,
bit description = false, bit extraClassDeclaration = false
> : OpenMP_Clause</*isRequired=*/false, traits, arguments, assemblyFormat,
description, extraClassDeclaration> {
let arguments = (ins
Variadic<AnyType>:$inclusive_vars
);

let assemblyFormat = [{
`inclusive` `(` $inclusive_vars `:` type($inclusive_vars) `)`
}];

let description = [{
The inclusive clause is used on a separating directive that separates a
structured block into two structured block sequences. If the inclusive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
structured block into two structured block sequences. If the inclusive
structured block into two structured block sequences. If it

clause is specified, the input phase includes the preceding structured block
sequence and the scan phase includes the following structured block sequence.
}];
}

def OpenMP_InclusiveClause : OpenMP_InclusiveClauseSkip<>;

//===----------------------------------------------------------------------===//
// V5.2: [5.4.7] `exclusive` clause
//===----------------------------------------------------------------------===//

class OpenMP_ExclusiveClauseSkip<
bit traits = false, bit arguments = false, bit assemblyFormat = false,
bit description = false, bit extraClassDeclaration = false
> : OpenMP_Clause</*isRequired=*/false, traits, arguments, assemblyFormat,
description, extraClassDeclaration> {
let arguments = (ins
Variadic<AnyType>:$exclusive_vars
);

let assemblyFormat = [{
`exclusive` `(` $exclusive_vars `:` type($exclusive_vars) `)`
}];

let description = [{
The exclusive clause is used on a separating directive that separates a
structured block into two structured block sequences. If the exclusive clause
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
structured block into two structured block sequences. If the exclusive clause
structured block into two structured block sequences. If it

is specified, the input phase excludes the preceding structured block
sequence and instead includes the following structured block sequence,
while the scan phase includes the preceding structured block sequence.
}];
}

def OpenMP_ExclusiveClause : OpenMP_ExclusiveClauseSkip<>;

//===----------------------------------------------------------------------===//
// V5.2: [5.4.6] `linear` clause
//===----------------------------------------------------------------------===//
Expand Down
14 changes: 14 additions & 0 deletions mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,20 @@ def OrderedRegionOp : OpenMP_Op<"ordered.region", clauses = [
let hasVerifier = 1;
}

def ScanOp : OpenMP_Op<"scan", traits = [
AttrSizedOperandSegments
], clauses = [OpenMP_InclusiveClause, OpenMP_ExclusiveClause]> {
let summary = "scan construct with the region";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be "scan directive"?

let description = [{
The scan without region is a stand-alone directive that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the description is not complete.

}] # clausesDescription;

let builders = [
OpBuilder<(ins CArg<"const ScanOperands &">:$clauses)>
];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

}

//===----------------------------------------------------------------------===//
// 2.17.5 taskwait Construct
//===----------------------------------------------------------------------===//
Expand Down
9 changes: 9 additions & 0 deletions mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,15 @@ LogicalResult PrivateClauseOp::verify() {
return success();
}

//===----------------------------------------------------------------------===//
// Spec 5.2: Scan construct (5.6)
//===----------------------------------------------------------------------===//

void ScanOp::build(OpBuilder &builder, OperationState &state,
const ScanOperands &clauses) {
ScanOp::build(builder, state, clauses.inclusiveVars, clauses.exclusiveVars);
}

//===----------------------------------------------------------------------===//
// Spec 5.2: Masked construct (10.5)
//===----------------------------------------------------------------------===//
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Dialect/OpenMP/ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ func.func @omp_masked(%filtered_thread_id : i32) -> () {
return
}

func.func @omp_scan(%arg0 : memref<i32>) -> () {
// CHECK: omp.scan inclusive(%{{.*}} : memref<i32>)
omp.scan inclusive(%arg0 : memref<i32>)
// CHECK: omp.scan exclusive(%{{.*}} : memref<i32>)
omp.scan exclusive(%arg0 : memref<i32>)
return
}

func.func @omp_taskwait() -> () {
// CHECK: omp.taskwait
omp.taskwait
Expand Down