[flang-commits] [flang] [MLIR][OpenMP] Add Lowering support for implicitly linking to default declare mappers (PR #131006)
Akash Banerjee via flang-commits
flang-commits at lists.llvm.org
Mon Mar 17 10:34:57 PDT 2025
================
@@ -978,6 +960,42 @@ void ClauseProcessor::processMapObjects(
}
}
+ // Create the mapper symbol from its name, if specified.
+ mlir::FlatSymbolRefAttr mapperId;
+ if (!mapperIdNameRef.empty()) {
+ std::string mapperIdName = mapperIdNameRef.str();
+ if (mapperIdNameRef == "implicit" || mapperIdNameRef == "default") {
+ if (!mlir::isa<mlir::omp::DeclareMapperOp>(
+ firOpBuilder.getRegion().getParentOp())) {
+ const semantics::DerivedTypeSpec *typeSpec = nullptr;
+
+ if (object.sym()->owner().IsDerivedType())
+ typeSpec = object.sym()->owner().derivedTypeSpec();
+ else if (object.sym()->GetType() &&
+ object.sym()->GetType()->category() ==
+ semantics::DeclTypeSpec::TypeDerived)
+ typeSpec = &object.sym()->GetType()->derivedTypeSpec();
+
+ if (typeSpec) {
+ mapperIdName = typeSpec->name().ToString() + ".default";
+ mapperIdName =
+ converter.mangleName(mapperIdName, *typeSpec->GetScope());
+ }
+ }
+ }
+ if (mapperIdNameRef == "implicit") {
+ mapperId = converter.getModuleOp().lookupSymbol(mapperIdName)
+ ? mlir::FlatSymbolRefAttr::get(
+ &converter.getMLIRContext(), mapperIdName)
+ : mlir::FlatSymbolRefAttr();
+ } else {
+ assert(converter.getModuleOp().lookupSymbol(mapperIdName) &&
+ "mapper not found");
+ mapperId = mlir::FlatSymbolRefAttr::get(&converter.getMLIRContext(),
+ mapperIdName);
+ }
+ }
----------------
TIFitis wrote:
Hi, case 1 doesn't require any separate code execution so ignoring that.
For "default" and case 3 we could move this outside the loop, but then as Kareem pointed out, the code for "default" and "implicit" is similar so we would either end up duplicating it or adding a new lambda for it. Overall, I feel like keeping the entire logic in a single place would be easier to follow than splitting between inside and outside the loop.
We would at most benefit from executing one less if condition inside the loop by doing this and this is mostly expected to loop for single-digits.
Let me know if you still feel like splitting it and I'd be happy to do so :)
https://github.com/llvm/llvm-project/pull/131006
More information about the flang-commits
mailing list