[Openmp-commits] [PATCH] D112005: [OpenMP] Check output of malloc in the device for debug

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 18 10:04:44 PDT 2021


jhuber6 updated this revision to Diff 380454.
jhuber6 added a comment.

Making suggested changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112005/new/

https://reviews.llvm.org/D112005

Files:
  openmp/libomptarget/DeviceRTL/include/Configuration.h
  openmp/libomptarget/DeviceRTL/src/State.cpp


Index: openmp/libomptarget/DeviceRTL/src/State.cpp
===================================================================
--- openmp/libomptarget/DeviceRTL/src/State.cpp
+++ openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -162,7 +162,11 @@
 }
 
 void *memory::allocGlobal(uint64_t Bytes, const char *Reason) {
-  return malloc(Bytes);
+  void *Ptr = malloc(Bytes);
+  if (config::isDebugMode(config::DebugKind::CommonIssues) &&
+      Ptr == nullptr)
+    PRINT ("Nullptr returned by Malloc!\n");
+  return Ptr;
 }
 
 void memory::freeGlobal(void *Ptr, const char *Reason) { free(Ptr); }
Index: openmp/libomptarget/DeviceRTL/include/Configuration.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Configuration.h
+++ openmp/libomptarget/DeviceRTL/include/Configuration.h
@@ -21,6 +21,7 @@
 enum DebugKind : uint32_t {
   Assertion = 1U << 0,
   FunctionTracing = 1U << 1,
+  CommonIssues = 1U << 2,
 };
 
 /// Return the number of devices in the system, same number as returned on the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112005.380454.patch
Type: text/x-patch
Size: 1043 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211018/83c1eec9/attachment.bin>


More information about the Openmp-commits mailing list