[flang-commits] [flang] [flang] Changes to map variables in link clause of declare target (PR #83643)
via flang-commits
flang-commits at lists.llvm.org
Fri Mar 1 20:24:35 PST 2024
================
@@ -1120,7 +1120,21 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
if (auto refType = baseOp.getType().dyn_cast<fir::ReferenceType>())
eleType = refType.getElementType();
- if (fir::isa_trivial(eleType) || fir::isa_char(eleType)) {
+ // If a variable is specified in declare target link and if device
+ // type is nohost, it needs to be mapped tofrom
+ mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
+ mlir::Operation *op = mod.lookupSymbol(converter.mangleName(sym));
+ auto declareTargetOp =
+ llvm::dyn_cast_if_present<mlir::omp::DeclareTargetInterface>(op);
+ if (declareTargetOp && declareTargetOp.isDeclareTarget()) {
+ if (declareTargetOp.getDeclareTargetCaptureClause() ==
+ mlir::omp::DeclareTargetCaptureClause::link &&
+ declareTargetOp.getDeclareTargetDeviceType() !=
----------------
agozillon wrote:
Great work! However, should this be an `==` rather than a `!=` or is the comment at line 1123~ misworded (there's also a chance I am misreading something as it's very late on a Friday, so I appologies if that's the case!). Going off of the PR description I'd wager the comment might need a little rewording from "and if device type is nohost" to "and if device type is **not** nohost"
Otherwise, this PR looks good to me, I'll give it a little test on Monday on the local map tests I have just to be sure and await your reply to the above comment before signing off on it fully!
https://github.com/llvm/llvm-project/pull/83643
More information about the flang-commits
mailing list