Skip to content

Commit 2a089ad

Browse files
committed
[MLIR][OpenMP] Clause-based OpenMP operation definition
This patch updates `OpenMP_Op` definitions to be based on the new set of `OpenMP_Clause` definitions, and to take advantage of clause-based automatically-generated argument lists, descriptions, assembly format and class declarations. There are also changes introduced to the clause operands structures to match the current set of tablegen clause definitions. These two are very closely linked and should be kept in sync. It would probably be a good idea to try generating clause operands structures from the tablegen `OpenMP_Clause` definitions in the future. As a result of this change, arguments for some operations have been reordered. This patch also addresses this by updating affected operation build calls and unit tests. Some other updates to tests related to the order of arguments in the resulting assembly format and others due to certain previous inconsistencies in the printing/parsing of clauses are addressed. The printer and parser functions for the `map` clause are updated, so that they are able to handle `map` clauses linked to entry block arguments as well as those which aren't. Printer and parser of reduction-related clauses are updated as well to add support for `byref` information to all operations, unifying the representation of reductions for all operations.
1 parent 1496299 commit 2a089ad

File tree

11 files changed

+463
-993
lines changed

11 files changed

+463
-993
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ struct AllocateClauseOps {
3939
llvm::SmallVector<Value> allocatorVars, allocateVars;
4040
};
4141

42+
struct CancelDirectiveNameClauseOps {
43+
ClauseCancellationConstructTypeAttr cancelDirectiveNameAttr;
44+
};
45+
4246
struct CollapseClauseOps {
4347
llvm::SmallVector<Value> loopLBVar, loopUBVar, loopStepVar;
4448
};
@@ -48,6 +52,10 @@ struct CopyprivateClauseOps {
4852
llvm::SmallVector<Attribute> copyprivateFuncs;
4953
};
5054

55+
struct CriticalNameClauseOps {
56+
StringAttr criticalNameAttr;
57+
};
58+
5159
struct DependClauseOps {
5260
llvm::SmallVector<Attribute> dependTypeAttrs;
5361
llvm::SmallVector<Value> dependVars;
@@ -84,6 +92,7 @@ struct GrainsizeClauseOps {
8492
struct HasDeviceAddrClauseOps {
8593
llvm::SmallVector<Value> hasDeviceAddrVars;
8694
};
95+
8796
struct HintClauseOps {
8897
IntegerAttr hintAttr;
8998
};
@@ -94,6 +103,7 @@ struct IfClauseOps {
94103

95104
struct InReductionClauseOps {
96105
llvm::SmallVector<Value> inReductionVars;
106+
llvm::SmallVector<bool> inReduceVarByRef;
97107
llvm::SmallVector<Attribute> inReductionDeclSymbols;
98108
};
99109

@@ -117,10 +127,6 @@ struct MergeableClauseOps {
117127
UnitAttr mergeableAttr;
118128
};
119129

120-
struct NameClauseOps {
121-
StringAttr nameAttr;
122-
};
123-
124130
struct NogroupClauseOps {
125131
UnitAttr nogroupAttr;
126132
};
@@ -198,6 +204,7 @@ struct SimdlenClauseOps {
198204

199205
struct TaskReductionClauseOps {
200206
llvm::SmallVector<Value> taskReductionVars;
207+
llvm::SmallVector<bool> taskReduceVarByRef;
201208
llvm::SmallVector<Attribute> taskReductionDeclSymbols;
202209
};
203210

@@ -209,8 +216,12 @@ struct UntiedClauseOps {
209216
UnitAttr untiedAttr;
210217
};
211218

212-
struct UseDeviceClauseOps {
213-
llvm::SmallVector<Value> useDevicePtrVars, useDeviceAddrVars;
219+
struct UseDeviceAddrClauseOps {
220+
llvm::SmallVector<Value> useDeviceAddrVars;
221+
};
222+
223+
struct UseDevicePtrClauseOps {
224+
llvm::SmallVector<Value> useDevicePtrVars;
214225
};
215226

216227
//===----------------------------------------------------------------------===//
@@ -225,7 +236,13 @@ template <typename... Mixins>
225236
struct Clauses : public Mixins... {};
226237
} // namespace detail
227238

228-
using CriticalClauseOps = detail::Clauses<HintClauseOps, NameClauseOps>;
239+
using CancelClauseOps =
240+
detail::Clauses<CancelDirectiveNameClauseOps, IfClauseOps>;
241+
242+
using CancellationPointClauseOps =
243+
detail::Clauses<CancelDirectiveNameClauseOps>;
244+
245+
using CriticalClauseOps = detail::Clauses<CriticalNameClauseOps, HintClauseOps>;
229246

230247
// TODO `indirect` clause.
231248
using DeclareTargetClauseOps = detail::Clauses<DeviceTypeClauseOps>;
@@ -264,10 +281,11 @@ using TargetClauseOps =
264281
detail::Clauses<AllocateClauseOps, DependClauseOps, DeviceClauseOps,
265282
HasDeviceAddrClauseOps, IfClauseOps, InReductionClauseOps,
266283
IsDevicePtrClauseOps, MapClauseOps, NowaitClauseOps,
267-
PrivateClauseOps, ReductionClauseOps, ThreadLimitClauseOps>;
284+
PrivateClauseOps, ThreadLimitClauseOps>;
268285

269-
using TargetDataClauseOps = detail::Clauses<DeviceClauseOps, IfClauseOps,
270-
MapClauseOps, UseDeviceClauseOps>;
286+
using TargetDataClauseOps =
287+
detail::Clauses<DeviceClauseOps, IfClauseOps, MapClauseOps,
288+
UseDeviceAddrClauseOps, UseDevicePtrClauseOps>;
271289

272290
using TargetEnterExitUpdateDataClauseOps =
273291
detail::Clauses<DependClauseOps, DeviceClauseOps, IfClauseOps, MapClauseOps,

0 commit comments

Comments
 (0)