[Openmp-commits] [PATCH] D109886: [OpenMP] Implement __assert_fail in the new device runtime

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Sep 16 07:39:12 PDT 2021


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

This patch implements the `__assert_fail` function in the new device
runtime. This allows users and developers to use the standars assert
function inside of the device.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109886

Files:
  openmp/libomptarget/DeviceRTL/include/Debug.h
  openmp/libomptarget/DeviceRTL/src/Debug.cpp


Index: openmp/libomptarget/DeviceRTL/src/Debug.cpp
===================================================================
--- openmp/libomptarget/DeviceRTL/src/Debug.cpp
+++ openmp/libomptarget/DeviceRTL/src/Debug.cpp
@@ -26,6 +26,12 @@
 
   __builtin_assume(cond);
 }
+
+void __assert_fail(const char *assertion, const char *file, unsigned line,
+                   const char *function) {
+  PRINTF("%s:%u: %s: Assertion `%s' failed.\n", file, line, function,
+         assertion);
+}
 }
 
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Debug.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Debug.h
+++ openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -17,6 +17,8 @@
 /// {
 extern "C" {
 void __assert_assume(bool cond, const char *exp, const char *file, int line);
+void __assert_fail(const char *assertion, const char *file, unsigned line,
+                   const char *function);
 }
 
 #define ASSERT(e) __assert_assume(e, #e, __FILE__, __LINE__)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109886.372941.patch
Type: text/x-patch
Size: 1046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210916/61de1ca5/attachment.bin>


More information about the Openmp-commits mailing list