[Openmp-commits] [PATCH] D109728: [OpenMP][DeviceRTL] Add the support for printf in a freestanding way

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Sep 13 17:22:21 PDT 2021


tianshilei1992 updated this revision to Diff 372369.
tianshilei1992 added a comment.

fixed wrong implementation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109728

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
@@ -28,4 +28,16 @@
 }
 }
 
+/// AMDGCN implementations of the printf.
+///
+///{
+#pragma omp begin declare variant match(device = {arch(amdgcn)})
+
+extern "C" {
+int vprintf(const char *format, __builtin_va_list args) { return 0; }
+}
+
+#pragma omp end declare variant
+///}
+
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Debug.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Debug.h
+++ openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -23,8 +23,16 @@
 
 ///}
 
-// TODO: We need to allow actual printf.
-#define PRINTF(fmt, ...) (void)fmt;
+/// Print
+/// {
+extern "C" {
+int printf(const char *format, ...);
+int vprintf(const char *format, __builtin_va_list args);
+}
+
+#define PRINTF(fmt, ...) (void)printf(fmt, __VA_ARGS__);
 #define PRINT(str) PRINTF("%s", str)
 
+///}
+
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109728.372369.patch
Type: text/x-patch
Size: 1103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210914/e6d75cc4/attachment.bin>


More information about the Openmp-commits mailing list