[Openmp-commits] [PATCH] D87722: [OpenMP] Additional Information for Libomptarget Device Mappings
Joseph Huber via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Sep 15 14:43:48 PDT 2020
jhuber6 updated this revision to Diff 292029.
jhuber6 added a comment.
Herald added a reviewer: gkistanova.
Merged calls to a single function. Made it not print out if the table is empty.
Repository:
rZORG LLVM Github Zorg
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87722/new/
https://reviews.llvm.org/D87722
Files:
openmp/libomptarget/src/device.cpp
openmp/libomptarget/src/interface.cpp
openmp/libomptarget/src/private.h
Index: openmp/libomptarget/src/private.h
===================================================================
--- openmp/libomptarget/src/private.h
+++ openmp/libomptarget/src/private.h
@@ -96,4 +96,20 @@
#define TARGET_NAME Libomptarget
#define DEBUG_PREFIX GETNAME(TARGET_NAME)
+////////////////////////////////////////////////////////////////////////////////
+/// dump a table of all the host-target pointer pairs on failure
+static inline void dumpTargetPointerMappings(const DeviceTy &Device) {
+ if (Device.HostDataToTargetMap.empty())
+ return;
+
+ fprintf(stderr, "Device %d Host-Device Pointer Mappings:\n", Device.DeviceID);
+ fprintf(stderr, "%-18s %-18s %s\n", "Host Ptr", "Target Ptr", "Size (B)");
+ for (const auto &HostTargetMap : Device.HostDataToTargetMap) {
+ fprintf(stderr, DPxMOD " " DPxMOD " %lu\n",
+ DPxPTR(HostTargetMap.HstPtrBegin),
+ DPxPTR(HostTargetMap.TgtPtrBegin),
+ HostTargetMap.HstPtrEnd - HostTargetMap.HstPtrBegin);
+ }
+}
+
#endif
Index: openmp/libomptarget/src/interface.cpp
===================================================================
--- openmp/libomptarget/src/interface.cpp
+++ openmp/libomptarget/src/interface.cpp
@@ -24,21 +24,6 @@
kmp_target_offload_kind_t TargetOffloadPolicy = tgt_default;
std::mutex TargetOffloadMtx;
-////////////////////////////////////////////////////////////////////////////////
-/// dump a table of all the host-target pointer pairs on failure
-static void dumpTargetPointerMappings() {
- for (const auto &Device : Devices) {
- fprintf(stderr, "Device %d:\n", Device.DeviceID);
- fprintf(stderr, "%-18s %-18s %s\n", "Host Ptr", "Target Ptr", "Size (B)");
- for (const auto &HostTargetMap : Device.HostDataToTargetMap) {
- fprintf(stderr, DPxMOD " " DPxMOD " %lu\n",
- DPxPTR(HostTargetMap.HstPtrBegin),
- DPxPTR(HostTargetMap.TgtPtrBegin),
- HostTargetMap.HstPtrEnd - HostTargetMap.HstPtrBegin);
- }
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
/// manage the success or failure of a target construct
static void HandleDefaultTargetOffload() {
@@ -76,9 +61,11 @@
case tgt_mandatory:
if (!success) {
if (getInfoLevel() > 1)
- dumpTargetPointerMappings();
+ for (const auto &Device : Devices)
+ dumpTargetPointerMappings(Device);
else
- FAILURE_MESSAGE("run with env LIBOMPTARGET_INFO>1 to dump tables\n");
+ FAILURE_MESSAGE("run with env LIBOMPTARGET_INFO>1 to dump host-target"
+ "pointer maps\n");
FATAL_MESSAGE0(1, "failure of target construct while offloading is mandatory");
}
Index: openmp/libomptarget/src/device.cpp
===================================================================
--- openmp/libomptarget/src/device.cpp
+++ openmp/libomptarget/src/device.cpp
@@ -17,6 +17,7 @@
#include <cassert>
#include <climits>
+#include <cstdio>
#include <string>
/// Map between Device ID (i.e. openmp device id) and its DeviceTy.
@@ -50,7 +51,12 @@
ShadowPtrMap(), DataMapMtx(), PendingGlobalsMtx(), ShadowMtx(),
MemoryManager(nullptr) {}
-DeviceTy::~DeviceTy() = default;
+DeviceTy::~DeviceTy() {
+ if (DeviceID == -1 || getInfoLevel() < 1)
+ return;
+
+ dumpTargetPointerMappings(*this);
+}
int DeviceTy::associatePtr(void *HstPtrBegin, void *TgtPtrBegin, int64_t Size) {
DataMapMtx.lock();
@@ -214,7 +220,7 @@
HT.incRefCount();
uintptr_t tp = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin);
- DP("Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD ", "
+ INFO(DeviceID, "Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD ", "
"Size=%" PRId64 ",%s RefCount=%s\n", (IsImplicit ? " (implicit)" : ""),
DPxPTR(HstPtrBegin), DPxPTR(tp), Size,
(UpdateRefCount ? " updated" : ""),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87722.292029.patch
Type: text/x-patch
Size: 3964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200915/beec1b99/attachment-0001.bin>
More information about the Openmp-commits
mailing list