diff --git a/openmp/libomptarget/src/device.cpp b/openmp/libomptarget/src/device.cpp --- a/openmp/libomptarget/src/device.cpp +++ b/openmp/libomptarget/src/device.cpp @@ -245,11 +245,12 @@ const char *HoldRefCountAction = HasHoldModifier ? RefCountAction : ""; uintptr_t Ptr = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin); INFO(OMP_INFOTYPE_MAPPING_EXISTS, DeviceID, - "Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD - ", Size=%" PRId64 ", DynRefCount=%s%s, HoldRefCount=%s%s, Name=%s\n", - (IsImplicit ? " (implicit)" : ""), DPxPTR(HstPtrBegin), DPxPTR(Ptr), - Size, HT.dynRefCountToStr().c_str(), DynRefCountAction, - HT.holdRefCountToStr().c_str(), HoldRefCountAction, + "Mapping exists%s with HstPtrBase=" DPxMOD ", HstPtrBegin=" DPxMOD + ", TgtPtrBegin=" DPxMOD ", Size=%" PRId64 + ", DynRefCount=%s%s, HoldRefCount=%s%s, Name=%s\n", + (IsImplicit ? " (implicit)" : ""), DPxPTR(HstPtrBase), + DPxPTR(HstPtrBegin), DPxPTR(Ptr), Size, HT.dynRefCountToStr().c_str(), + DynRefCountAction, HT.holdRefCountToStr().c_str(), HoldRefCountAction, (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown"); TargetPointer = (void *)Ptr; } else if ((LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) && !IsImplicit) { diff --git a/openmp/libomptarget/test/mapping/three_chunks_of_one_array.c b/openmp/libomptarget/test/mapping/three_chunks_of_one_array.c new file mode 100644 --- /dev/null +++ b/openmp/libomptarget/test/mapping/three_chunks_of_one_array.c @@ -0,0 +1,32 @@ +// RUN: %libomptarget-compilexx-run-and-check-generic + +#include +#include + +int main() { + int *mem = (int *)malloc(32 * sizeof(int)); + mem[0] = 1; + mem[5] = 11; + mem[20] = 21; +#pragma omp target data map(to : mem [20:10], mem [5:5]) map(to : mem[0]) + { +#pragma omp parallel +#pragma omp single + { +#pragma omp target map(always, from : mem[0]) nowait + { mem[0] = 2; } +#pragma omp target map(always, from : mem [5:5]) nowait + { mem[5] = 12; } +#pragma omp target map(always, from : mem [20:10]) nowait + { mem[20] = 22; } + } + // CHECK: mem[0] 2 + printf("mem[0] %d\n", mem[0]); + // CHECK: mem[5] 12 + printf("mem[5] %d\n", mem[5]); + // CHECK: mem[20] 22 + printf("mem[20] %d\n", mem[20]); + } + + return 0; +}