[Mlir-commits] [flang] [openmp] [mlir] [Flang][OpenMP] Initial mapping of Fortran pointers and allocatables for target devices (PR #71766)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Dec 1 03:06:31 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff cd31cf5989aaf6a187aaf3af4f94207c55a70d0f b42f20713eadd9edb25cb103306a06b4716aa7c2 -- flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp flang/include/flang/Optimizer/CodeGen/CodeGen.h flang/lib/Lower/DirectivesCommon.h flang/lib/Lower/OpenMP.cpp flang/lib/Optimizer/CodeGen/CodeGen.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 81f1f5c80a..201847ec7f 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -1746,47 +1746,45 @@ static mlir::omp::MapInfoOp processDescriptorTypeMappings(
if (fir::isAssumedShape(fir::unwrapRefType(descriptorAddr.getType()))) {
mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint();
firOpBuilder.setInsertionPointToStart(firOpBuilder.getAllocaBlock());
- descriptor = firOpBuilder.create<fir::AllocaOp>(loc, descriptorAddr.getType());
+ descriptor =
+ firOpBuilder.create<fir::AllocaOp>(loc, descriptorAddr.getType());
firOpBuilder.restoreInsertionPoint(insPt);
- firOpBuilder.create<fir::StoreOp>(
- loc, descriptorAddr, descriptor);
+ firOpBuilder.create<fir::StoreOp>(loc, descriptorAddr, descriptor);
}
// if (auto boxTy = descriptorAddr.getType().dyn_cast<fir::BaseBoxType>())
- // descriptorAddr = converter.getFirOpBuilder().create<fir::BoxAddrOp>(loc, descriptorAddr);
+ // descriptorAddr = converter.getFirOpBuilder().create<fir::BoxAddrOp>(loc,
+ // descriptorAddr);
+
+ mlir::Value baseAddrAddr = firOpBuilder.create<fir::BoxOffsetOp>(
+ loc, descriptor, fir::BoxFieldAttr::base_addr);
- mlir::Value baseAddrAddr =
- firOpBuilder.create<fir::BoxOffsetOp>(
- loc, descriptor, fir::BoxFieldAttr::base_addr);
-
descriptorBaseAddrMembers.push_back(createMapInfoOp(
- firOpBuilder, loc, descDataBaseAddr, baseAddrAddr,
- asFortran, bounds, {},
+ firOpBuilder, loc, descDataBaseAddr, baseAddrAddr, asFortran, bounds, {},
static_cast<std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
mapCaptureType),
mlir::omp::VariableCaptureKind::ByRef, descDataBaseAddr.getType()));
- if (fir::BaseBoxType baseBoxTy =
- llvm::dyn_cast<fir::BaseBoxType>(fir::unwrapRefType(descriptor.getType()))) {
+ if (fir::BaseBoxType baseBoxTy = llvm::dyn_cast<fir::BaseBoxType>(
+ fir::unwrapRefType(descriptor.getType()))) {
if (fir::boxHasAddendum(baseBoxTy)) {
- mlir::Value addendumAddrAddr =
- firOpBuilder.create<fir::BoxOffsetOp>(
- loc, descriptor, fir::BoxFieldAttr::derived_type);
+ mlir::Value addendumAddrAddr = firOpBuilder.create<fir::BoxOffsetOp>(
+ loc, descriptor, fir::BoxFieldAttr::derived_type);
// NOTE: We have no addendumAddr, but we must provide a varPtr alongside
// the varPtrPtr so we replicate it across the two for now.
descriptorBaseAddrMembers.push_back(createMapInfoOp(
- firOpBuilder, loc, addendumAddrAddr, addendumAddrAddr,
- asFortran, {}, {},
+ firOpBuilder, loc, addendumAddrAddr, addendumAddrAddr, asFortran, {},
+ {},
static_cast<
std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
mapCaptureType),
mlir::omp::VariableCaptureKind::ByRef, addendumAddrAddr.getType()));
}
}
-
+
return createMapInfoOp(
- firOpBuilder, loc, descriptor, mlir::Value{},
- asFortran, {}, descriptorBaseAddrMembers,
+ firOpBuilder, loc, descriptor, mlir::Value{}, asFortran, {},
+ descriptorBaseAddrMembers,
static_cast<std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
mapCaptureType),
mlir::omp::VariableCaptureKind::ByRef, descriptor.getType());
@@ -1849,26 +1847,24 @@ bool ClauseProcessor::processMap(
for (const Fortran::parser::OmpObject &ompObject :
std::get<Fortran::parser::OmpObjectList>(mapClause->v.t).v) {
- llvm::SmallVector<mlir::Value> bounds;
- std::stringstream asFortran;
- mlir::Value baseAddr =
- Fortran::lower::gatherDataOperandAddrAndBounds<
- Fortran::parser::OmpObject, mlir::omp::DataBoundsType,
- mlir::omp::DataBoundsOp>(
- converter, firOpBuilder, semanticsContext, stmtCtx,
- ompObject, clauseLocation, asFortran, bounds,
- treatIndexAsSection);
- auto origSymbol =
- converter.getSymbolAddress(*getOmpObjectSymbol(ompObject));
- mlir::Value mapOp, symAddr;
- if (fir::isPointerType(origSymbol.getType()) ||
- fir::isAllocatableType(origSymbol.getType()) ||
- fir::isAssumedShape(origSymbol.getType())) {
- symAddr = origSymbol;
- mapOp = processDescriptorTypeMappings(
+ llvm::SmallVector<mlir::Value> bounds;
+ std::stringstream asFortran;
+ mlir::Value baseAddr = Fortran::lower::gatherDataOperandAddrAndBounds<
+ Fortran::parser::OmpObject, mlir::omp::DataBoundsType,
+ mlir::omp::DataBoundsOp>(
+ converter, firOpBuilder, semanticsContext, stmtCtx, ompObject,
+ clauseLocation, asFortran, bounds, treatIndexAsSection);
+ auto origSymbol =
+ converter.getSymbolAddress(*getOmpObjectSymbol(ompObject));
+ mlir::Value mapOp, symAddr;
+ if (fir::isPointerType(origSymbol.getType()) ||
+ fir::isAllocatableType(origSymbol.getType()) ||
+ fir::isAssumedShape(origSymbol.getType())) {
+ symAddr = origSymbol;
+ mapOp = processDescriptorTypeMappings(
semanticsContext, stmtCtx, converter, clauseLocation,
origSymbol, baseAddr, bounds, asFortran.str(), mapTypeBits);
- } else {
+ } else {
// Explicit map captures are captured ByRef by default,
// optimisation passes may alter this to ByCopy or other capture
// types to optimise
@@ -1879,15 +1875,15 @@ bool ClauseProcessor::processMap(
static_cast<std::underlying_type_t<
llvm::omp::OpenMPOffloadMappingFlags>>(mapTypeBits),
mlir::omp::VariableCaptureKind::ByRef, baseAddr.getType());
- }
+ }
- mapOperands.push_back(mapOp);
- if (mapSymTypes)
- mapSymTypes->push_back(symAddr.getType());
- if (mapSymLocs)
- mapSymLocs->push_back(symAddr.getLoc());
- if (mapSymbols)
- mapSymbols->push_back(getOmpObjectSymbol(ompObject));
+ mapOperands.push_back(mapOp);
+ if (mapSymTypes)
+ mapSymTypes->push_back(symAddr.getType());
+ if (mapSymLocs)
+ mapSymLocs->push_back(symAddr.getLoc());
+ if (mapSymbols)
+ mapSymbols->push_back(getOmpObjectSymbol(ompObject));
}
});
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/71766
More information about the Mlir-commits
mailing list