[Openmp-commits] [openmp] 119a9ea - [OpenMP] Fix failing test due to change in offloading flags

via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 21 11:09:49 PST 2021


Author: Joseph Huber
Date: 2021-01-21T14:09:36-05:00
New Revision: 119a9ea13f9f2e5fe78125bc3f9a76ebf85d3270

URL: https://github.com/llvm/llvm-project/commit/119a9ea13f9f2e5fe78125bc3f9a76ebf85d3270
DIFF: https://github.com/llvm/llvm-project/commit/119a9ea13f9f2e5fe78125bc3f9a76ebf85d3270.diff

LOG: [OpenMP] Fix failing test due to change in offloading flags

Summary:
Prior to D91261 the information checked the OMP_MAP_TARGET_PARAM flag, change this as it has been removed. The INFO macro was changed to accept a flag as input to make conditionally printing information easier.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D95133

Added: 
    

Modified: 
    openmp/libomptarget/include/Debug.h
    openmp/libomptarget/plugins/cuda/src/rtl.cpp
    openmp/libomptarget/src/device.cpp
    openmp/libomptarget/src/private.h

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/include/Debug.h b/openmp/libomptarget/include/Debug.h
index de593ecf5c3e..a2bb419f0656 100644
--- a/openmp/libomptarget/include/Debug.h
+++ b/openmp/libomptarget/include/Debug.h
@@ -47,8 +47,10 @@ enum OpenMPInfoType : uint32_t {
   OMP_INFOTYPE_MAPPING_EXISTS = 0x0002,
   // Dump the contents of the device pointer map at kernel exit or failure.
   OMP_INFOTYPE_DUMP_TABLE = 0x0004,
-  // Print kernel information from target device plugins
+  // Print kernel information from target device plugins.
   OMP_INFOTYPE_PLUGIN_KERNEL = 0x0010,
+  // Enable every flag.
+  OMP_INFOTYPE_ALL = 0xffffffff,
 };
 
 static inline uint32_t getInfoLevel() {
@@ -161,11 +163,11 @@ static inline uint32_t getDebugLevel() {
 #endif // OMPTARGET_DEBUG
 
 /// Emit a message giving the user extra information about the runtime if
-#define INFO(_id, ...)                                                         \
+#define INFO(_flags, _id, ...)                                                 \
   do {                                                                         \
     if (getDebugLevel() > 0) {                                                 \
       DEBUGP(DEBUG_PREFIX, __VA_ARGS__);                                       \
-    } else if (getInfoLevel() > 0) {                                           \
+    } else if (getInfoLevel() & _flags) {                                      \
       INFO_MESSAGE(_id, __VA_ARGS__);                                          \
     }                                                                          \
   } while (false)

diff  --git a/openmp/libomptarget/plugins/cuda/src/rtl.cpp b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
index 92bbf43d96c1..e4ac1e0820e6 100644
--- a/openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -580,7 +580,7 @@ class DeviceRTLTy {
       DeviceData[DeviceId].BlocksPerGrid = EnvTeamLimit;
     }
 
-    INFO(DeviceId,
+    INFO(OMP_INFOTYPE_PLUGIN_KERNEL, DeviceId,
          "Device supports up to %d CUDA blocks and %d threads with a "
          "warp size of %d\n",
          DeviceData[DeviceId].BlocksPerGrid,
@@ -1004,7 +1004,7 @@ class DeviceRTLTy {
       CudaBlocksPerGrid = TeamNum;
     }
 
-    INFO(DeviceId,
+    INFO(OMP_INFOTYPE_PLUGIN_KERNEL, DeviceId,
          "Launching kernel %s with %d blocks and %d threads in %s "
          "mode\n",
          (getOffloadEntry(DeviceId, TgtEntryPtr))

diff  --git a/openmp/libomptarget/src/device.cpp b/openmp/libomptarget/src/device.cpp
index 93c82e30ec1a..ee90bc647f4d 100644
--- a/openmp/libomptarget/src/device.cpp
+++ b/openmp/libomptarget/src/device.cpp
@@ -216,16 +216,14 @@ void *DeviceTy::getOrAllocTgtPtr(void *HstPtrBegin, void *HstPtrBase,
       HT.incRefCount();
 
     uintptr_t tp = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin);
-    if (getDebugLevel() || getInfoLevel() & OMP_INFOTYPE_MAPPING_EXISTS)
-      INFO(DeviceID,
-           "Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD
-           ", "
-           "Size=%" PRId64 ",%s RefCount=%s, Name=%s\n",
-           (IsImplicit ? " (implicit)" : ""), DPxPTR(HstPtrBegin), DPxPTR(tp),
-           Size, (UpdateRefCount ? " updated" : ""),
-           HT.isRefCountInf() ? "INF"
-                              : std::to_string(HT.getRefCount()).c_str(),
-           (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
+    INFO(OMP_INFOTYPE_MAPPING_EXISTS, DeviceID,
+         "Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD
+         ", "
+         "Size=%" PRId64 ",%s RefCount=%s, Name=%s\n",
+         (IsImplicit ? " (implicit)" : ""), DPxPTR(HstPtrBegin), DPxPTR(tp),
+         Size, (UpdateRefCount ? " updated" : ""),
+         HT.isRefCountInf() ? "INF" : std::to_string(HT.getRefCount()).c_str(),
+         (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
     rc = (void *)tp;
   } else if ((lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter) && !IsImplicit) {
     // Explicit extension of mapped data - not allowed.

diff  --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h
index 22672987ae29..6a44dd9e450e 100644
--- a/openmp/libomptarget/src/private.h
+++ b/openmp/libomptarget/src/private.h
@@ -101,14 +101,15 @@ static inline void dumpTargetPointerMappings(const ident_t *Loc,
     return;
 
   SourceInfo Kernel(Loc);
-  INFO(Device.DeviceID,
+  INFO(OMP_INFOTYPE_ALL, Device.DeviceID,
        "OpenMP Host-Device pointer mappings after block at %s:%d:%d:\n",
        Kernel.getFilename(), Kernel.getLine(), Kernel.getColumn());
-  INFO(Device.DeviceID, "%-18s %-18s %s %s %s\n", "Host Ptr", "Target Ptr",
-       "Size (B)", "RefCount", "Declaration");
+  INFO(OMP_INFOTYPE_ALL, Device.DeviceID, "%-18s %-18s %s %s %s\n", "Host Ptr",
+       "Target Ptr", "Size (B)", "RefCount", "Declaration");
   for (const auto &HostTargetMap : Device.HostDataToTargetMap) {
     SourceInfo Info(HostTargetMap.HstPtrName);
-    INFO(Device.DeviceID, DPxMOD " " DPxMOD " %-8lu %-8ld %s at %s:%d:%d\n",
+    INFO(OMP_INFOTYPE_ALL, Device.DeviceID,
+         DPxMOD " " DPxMOD " %-8lu %-8ld %s at %s:%d:%d\n",
          DPxPTR(HostTargetMap.HstPtrBegin), DPxPTR(HostTargetMap.TgtPtrBegin),
          (long unsigned)(HostTargetMap.HstPtrEnd - HostTargetMap.HstPtrBegin),
          HostTargetMap.getRefCount(), Info.getName(), Info.getFilename(),
@@ -124,8 +125,9 @@ printKernelArguments(const ident_t *Loc, const int64_t DeviceId,
                      const int64_t *ArgTypes, const map_var_info_t *ArgNames,
                      const char *RegionType) {
   SourceInfo info(Loc);
-  INFO(DeviceId, "%s at %s:%d:%d with %d arguments:\n", RegionType,
-       info.getFilename(), info.getLine(), info.getColumn(), ArgNum);
+  INFO(OMP_INFOTYPE_ALL, DeviceId, "%s at %s:%d:%d with %d arguments:\n",
+       RegionType, info.getFilename(), info.getLine(), info.getColumn(),
+       ArgNum);
 
   for (int32_t i = 0; i < ArgNum; ++i) {
     const map_var_info_t varName = (ArgNames) ? ArgNames[i] : nullptr;
@@ -142,12 +144,12 @@ printKernelArguments(const ident_t *Loc, const int64_t DeviceId,
       type = "private";
     else if (ArgTypes[i] & OMP_TGT_MAPTYPE_LITERAL)
       type = "firstprivate";
-    else if (ArgTypes[i] & OMP_TGT_MAPTYPE_TARGET_PARAM && ArgSizes[i] != 0)
+    else if (ArgSizes[i] != 0)
       type = "alloc";
     else
       type = "use_address";
 
-    INFO(DeviceId, "%s(%s)[%ld] %s\n", type,
+    INFO(OMP_INFOTYPE_ALL, DeviceId, "%s(%s)[%ld] %s\n", type,
          getNameFromMapping(varName).c_str(), ArgSizes[i], implicit);
   }
 }


        


More information about the Openmp-commits mailing list