Skip to content

Commit 3df8911

Browse files
authored
Ensure pointer is copied to target when USM is active (llvm#450)
2 parents a42a22f + f19c328 commit 3df8911

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

offload/libomptarget/omptarget.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,16 @@ int targetDataBegin(ident_t *Loc, DeviceTy &Device, int32_t ArgNum,
488488
ArgsBase[I] = TgtPtrBase;
489489
}
490490

491-
if (ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ && !IsHostPtr)
491+
// The || part of the if condition covers flang dope vectors that
492+
// have different host and target addresses when USM is enabled. The
493+
// pointer to the array is IsHostPtr but the dope vector is not.
494+
// This happens with dope vectors in Fortran modules.
495+
// The pointer has to be copied into the
496+
// target dope vector.
497+
// Perhaps OMP_TGT_MAPTYPE_DESCRIPTOR would help here, not sure.
498+
if ((ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ) &&
499+
(!IsHostPtr || (PointerTpr.getEntry() != nullptr &&
500+
PointerHstPtrBegin != PointerTgtPtrBegin)))
492501
if (prepareAndSubmitData(Device, HstPtrBegin, HstPtrBase, TgtPtrBegin,
493502
PointerTpr, PointerHstPtrBegin,
494503
PointerTgtPtrBegin,

0 commit comments

Comments
 (0)