-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Flang][MLIR][OpenMP] Allow setting OMP_MAP_PTR_AND_OBJ by frontends #84328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,10 @@ bool ClauseProcessor::processMotionClauses( | |
| : llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM; | ||
|
|
||
| for (const Fortran::parser::OmpObject &ompObject : motionClause->v.v) { | ||
| llvm::omp::OpenMPOffloadMappingFlags objectsMapTypeBits = mapTypeBits; | ||
| checkAndApplyDeclTargetMapFlags(converter, objectsMapTypeBits, | ||
| *getOmpObjectSymbol(ompObject)); | ||
|
|
||
| llvm::SmallVector<mlir::Value> bounds; | ||
| std::stringstream asFortran; | ||
| Fortran::lower::AddrAndBoundsInfo info = | ||
|
|
@@ -226,7 +230,7 @@ bool ClauseProcessor::processMotionClauses( | |
| asFortran.str(), bounds, {}, | ||
| static_cast< | ||
| std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>( | ||
|
||
| mapTypeBits), | ||
| objectsMapTypeBits), | ||
| mlir::omp::VariableCaptureKind::ByRef, symAddr.getType()); | ||
|
|
||
| mapOperands.push_back(mapOp); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,22 @@ namespace Fortran { | |
| namespace lower { | ||
| namespace omp { | ||
|
|
||
| void checkAndApplyDeclTargetMapFlags( | ||
|
||
| Fortran::lower::AbstractConverter &converter, | ||
| llvm::omp::OpenMPOffloadMappingFlags &mapFlags, | ||
| const Fortran::semantics::Symbol &symbol) { | ||
| if (auto declareTargetOp = | ||
| llvm::dyn_cast_if_present<mlir::omp::DeclareTargetInterface>( | ||
| converter.getModuleOp().lookupSymbol( | ||
| converter.mangleName(symbol)))) { | ||
|
||
| // Only Link clauses have OMP_MAP_PTR_AND_OBJ applied, To clause | ||
| // seems to function differently. | ||
| if (declareTargetOp.getDeclareTargetCaptureClause() == | ||
|
||
| mlir::omp::DeclareTargetCaptureClause::link) | ||
| mapFlags |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ; | ||
| } | ||
| } | ||
|
|
||
| void genObjectList(const Fortran::parser::OmpObjectList &objectList, | ||
| Fortran::lower::AbstractConverter &converter, | ||
| llvm::SmallVectorImpl<mlir::Value> &operands) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| #include "mlir/Pass/Pass.h" | ||
| #include "mlir/Support/LLVM.h" | ||
| #include "llvm/ADT/SmallPtrSet.h" | ||
| #include "llvm/Frontend/OpenMP/OMPConstants.h" | ||
| #include <iterator> | ||
|
|
||
| namespace fir { | ||
|
|
@@ -76,15 +77,23 @@ class OMPDescriptorMapInfoGenPass | |
| mlir::Value baseAddrAddr = builder.create<fir::BoxOffsetOp>( | ||
| loc, descriptor, fir::BoxFieldAttr::base_addr); | ||
|
|
||
| llvm::omp::OpenMPOffloadMappingFlags baseAddrMapFlag = | ||
| llvm::omp::OpenMPOffloadMappingFlags(op.getMapType().value()); | ||
| baseAddrMapFlag |= | ||
| llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ; | ||
|
|
||
| // Member of the descriptor pointing at the allocated data | ||
| mlir::Value baseAddr = builder.create<mlir::omp::MapInfoOp>( | ||
| loc, baseAddrAddr.getType(), descriptor, | ||
| llvm::cast<mlir::omp::PointerLikeType>( | ||
| fir::unwrapRefType(baseAddrAddr.getType())) | ||
| .getElementType(), | ||
| baseAddrAddr, mlir::SmallVector<mlir::Value>{}, op.getBounds(), | ||
| builder.getIntegerAttr(builder.getIntegerType(64, false), | ||
| op.getMapType().value()), | ||
| builder.getIntegerAttr( | ||
| builder.getIntegerType(64, false), | ||
| static_cast< | ||
| std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>( | ||
|
||
| baseAddrMapFlag)), | ||
| builder.getAttr<mlir::omp::VariableCaptureKindAttr>( | ||
| mlir::omp::VariableCaptureKind::ByRef), | ||
| builder.getStringAttr("") /*name*/); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you perhaps add a "using" alias for the underlying type and use it here? This would improve the readability a bit.