Skip to content

Commit 18e4417

Browse files
[Flang][OpenMP] Fix GenASiS failure for HSA_XNACK=1 and USM mode (llvm#2348)
If the -fopenmp-force-usm mode is attached, the plugin manager does not set the OMPX_REQ_AUTO_ZERO_COPY flag. We need to check both flags if we compile with the -fopenmp-force-usm option.
1 parent a514392 commit 18e4417

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

offload/libomptarget/omptarget.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,10 @@ postProcessingTargetDataEnd(DeviceTy *Device,
600600
// TODO/FIXME: Look into a better longterm solution, such as a different
601601
// mapping combination for descriptors or performing a similar base
602602
// address skip that we've done elsewhere in the omptarget runtime.
603-
bool isZeroCopy = PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY;
604-
if ((*ShadowPtr.HstPtrAddr == nullptr || isZeroCopy) &&
603+
const bool isZeroCopy = PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY;
604+
const bool isUSMMode =
605+
PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY;
606+
if ((*ShadowPtr.HstPtrAddr == nullptr || isZeroCopy || isUSMMode) &&
605607
ShadowPtr.IsDescriptorBaseAddr)
606608
return OFFLOAD_SUCCESS;
607609
*ShadowPtr.HstPtrAddr = ShadowPtr.HstPtrVal;
@@ -854,9 +856,12 @@ static int targetDataContiguous(ident_t *Loc, DeviceTy &Device, void *ArgsBase,
854856
// different mapping combination for descriptors or performing a
855857
// similar base address skip that we've done elsewhere in the
856858
// omptarget runtime.
857-
bool isZeroCopy =
859+
const bool isZeroCopy =
858860
PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY;
859-
if ((*ShadowPtr.HstPtrAddr == nullptr || isZeroCopy) &&
861+
const bool isUSMMode =
862+
PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY;
863+
if ((*ShadowPtr.HstPtrAddr == nullptr || isZeroCopy ||
864+
isUSMMode) &&
860865
ShadowPtr.IsDescriptorBaseAddr)
861866
return OFFLOAD_SUCCESS;
862867
*ShadowPtr.HstPtrAddr = ShadowPtr.HstPtrVal;

0 commit comments

Comments
 (0)