[flang-commits] [flang] [Flang][OpenMP] Fix USM `close` semantics and `use_device_ptr` (PR #163258)
Akash Banerjee via flang-commits
flang-commits at lists.llvm.org
Tue Oct 14 08:24:19 PDT 2025
================
@@ -425,8 +426,23 @@ class MapInfoFinalizationPass
mapFlags flags = mapFlags::OMP_MAP_TO |
(mapFlags(mapTypeFlag) &
- (mapFlags::OMP_MAP_IMPLICIT | mapFlags::OMP_MAP_CLOSE |
- mapFlags::OMP_MAP_ALWAYS));
+ (mapFlags::OMP_MAP_IMPLICIT | mapFlags::OMP_MAP_ALWAYS));
+ // For unified_shared_memory, we additionally add `CLOSE` on the descriptor
+ // to ensure device-local placement where required by tests relying on USM +
+ // close semantics.
+ if (target) {
+ if (auto mod = target->getParentOfType<mlir::ModuleOp>()) {
----------------
TIFitis wrote:
> Could be worth mentioning that we have a little check downstream currently (that I think I've added to an upstream PR recently that's not landed yet). That will prevent always + close being applied at the same time, as it was causing some mapping issues for the runtime in certain cases, not sure that's applicable here but just incase it crops up for whatever reason!
Thanks, I'll revisit when it lands upstream.
> Nit: Might be nice to put this check logic into a helper function just to keep the logic in this function as simple as it can be, all of the bit flags can already be a little difficult to follow! :-) Just a small suggestion though if it makes sense.
I've refactored this to add a utility func.
https://github.com/llvm/llvm-project/pull/163258
More information about the flang-commits
mailing list