aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib
diff options
context:
space:
mode:
authorSergio Afonso <safonsof@amd.com>2024-03-20 11:19:38 +0000
committerGitHub <noreply@github.com>2024-03-20 11:19:38 +0000
commitd84252e064b3f35aa879c10e207f77e931f351d9 (patch)
treebff1027cbd1ff3e4655052139a605346b7514c6e /mlir/lib
parentfe2119a7b08b6e468b2a67768904ea85b1bf0a45 (diff)
downloadllvm-d84252e064b3f35aa879c10e207f77e931f351d9.zip
llvm-d84252e064b3f35aa879c10e207f77e931f351d9.tar.gz
llvm-d84252e064b3f35aa879c10e207f77e931f351d9.tar.bz2
[MLIR][OpenMP] NFC: Uniformize OpenMP ops names (#85393)
This patch proposes the renaming of certain OpenMP dialect operations with the goal of improving readability and following a uniform naming convention for MLIR operations and associated classes. In particular, the following operations are renamed: - `omp.map_info` -> `omp.map.info` - `omp.target_update_data` -> `omp.target_update` - `omp.ordered_region` -> `omp.ordered.region` - `omp.cancellationpoint` -> `omp.cancellation_point` - `omp.bounds` -> `omp.map.bounds` - `omp.reduction.declare` -> `omp.declare_reduction` Also, the following MLIR operation classes have been renamed: - `omp::TaskLoopOp` -> `omp::TaskloopOp` - `omp::TaskGroupOp` -> `omp::TaskgroupOp` - `omp::DataBoundsOp` -> `omp::MapBoundsOp` - `omp::DataOp` -> `omp::TargetDataOp` - `omp::EnterDataOp` -> `omp::TargetEnterDataOp` - `omp::ExitDataOp` -> `omp::TargetExitDataOp` - `omp::UpdateDataOp` -> `omp::TargetUpdateOp` - `omp::ReductionDeclareOp` -> `omp::DeclareReductionOp` - `omp::WsLoopOp` -> `omp::WsloopOp`
Diffstat (limited to 'mlir/lib')
-rw-r--r--mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp40
-rw-r--r--mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp30
-rw-r--r--mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp60
-rw-r--r--mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp95
4 files changed, 114 insertions, 111 deletions
diff --git a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
index fa54d01..b9ada0f 100644
--- a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
@@ -239,21 +239,23 @@ void mlir::configureOpenMPToLLVMConversionLegality(
ConversionTarget &target, LLVMTypeConverter &typeConverter) {
target.addDynamicallyLegalOp<
mlir::omp::AtomicReadOp, mlir::omp::AtomicWriteOp, mlir::omp::FlushOp,
- mlir::omp::ThreadprivateOp, mlir::omp::YieldOp, mlir::omp::EnterDataOp,
- mlir::omp::ExitDataOp, mlir::omp::UpdateDataOp, mlir::omp::DataBoundsOp,
- mlir::omp::MapInfoOp>([&](Operation *op) {
- return typeConverter.isLegal(op->getOperandTypes()) &&
- typeConverter.isLegal(op->getResultTypes());
- });
+ mlir::omp::ThreadprivateOp, mlir::omp::YieldOp,
+ mlir::omp::TargetEnterDataOp, mlir::omp::TargetExitDataOp,
+ mlir::omp::TargetUpdateOp, mlir::omp::MapBoundsOp, mlir::omp::MapInfoOp>(
+ [&](Operation *op) {
+ return typeConverter.isLegal(op->getOperandTypes()) &&
+ typeConverter.isLegal(op->getResultTypes());
+ });
target.addDynamicallyLegalOp<mlir::omp::ReductionOp>([&](Operation *op) {
return typeConverter.isLegal(op->getOperandTypes());
});
target.addDynamicallyLegalOp<
mlir::omp::AtomicUpdateOp, mlir::omp::CriticalOp, mlir::omp::TargetOp,
- mlir::omp::DataOp, mlir::omp::OrderedRegionOp, mlir::omp::ParallelOp,
- mlir::omp::WsLoopOp, mlir::omp::SimdLoopOp, mlir::omp::MasterOp,
- mlir::omp::SectionOp, mlir::omp::SectionsOp, mlir::omp::SingleOp,
- mlir::omp::TaskGroupOp, mlir::omp::TaskOp, mlir::omp::ReductionDeclareOp,
+ mlir::omp::TargetDataOp, mlir::omp::OrderedRegionOp,
+ mlir::omp::ParallelOp, mlir::omp::WsloopOp, mlir::omp::SimdLoopOp,
+ mlir::omp::MasterOp, mlir::omp::SectionOp, mlir::omp::SectionsOp,
+ mlir::omp::SingleOp, mlir::omp::TaskgroupOp, mlir::omp::TaskOp,
+ mlir::omp::DeclareReductionOp,
mlir::omp::PrivateClauseOp>([&](Operation *op) {
return std::all_of(op->getRegions().begin(), op->getRegions().end(),
[&](Region &region) {
@@ -270,28 +272,28 @@ void mlir::populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter,
// bounds information for map clauses and the operation and type are
// discarded on lowering to LLVM-IR from the OpenMP dialect.
converter.addConversion(
- [&](omp::DataBoundsType type) -> Type { return type; });
+ [&](omp::MapBoundsType type) -> Type { return type; });
patterns.add<
AtomicReadOpConversion, MapInfoOpConversion, ReductionOpConversion,
- MultiRegionOpConversion<omp::ReductionDeclareOp>,
+ MultiRegionOpConversion<omp::DeclareReductionOp>,
MultiRegionOpConversion<omp::PrivateClauseOp>,
RegionOpConversion<omp::CriticalOp>, RegionOpConversion<omp::MasterOp>,
ReductionOpConversion, RegionOpConversion<omp::OrderedRegionOp>,
- RegionOpConversion<omp::ParallelOp>, RegionOpConversion<omp::WsLoopOp>,
+ RegionOpConversion<omp::ParallelOp>, RegionOpConversion<omp::WsloopOp>,
RegionOpConversion<omp::SectionsOp>, RegionOpConversion<omp::SectionOp>,
RegionOpConversion<omp::SimdLoopOp>, RegionOpConversion<omp::SingleOp>,
- RegionOpConversion<omp::TaskGroupOp>, RegionOpConversion<omp::TaskOp>,
- RegionOpConversion<omp::DataOp>, RegionOpConversion<omp::TargetOp>,
+ RegionOpConversion<omp::TaskgroupOp>, RegionOpConversion<omp::TaskOp>,
+ RegionOpConversion<omp::TargetDataOp>, RegionOpConversion<omp::TargetOp>,
RegionLessOpWithVarOperandsConversion<omp::AtomicWriteOp>,
RegionOpWithVarOperandsConversion<omp::AtomicUpdateOp>,
RegionLessOpWithVarOperandsConversion<omp::FlushOp>,
RegionLessOpWithVarOperandsConversion<omp::ThreadprivateOp>,
RegionLessOpConversion<omp::YieldOp>,
- RegionLessOpConversion<omp::EnterDataOp>,
- RegionLessOpConversion<omp::ExitDataOp>,
- RegionLessOpConversion<omp::UpdateDataOp>,
- RegionLessOpWithVarOperandsConversion<omp::DataBoundsOp>>(converter);
+ RegionLessOpConversion<omp::TargetEnterDataOp>,
+ RegionLessOpConversion<omp::TargetExitDataOp>,
+ RegionLessOpConversion<omp::TargetUpdateOp>,
+ RegionLessOpWithVarOperandsConversion<omp::MapBoundsOp>>(converter);
}
namespace {
diff --git a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
index 464a647..7f91367 100644
--- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
+++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
@@ -183,12 +183,12 @@ static Attribute minMaxValueForUnsignedInt(Type type, bool min) {
/// symbol table. The declaration has a constant initializer with the neutral
/// value `initValue`, and the `reductionIndex`-th reduction combiner carried
/// over from `reduce`.
-static omp::ReductionDeclareOp
+static omp::DeclareReductionOp
createDecl(PatternRewriter &builder, SymbolTable &symbolTable,
scf::ReduceOp reduce, int64_t reductionIndex, Attribute initValue) {
OpBuilder::InsertionGuard guard(builder);
Type type = reduce.getOperands()[reductionIndex].getType();
- auto decl = builder.create<omp::ReductionDeclareOp>(reduce.getLoc(),
+ auto decl = builder.create<omp::DeclareReductionOp>(reduce.getLoc(),
"__scf_reduction", type);
symbolTable.insert(decl);
@@ -215,9 +215,9 @@ createDecl(PatternRewriter &builder, SymbolTable &symbolTable,
/// Adds an atomic reduction combiner to the given OpenMP reduction declaration
/// using llvm.atomicrmw of the given kind.
-static omp::ReductionDeclareOp addAtomicRMW(OpBuilder &builder,
+static omp::DeclareReductionOp addAtomicRMW(OpBuilder &builder,
LLVM::AtomicBinOp atomicKind,
- omp::ReductionDeclareOp decl,
+ omp::DeclareReductionOp decl,
scf::ReduceOp reduce,
int64_t reductionIndex) {
OpBuilder::InsertionGuard guard(builder);
@@ -241,7 +241,7 @@ static omp::ReductionDeclareOp addAtomicRMW(OpBuilder &builder,
/// reduction and returns it. Recognizes common reductions in order to identify
/// the neutral value, necessary for the OpenMP declaration. If the reduction
/// cannot be recognized, returns null.
-static omp::ReductionDeclareOp declareReduction(PatternRewriter &builder,
+static omp::DeclareReductionOp declareReduction(PatternRewriter &builder,
scf::ReduceOp reduce,
int64_t reductionIndex) {
Operation *container = SymbolTable::getNearestSymbolTable(reduce);
@@ -262,35 +262,35 @@ static omp::ReductionDeclareOp declareReduction(PatternRewriter &builder,
Type type = reduce.getOperands()[reductionIndex].getType();
Block &reduction = reduce.getReductions()[reductionIndex].front();
if (matchSimpleReduction<arith::AddFOp, LLVM::FAddOp>(reduction)) {
- omp::ReductionDeclareOp decl =
+ omp::DeclareReductionOp decl =
createDecl(builder, symbolTable, reduce, reductionIndex,
builder.getFloatAttr(type, 0.0));
return addAtomicRMW(builder, LLVM::AtomicBinOp::fadd, decl, reduce,
reductionIndex);
}
if (matchSimpleReduction<arith::AddIOp, LLVM::AddOp>(reduction)) {
- omp::ReductionDeclareOp decl =
+ omp::DeclareReductionOp decl =
createDecl(builder, symbolTable, reduce, reductionIndex,
builder.getIntegerAttr(type, 0));
return addAtomicRMW(builder, LLVM::AtomicBinOp::add, decl, reduce,
reductionIndex);
}
if (matchSimpleReduction<arith::OrIOp, LLVM::OrOp>(reduction)) {
- omp::ReductionDeclareOp decl =
+ omp::DeclareReductionOp decl =
createDecl(builder, symbolTable, reduce, reductionIndex,
builder.getIntegerAttr(type, 0));
return addAtomicRMW(builder, LLVM::AtomicBinOp::_or, decl, reduce,
reductionIndex);
}
if (matchSimpleReduction<arith::XOrIOp, LLVM::XOrOp>(reduction)) {
- omp::ReductionDeclareOp decl =
+ omp::DeclareReductionOp decl =
createDecl(builder, symbolTable, reduce, reductionIndex,
builder.getIntegerAttr(type, 0));
return addAtomicRMW(builder, LLVM::AtomicBinOp::_xor, decl, reduce,
reductionIndex);
}
if (matchSimpleReduction<arith::AndIOp, LLVM::AndOp>(reduction)) {
- omp::ReductionDeclareOp decl = createDecl(
+ omp::DeclareReductionOp decl = createDecl(
builder, symbolTable, reduce, reductionIndex,
builder.getIntegerAttr(
type, llvm::APInt::getAllOnes(type.getIntOrFloatBitWidth())));
@@ -327,7 +327,7 @@ static omp::ReductionDeclareOp declareReduction(PatternRewriter &builder,
matchSelectReduction<LLVM::ICmpOp, LLVM::SelectOp>(
reduction, {LLVM::ICmpPredicate::slt, LLVM::ICmpPredicate::sle},
{LLVM::ICmpPredicate::sgt, LLVM::ICmpPredicate::sge}, isMin)) {
- omp::ReductionDeclareOp decl =
+ omp::DeclareReductionOp decl =
createDecl(builder, symbolTable, reduce, reductionIndex,
minMaxValueForSignedInt(type, !isMin));
return addAtomicRMW(builder,
@@ -340,7 +340,7 @@ static omp::ReductionDeclareOp declareReduction(PatternRewriter &builder,
matchSelectReduction<LLVM::ICmpOp, LLVM::SelectOp>(
reduction, {LLVM::ICmpPredicate::ugt, LLVM::ICmpPredicate::ule},
{LLVM::ICmpPredicate::ugt, LLVM::ICmpPredicate::uge}, isMin)) {
- omp::ReductionDeclareOp decl =
+ omp::DeclareReductionOp decl =
createDecl(builder, symbolTable, reduce, reductionIndex,
minMaxValueForUnsignedInt(type, !isMin));
return addAtomicRMW(
@@ -367,10 +367,10 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
// TODO: consider checking it here is already a compatible reduction
// declaration and use it instead of redeclaring.
SmallVector<Attribute> reductionDeclSymbols;
- SmallVector<omp::ReductionDeclareOp> ompReductionDecls;
+ SmallVector<omp::DeclareReductionOp> ompReductionDecls;
auto reduce = cast<scf::ReduceOp>(parallelOp.getBody()->getTerminator());
for (int64_t i = 0, e = parallelOp.getNumReductions(); i < e; ++i) {
- omp::ReductionDeclareOp decl = declareReduction(rewriter, reduce, i);
+ omp::DeclareReductionOp decl = declareReduction(rewriter, reduce, i);
ompReductionDecls.push_back(decl);
if (!decl)
return failure();
@@ -461,7 +461,7 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
// Replace the loop.
{
OpBuilder::InsertionGuard allocaGuard(rewriter);
- auto loop = rewriter.create<omp::WsLoopOp>(
+ auto loop = rewriter.create<omp::WsloopOp>(
parallelOp.getLoc(), parallelOp.getLowerBound(),
parallelOp.getUpperBound(), parallelOp.getStep());
rewriter.create<omp::TerminatorOp>(loc);
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index e7b899a..bf58750 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -592,7 +592,7 @@ static LogicalResult verifyReductionVarList(Operation *op,
Type varType = accum.getType();
auto symbolRef = llvm::cast<SymbolRefAttr>(std::get<1>(args));
auto decl =
- SymbolTable::lookupNearestSymbolFrom<ReductionDeclareOp>(op, symbolRef);
+ SymbolTable::lookupNearestSymbolFrom<DeclareReductionOp>(op, symbolRef);
if (!decl)
return op->emitOpError() << "expected symbol reference " << symbolRef
<< " to point to a reduction declaration";
@@ -1112,18 +1112,18 @@ static LogicalResult verifyMapClause(Operation *op, OperandRange mapOperands) {
bool implicit = mapTypeToBitFlag(
mapTypeBits, llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT);
- if ((isa<DataOp>(op) || isa<TargetOp>(op)) && del)
+ if ((isa<TargetDataOp>(op) || isa<TargetOp>(op)) && del)
return emitError(op->getLoc(),
"to, from, tofrom and alloc map types are permitted");
- if (isa<EnterDataOp>(op) && (from || del))
+ if (isa<TargetEnterDataOp>(op) && (from || del))
return emitError(op->getLoc(), "to and alloc map types are permitted");
- if (isa<ExitDataOp>(op) && to)
+ if (isa<TargetExitDataOp>(op) && to)
return emitError(op->getLoc(),
"from, release and delete map types are permitted");
- if (isa<UpdateDataOp>(op)) {
+ if (isa<TargetUpdateOp>(op)) {
if (del) {
return emitError(op->getLoc(),
"at least one of to or from map types must be "
@@ -1161,7 +1161,7 @@ static LogicalResult verifyMapClause(Operation *op, OperandRange mapOperands) {
return success();
}
-LogicalResult DataOp::verify() {
+LogicalResult TargetDataOp::verify() {
if (getMapOperands().empty() && getUseDevicePtr().empty() &&
getUseDeviceAddr().empty()) {
return ::emitError(this->getLoc(), "At least one of map, useDevicePtr, or "
@@ -1170,21 +1170,21 @@ LogicalResult DataOp::verify() {
return verifyMapClause(*this, getMapOperands());
}
-LogicalResult EnterDataOp::verify() {
+LogicalResult TargetEnterDataOp::verify() {
LogicalResult verifyDependVars =
verifyDependVarList(*this, getDepends(), getDependVars());
return failed(verifyDependVars) ? verifyDependVars
: verifyMapClause(*this, getMapOperands());
}
-LogicalResult ExitDataOp::verify() {
+LogicalResult TargetExitDataOp::verify() {
LogicalResult verifyDependVars =
verifyDependVarList(*this, getDepends(), getDependVars());
return failed(verifyDependVars) ? verifyDependVars
: verifyMapClause(*this, getMapOperands());
}
-LogicalResult UpdateDataOp::verify() {
+LogicalResult TargetUpdateOp::verify() {
LogicalResult verifyDependVars =
verifyDependVarList(*this, getDepends(), getDependVars());
return failed(verifyDependVars) ? verifyDependVars
@@ -1345,14 +1345,14 @@ LogicalResult SingleOp::verify() {
}
//===----------------------------------------------------------------------===//
-// WsLoopOp
+// WsloopOp
//===----------------------------------------------------------------------===//
/// loop-control ::= `(` ssa-id-list `)` `:` type `=` loop-bounds
/// loop-bounds := `(` ssa-id-list `)` to `(` ssa-id-list `)` inclusive? steps
/// steps := `step` `(`ssa-id-list`)`
ParseResult
-parseWsLoop(OpAsmParser &parser, Region &region,
+parseWsloop(OpAsmParser &parser, Region &region,
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &lowerBound,
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &upperBound,
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &steps,
@@ -1405,7 +1405,7 @@ parseWsLoop(OpAsmParser &parser, Region &region,
return parser.parseRegion(region, regionArgs);
}
-void printWsLoop(OpAsmPrinter &p, Operation *op, Region &region,
+void printWsloop(OpAsmPrinter &p, Operation *op, Region &region,
ValueRange lowerBound, ValueRange upperBound, ValueRange steps,
TypeRange loopVarTypes, ValueRange reductionOperands,
TypeRange reductionTypes, ArrayAttr reductionSymbols,
@@ -1531,14 +1531,14 @@ static ParseResult parseAtomicReductionRegion(OpAsmParser &parser,
}
static void printAtomicReductionRegion(OpAsmPrinter &printer,
- ReductionDeclareOp op, Region &region) {
+ DeclareReductionOp op, Region &region) {
if (region.empty())
return;
printer << "atomic ";
printer.printRegion(region);
}
-LogicalResult ReductionDeclareOp::verifyRegions() {
+LogicalResult DeclareReductionOp::verifyRegions() {
if (getInitializerRegion().empty())
return emitOpError() << "expects non-empty initializer region";
Block &initializerEntryBlock = getInitializerRegion().front();
@@ -1617,17 +1617,17 @@ LogicalResult TaskOp::verify() {
}
//===----------------------------------------------------------------------===//
-// TaskGroupOp
+// TaskgroupOp
//===----------------------------------------------------------------------===//
-LogicalResult TaskGroupOp::verify() {
+LogicalResult TaskgroupOp::verify() {
return verifyReductionVarList(*this, getTaskReductions(),
getTaskReductionVars());
}
//===----------------------------------------------------------------------===//
-// TaskLoopOp
+// TaskloopOp
//===----------------------------------------------------------------------===//
-SmallVector<Value> TaskLoopOp::getAllReductionVars() {
+SmallVector<Value> TaskloopOp::getAllReductionVars() {
SmallVector<Value> allReductionNvars(getInReductionVars().begin(),
getInReductionVars().end());
allReductionNvars.insert(allReductionNvars.end(), getReductionVars().begin(),
@@ -1635,7 +1635,7 @@ SmallVector<Value> TaskLoopOp::getAllReductionVars() {
return allReductionNvars;
}
-LogicalResult TaskLoopOp::verify() {
+LogicalResult TaskloopOp::verify() {
if (getAllocateVars().size() != getAllocatorsVars().size())
return emitError(
"expected equal sizes for allocate and allocator variables");
@@ -1663,10 +1663,10 @@ LogicalResult TaskLoopOp::verify() {
}
//===----------------------------------------------------------------------===//
-// WsLoopOp
+// WsloopOp
//===----------------------------------------------------------------------===//
-void WsLoopOp::build(OpBuilder &builder, OperationState &state,
+void WsloopOp::build(OpBuilder &builder, OperationState &state,
ValueRange lowerBound, ValueRange upperBound,
ValueRange step, ArrayRef<NamedAttribute> attributes) {
build(builder, state, lowerBound, upperBound, step,
@@ -1680,7 +1680,7 @@ void WsLoopOp::build(OpBuilder &builder, OperationState &state,
state.addAttributes(attributes);
}
-LogicalResult WsLoopOp::verify() {
+LogicalResult WsloopOp::verify() {
return verifyReductionVarList(*this, getReductions(), getReductionVars());
}
@@ -1711,7 +1711,7 @@ LogicalResult CriticalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
//===----------------------------------------------------------------------===//
LogicalResult OrderedOp::verify() {
- auto container = (*this)->getParentOfType<WsLoopOp>();
+ auto container = (*this)->getParentOfType<WsloopOp>();
if (!container || !container.getOrderedValAttr() ||
container.getOrderedValAttr().getInt() == 0)
return emitOpError() << "ordered depend directive must be closely "
@@ -1731,7 +1731,7 @@ LogicalResult OrderedRegionOp::verify() {
if (getSimd())
return failure();
- if (auto container = (*this)->getParentOfType<WsLoopOp>()) {
+ if (auto container = (*this)->getParentOfType<WsloopOp>()) {
if (!container.getOrderedValAttr() ||
container.getOrderedValAttr().getInt() != 0)
return emitOpError() << "ordered region must be closely nested inside "
@@ -1874,15 +1874,15 @@ LogicalResult CancelOp::verify() {
<< "inside a parallel region";
}
if (cct == ClauseCancellationConstructType::Loop) {
- if (!isa<WsLoopOp>(parentOp)) {
+ if (!isa<WsloopOp>(parentOp)) {
return emitOpError() << "cancel loop must appear "
<< "inside a worksharing-loop region";
}
- if (cast<WsLoopOp>(parentOp).getNowaitAttr()) {
+ if (cast<WsloopOp>(parentOp).getNowaitAttr()) {
return emitError() << "A worksharing construct that is canceled "
<< "must not have a nowait clause";
}
- if (cast<WsLoopOp>(parentOp).getOrderedValAttr()) {
+ if (cast<WsloopOp>(parentOp).getOrderedValAttr()) {
return emitError() << "A worksharing construct that is canceled "
<< "must not have an ordered clause";
}
@@ -1920,7 +1920,7 @@ LogicalResult CancellationPointOp::verify() {
<< "inside a parallel region";
}
if ((cct == ClauseCancellationConstructType::Loop) &&
- !isa<WsLoopOp>(parentOp)) {
+ !isa<WsloopOp>(parentOp)) {
return emitOpError() << "cancellation point loop must appear "
<< "inside a worksharing-loop region";
}
@@ -1934,10 +1934,10 @@ LogicalResult CancellationPointOp::verify() {
}
//===----------------------------------------------------------------------===//
-// DataBoundsOp
+// MapBoundsOp
//===----------------------------------------------------------------------===//
-LogicalResult DataBoundsOp::verify() {
+LogicalResult MapBoundsOp::verify() {
auto extent = getExtent();
auto upperbound = getUpperBound();
if (!extent && !upperbound)
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 5027f2a..7df3347 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -331,10 +331,10 @@ convertOmpCritical(Operation &opInst, llvm::IRBuilderBase &builder,
/// Returns a reduction declaration that corresponds to the given reduction
/// operation in the given container. Currently only supports reductions inside
-/// WsLoopOp and ParallelOp but can be easily extended as long as the given
+/// WsloopOp and ParallelOp but can be easily extended as long as the given
/// construct implements getNumReductionVars.
template <typename T>
-static std::optional<omp::ReductionDeclareOp>
+static std::optional<omp::DeclareReductionOp>
findReductionDeclInContainer(T container, omp::ReductionOp reduction) {
for (unsigned i = 0, e = container.getNumReductionVars(); i < e; ++i) {
if (container.getReductionVars()[i] != reduction.getAccumulator())
@@ -343,7 +343,7 @@ findReductionDeclInContainer(T container, omp::ReductionOp reduction) {
SymbolRefAttr reductionSymbol =
cast<SymbolRefAttr>((*container.getReductions())[i]);
auto declareOp =
- SymbolTable::lookupNearestSymbolFrom<omp::ReductionDeclareOp>(
+ SymbolTable::lookupNearestSymbolFrom<omp::DeclareReductionOp>(
container, reductionSymbol);
return declareOp;
}
@@ -352,16 +352,16 @@ findReductionDeclInContainer(T container, omp::ReductionOp reduction) {
/// Searches for a reduction in a provided region and the regions
/// it is nested in
-static omp::ReductionDeclareOp findReductionDecl(Operation &containerOp,
+static omp::DeclareReductionOp findReductionDecl(Operation &containerOp,
omp::ReductionOp reduction) {
- std::optional<omp::ReductionDeclareOp> declareOp = std::nullopt;
+ std::optional<omp::DeclareReductionOp> declareOp = std::nullopt;
Operation *container = &containerOp;
while (!declareOp.has_value() && container) {
// Check if current container is supported for reductions searches
if (auto par = dyn_cast<omp::ParallelOp>(*container)) {
declareOp = findReductionDeclInContainer(par, reduction);
- } else if (auto loop = dyn_cast<omp::WsLoopOp>(*container)) {
+ } else if (auto loop = dyn_cast<omp::WsloopOp>(*container)) {
declareOp = findReductionDeclInContainer(loop, reduction);
} else {
break;
@@ -381,7 +381,7 @@ static omp::ReductionDeclareOp findReductionDecl(Operation &containerOp,
template <typename T>
static void
collectReductionDecls(T loop,
- SmallVectorImpl<omp::ReductionDeclareOp> &reductions) {
+ SmallVectorImpl<omp::DeclareReductionOp> &reductions) {
std::optional<ArrayAttr> attr = loop.getReductions();
if (!attr)
return;
@@ -389,7 +389,7 @@ collectReductionDecls(T loop,
reductions.reserve(reductions.size() + loop.getNumReductionVars());
for (auto symbolRef : attr->getAsRange<SymbolRefAttr>()) {
reductions.push_back(
- SymbolTable::lookupNearestSymbolFrom<omp::ReductionDeclareOp>(
+ SymbolTable::lookupNearestSymbolFrom<omp::DeclareReductionOp>(
loop, symbolRef));
}
}
@@ -466,7 +466,7 @@ using OwningAtomicReductionGen =
/// reduction declaration. The generator uses `builder` but ignores its
/// insertion point.
static OwningReductionGen
-makeReductionGen(omp::ReductionDeclareOp decl, llvm::IRBuilderBase &builder,
+makeReductionGen(omp::DeclareReductionOp decl, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
// The lambda is mutable because we need access to non-const methods of decl
// (which aren't actually mutating it), and we must capture decl by-value to
@@ -496,7 +496,7 @@ makeReductionGen(omp::ReductionDeclareOp decl, llvm::IRBuilderBase &builder,
/// insertion point. Returns null if there is no atomic region available in the
/// reduction declaration.
static OwningAtomicReductionGen
-makeAtomicReductionGen(omp::ReductionDeclareOp decl,
+makeAtomicReductionGen(omp::DeclareReductionOp decl,
llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
if (decl.getAtomicReductionRegion().empty())
@@ -783,7 +783,7 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
/// Converts an OpenMP taskgroup construct into LLVM IR using OpenMPIRBuilder.
static LogicalResult
-convertOmpTaskgroupOp(omp::TaskGroupOp tgOp, llvm::IRBuilderBase &builder,
+convertOmpTaskgroupOp(omp::TaskgroupOp tgOp, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
LogicalResult bodyGenStatus = success();
@@ -808,7 +808,7 @@ static void
allocByValReductionVars(T loop, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation,
llvm::OpenMPIRBuilder::InsertPointTy &allocaIP,
- SmallVector<omp::ReductionDeclareOp> &reductionDecls,
+ SmallVector<omp::DeclareReductionOp> &reductionDecls,
SmallVector<llvm::Value *> &privateReductionVariables,
DenseMap<Value, llvm::Value *> &reductionVariableMap) {
llvm::IRBuilderBase::InsertPointGuard guard(builder);
@@ -830,7 +830,7 @@ template <typename T>
static void collectReductionInfo(
T loop, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation,
- SmallVector<omp::ReductionDeclareOp> &reductionDecls,
+ SmallVector<omp::DeclareReductionOp> &reductionDecls,
SmallVector<OwningReductionGen> &owningReductionGens,
SmallVector<OwningAtomicReductionGen> &owningAtomicReductionGens,
const SmallVector<llvm::Value *> &privateReductionVariables,
@@ -860,9 +860,9 @@ static void collectReductionInfo(
/// Converts an OpenMP workshare loop into LLVM IR using OpenMPIRBuilder.
static LogicalResult
-convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
+convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
- auto loop = cast<omp::WsLoopOp>(opInst);
+ auto loop = cast<omp::WsloopOp>(opInst);
const bool isByRef = loop.getByref();
// TODO: this should be in the op verifier instead.
if (loop.getLowerBound().empty())
@@ -882,7 +882,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
chunk = builder.CreateSExtOrTrunc(chunkVar, ivType);
}
- SmallVector<omp::ReductionDeclareOp> reductionDecls;
+ SmallVector<omp::DeclareReductionOp> reductionDecls;
collectReductionDecls(loop, reductionDecls);
llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
findAllocaInsertPoint(builder, moduleTranslation);
@@ -962,9 +962,9 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
};
// Delegate actual loop construction to the OpenMP IRBuilder.
- // TODO: this currently assumes WsLoop is semantically similar to SCF loop,
+ // TODO: this currently assumes Wsloop is semantically similar to SCF loop,
// i.e. it has a positive step, uses signed integer semantics. Reconsider
- // this code when WsLoop clearly supports more cases.
+ // this code when Wsloop clearly supports more cases.
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
for (unsigned i = 0, e = loop.getNumLoops(); i < e; ++i) {
llvm::Value *lowerBound =
@@ -1099,7 +1099,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
auto bodyGenCB = [&](InsertPointTy allocaIP, InsertPointTy codeGenIP) {
// Collect reduction declarations
- SmallVector<omp::ReductionDeclareOp> reductionDecls;
+ SmallVector<omp::DeclareReductionOp> reductionDecls;
collectReductionDecls(opInst, reductionDecls);
// Allocate reduction vars
@@ -1653,16 +1653,16 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
/// Converts an OpenMP reduction operation using OpenMPIRBuilder. Expects the
/// mapping between reduction variables and their private equivalents to have
/// been stored on the ModuleTranslation stack. Currently only supports
-/// reduction within WsLoopOp and ParallelOp, but can be easily extended.
+/// reduction within WsloopOp and ParallelOp, but can be easily extended.
static LogicalResult
convertOmpReductionOp(omp::ReductionOp reductionOp,
llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
// Find the declaration that corresponds to the reduction op.
- omp::ReductionDeclareOp declaration;
+ omp::DeclareReductionOp declaration;
Operation *reductionParent = reductionOp->getParentOp();
if (dyn_cast<omp::ParallelOp>(reductionParent) ||
- dyn_cast<omp::WsLoopOp>(reductionParent)) {
+ dyn_cast<omp::WsloopOp>(reductionParent)) {
declaration = findReductionDecl(*reductionParent, reductionOp);
} else {
llvm_unreachable("Unhandled reduction container");
@@ -1894,7 +1894,7 @@ llvm::Value *getSizeInBytes(DataLayout &dl, const mlir::Type &type,
if (!memberClause.getBounds().empty()) {
llvm::Value *elementCount = builder.getInt64(1);
for (auto bounds : memberClause.getBounds()) {
- if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::DataBoundsOp>(
+ if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::MapBoundsOp>(
bounds.getDefiningOp())) {
// The below calculation for the size to be mapped calculated from the
// map_info's bounds is: (elemCount * [UB - LB] + 1), later we
@@ -2098,7 +2098,7 @@ static void processMapMembersWithParent(
if (!memberClause.getBounds().empty()) {
if (mapData.BaseType[memberDataIdx]->isArrayTy()) {
for (int i = memberClause.getBounds().size() - 1; i >= 0; --i) {
- if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::DataBoundsOp>(
+ if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::MapBoundsOp>(
memberClause.getBounds()[i].getDefiningOp())) {
idx.push_back(
moduleTranslation.lookupValue(boundOp.getLowerBound()));
@@ -2108,7 +2108,7 @@ static void processMapMembersWithParent(
std::vector<llvm::Value *> dimensionIndexSizeOffset{
builder.getInt64(1)};
for (size_t i = 1; i < memberClause.getBounds().size(); ++i) {
- if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::DataBoundsOp>(
+ if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::MapBoundsOp>(
memberClause.getBounds()[i].getDefiningOp())) {
dimensionIndexSizeOffset.push_back(builder.CreateMul(
moduleTranslation.lookupValue(boundOp.getExtent()),
@@ -2117,7 +2117,7 @@ static void processMapMembersWithParent(
}
for (int i = memberClause.getBounds().size() - 1; i >= 0; --i) {
- if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::DataBoundsOp>(
+ if (auto boundOp = mlir::dyn_cast_if_present<mlir::omp::MapBoundsOp>(
memberClause.getBounds()[i].getDefiningOp())) {
if (!offsetAddress)
offsetAddress = builder.CreateMul(
@@ -2279,7 +2279,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
LogicalResult result =
llvm::TypeSwitch<Operation *, LogicalResult>(op)
- .Case([&](omp::DataOp dataOp) {
+ .Case([&](omp::TargetDataOp dataOp) {
if (auto ifExprVar = dataOp.getIfExpr())
ifCond = moduleTranslation.lookupValue(ifExprVar);
@@ -2294,7 +2294,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
useDevAddrOperands = dataOp.getUseDeviceAddr();
return success();
})
- .Case([&](omp::EnterDataOp enterDataOp) {
+ .Case([&](omp::TargetEnterDataOp enterDataOp) {
if (enterDataOp.getNowait())
return (LogicalResult)(enterDataOp.emitError(
"`nowait` is not supported yet"));
@@ -2311,7 +2311,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
mapOperands = enterDataOp.getMapOperands();
return success();
})
- .Case([&](omp::ExitDataOp exitDataOp) {
+ .Case([&](omp::TargetExitDataOp exitDataOp) {
if (exitDataOp.getNowait())
return (LogicalResult)(exitDataOp.emitError(
"`nowait` is not supported yet"));
@@ -2329,7 +2329,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
mapOperands = exitDataOp.getMapOperands();
return success();
})
- .Case([&](omp::UpdateDataOp updateDataOp) {
+ .Case([&](omp::TargetUpdateOp updateDataOp) {
if (updateDataOp.getNowait())
return (LogicalResult)(updateDataOp.emitError(
"`nowait` is not supported yet"));
@@ -2366,7 +2366,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
auto genMapInfoCB =
[&](InsertPointTy codeGenIP) -> llvm::OpenMPIRBuilder::MapInfosTy & {
builder.restoreIP(codeGenIP);
- if (auto dataOp = dyn_cast<omp::DataOp>(op)) {
+ if (auto dataOp = dyn_cast<omp::TargetDataOp>(op)) {
genMapInfos(builder, moduleTranslation, DL, combinedInfo, mapData,
useDevPtrOperands, useDevAddrOperands);
} else {
@@ -2381,8 +2381,9 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
using BodyGenTy = llvm::OpenMPIRBuilder::BodyGenTy;
LogicalResult bodyGenStatus = success();
auto bodyGenCB = [&](InsertPointTy codeGenIP, BodyGenTy bodyGenType) {
- assert(isa<omp::DataOp>(op) && "BodyGen requested for non DataOp");
- Region &region = cast<omp::DataOp>(op).getRegion();
+ assert(isa<omp::TargetDataOp>(op) &&
+ "BodyGen requested for non TargetDataOp");
+ Region &region = cast<omp::TargetDataOp>(op).getRegion();
switch (bodyGenType) {
case BodyGenTy::Priv:
// Check if any device ptr/addr info is available
@@ -2427,7 +2428,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
findAllocaInsertPoint(builder, moduleTranslation);
- if (isa<omp::DataOp>(op)) {
+ if (isa<omp::TargetDataOp>(op)) {
builder.restoreIP(ompBuilder->createTargetData(
ompLoc, allocaIP, builder.saveIP(), builder.getInt64(deviceID), ifCond,
info, genMapInfoCB, nullptr, bodyGenCB));
@@ -2698,7 +2699,7 @@ createAlteredByCaptureMap(MapInfoData &mapData,
std::vector<llvm::Value *>{builder.getInt64(0)};
for (int i = mapOp.getBounds().size() - 1; i >= 0; --i) {
if (auto boundOp =
- mlir::dyn_cast_if_present<mlir::omp::DataBoundsOp>(
+ mlir::dyn_cast_if_present<mlir::omp::MapBoundsOp>(
mapOp.getBounds()[i].getDefiningOp())) {
idx.push_back(
moduleTranslation.lookupValue(boundOp.getLowerBound()));
@@ -3132,8 +3133,8 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
.Case([&](omp::OrderedOp) {
return convertOmpOrdered(*op, builder, moduleTranslation);
})
- .Case([&](omp::WsLoopOp) {
- return convertOmpWsLoop(*op, builder, moduleTranslation);
+ .Case([&](omp::WsloopOp) {
+ return convertOmpWsloop(*op, builder, moduleTranslation);
})
.Case([&](omp::SimdLoopOp) {
return convertOmpSimdLoop(*op, builder, moduleTranslation);
@@ -3162,14 +3163,14 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
.Case([&](omp::TaskOp op) {
return convertOmpTaskOp(op, builder, moduleTranslation);
})
- .Case([&](omp::TaskGroupOp op) {
+ .Case([&](omp::TaskgroupOp op) {
return convertOmpTaskgroupOp(op, builder, moduleTranslation);
})
- .Case<omp::YieldOp, omp::TerminatorOp, omp::ReductionDeclareOp,
+ .Case<omp::YieldOp, omp::TerminatorOp, omp::DeclareReductionOp,
omp::CriticalDeclareOp>([](auto op) {
// `yield` and `terminator` can be just omitted. The block structure
// was created in the region that handles their parent operation.
- // `reduction.declare` will be used by reductions and is not
+ // `declare_reduction` will be used by reductions and is not
// converted directly, skip it.
// `critical.declare` is only used to declare names of critical
// sections which will be used by `critical` ops and hence can be
@@ -3180,18 +3181,18 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
.Case([&](omp::ThreadprivateOp) {
return convertOmpThreadprivate(*op, builder, moduleTranslation);
})
- .Case<omp::DataOp, omp::EnterDataOp, omp::ExitDataOp, omp::UpdateDataOp>(
- [&](auto op) {
- return convertOmpTargetData(op, builder, moduleTranslation);
- })
+ .Case<omp::TargetDataOp, omp::TargetEnterDataOp, omp::TargetExitDataOp,
+ omp::TargetUpdateOp>([&](auto op) {
+ return convertOmpTargetData(op, builder, moduleTranslation);
+ })
.Case([&](omp::TargetOp) {
return convertOmpTarget(*op, builder, moduleTranslation);
})
- .Case<omp::MapInfoOp, omp::DataBoundsOp, omp::PrivateClauseOp>(
+ .Case<omp::MapInfoOp, omp::MapBoundsOp, omp::PrivateClauseOp>(
[&](auto op) {
// No-op, should be handled by relevant owning operations e.g.
- // TargetOp, EnterDataOp, ExitDataOp, DataOp etc. and then
- // discarded
+ // TargetOp, TargetEnterDataOp, TargetExitDataOp, TargetDataOp etc.
+ // and then discarded
return success();
})
.Default([&](Operation *inst) {