[Openmp-commits] [openmp] Fixing LIBOMPTARGET_INFO message, for Copying data from device to host (PR #85444)

Felipe Cabarcas via Openmp-commits openmp-commits at lists.llvm.org
Fri Mar 15 11:31:25 PDT 2024


https://github.com/fel-cab created https://github.com/llvm/llvm-project/pull/85444

When running OpenMP offloading application with LIBOMPTARGET_INFO=-1, the addresses of the Copying data from **device** to **host**, the address are swap. 
As an example, Currently the address would be
```
omptarget device 0 info: Mapping exists with HstPtrBegin=0x00007ffddaf0fb90, TgtPtrBegin=0x00007fb385404000, Size=8000, DynRefCount=0 (decremented, delayed deletion), HoldRefCount=0
omptarget device 0 info: Copying data from device to host, TgtPtr=0x00007ffddaf0fb90, HstPtr=0x00007fb385404000, Size=8000, Name=d
```
And it should be
```
omptarget device 0 info: Copying data from device to host, TgtPtr=0x00007fb385404000, HstPtr=0x00007ffddaf0fb90, Size=8000, Name=d
```

>From 38b3bfd8d74256c48c8e8070775160d08a174f03 Mon Sep 17 00:00:00 2001
From: fel-cab <fel-cab at github.com>
Date: Fri, 15 Mar 2024 14:31:39 +0000
Subject: [PATCH] Fixing LIBOMPTARGET_INFO message, Hst and Tgt pointers were
 mixed on the printCopyInfoImpl when the copy was from the device to the host

---
 openmp/libomptarget/src/OpenMP/Mapping.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/openmp/libomptarget/src/OpenMP/Mapping.cpp b/openmp/libomptarget/src/OpenMP/Mapping.cpp
index 9c0b219b6f15f1..1f784b9b90f020 100644
--- a/openmp/libomptarget/src/OpenMP/Mapping.cpp
+++ b/openmp/libomptarget/src/OpenMP/Mapping.cpp
@@ -511,7 +511,8 @@ static void printCopyInfoImpl(int DeviceId, bool H2D, void *SrcPtrBegin,
        "Copying data from %s to %s, %sPtr=" DPxMOD ", %sPtr=" DPxMOD
        ", Size=%" PRId64 ", Name=%s\n",
        H2D ? "host" : "device", H2D ? "device" : "host", H2D ? "Hst" : "Tgt",
-       DPxPTR(SrcPtrBegin), H2D ? "Tgt" : "Hst", DPxPTR(DstPtrBegin), Size,
+       DPxPTR(H2D ? SrcPtrBegin:DstPtrBegin), H2D ? "Tgt" : "Hst", 
+       DPxPTR(H2D ? DstPtrBegin:SrcPtrBegin), Size,
        (HT && HT->HstPtrName) ? getNameFromMapping(HT->HstPtrName).c_str()
                               : "unknown");
 }



More information about the Openmp-commits mailing list