From 786a140650990ce9f760da5ffeb5fad0b93687d9 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Wed, 1 Sep 2021 16:24:39 -0400 Subject: [PATCH] [OpenMP] Use IsHostPtr where needed in rest of omptarget.cpp As started in D107925, this patch replaces the remaining occurrences of `UNIFIED_SHARED_MEMORY && TgtPtrBegin == HstPtrBegin` in `omptarget.cpp` with `IsHostPtr`. The former condition is broken in the rare case that the device and host happen to use the same address for their mapped allocations. I don't know how to write a test that's likely to reveal this case. Reviewed By: grokos Differential Revision: https://reviews.llvm.org/D107928 --- openmp/libomptarget/src/omptarget.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp index 55b840a..846c4d5 100644 --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -833,8 +833,7 @@ static int targetDataContiguous(ident_t *loc, DeviceTy &Device, void *ArgsBase, return OFFLOAD_SUCCESS; } - if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY && - TgtPtrBegin == HstPtrBegin) { + if (IsHostPtr) { DP("hst data:" DPxMOD " unified and shared, becomes a noop\n", DPxPTR(HstPtrBegin)); return OFFLOAD_SUCCESS; @@ -1273,7 +1272,7 @@ static int processDataBefore(ident_t *loc, int64_t DeviceId, void *HostPtr, void *HstPtrVal = Args[I]; void *HstPtrBegin = ArgBases[I]; void *HstPtrBase = Args[Idx]; - bool IsLast, IsHostPtr; // unused. + bool IsLast, IsHostPtr; // IsLast is unused. void *TgtPtrBase = (void *)((intptr_t)TgtArgs[TgtIdx] + TgtOffsets[TgtIdx]); DP("Parent lambda base " DPxMOD "\n", DPxPTR(TgtPtrBase)); @@ -1288,8 +1287,7 @@ static int processDataBefore(ident_t *loc, int64_t DeviceId, void *HostPtr, DPxPTR(HstPtrVal)); continue; } - if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY && - TgtPtrBegin == HstPtrBegin) { + if (IsHostPtr) { DP("Unified memory is active, no need to map lambda captured" "variable (" DPxMOD ")\n", DPxPTR(HstPtrVal)); -- 2.7.4