[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
Thu Sep 23 11:28:01 PDT 2021
tianshilei1992 updated this revision to Diff 374633.
tianshilei1992 added a comment.
add `PRINTF` for AMDGCN as well
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
Index: openmp/libomptarget/DeviceRTL/include/Debug.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Debug.h
+++ openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -25,9 +25,24 @@
///}
-// TODO: We need to allow actual printf.
-#define PRINTF(fmt, ...) (void)fmt;
+/// Print
+/// TODO: For now we have to use macros to gaurd the code because Clang lower
+/// `printf` to different function calls on NVPTX and AMDGCN platforms, and it
+/// doesn't work for AMDGCN. After it can work on AMDGCN, we will remove the
+/// macro.
+/// {
+
+#ifndef __AMDGCN__
+extern "C" {
+int printf(const char *format, ...);
+}
+
+#define PRINTF(fmt, ...) (void)printf(fmt, __VA_ARGS__);
#define PRINT(str) PRINTF("%s", str)
+#else
+#define PRINTF(fmt, ...)
+#define PRINT(str)
+#endif
///}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109728.374633.patch
Type: text/x-patch
Size: 842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210923/8110570d/attachment.bin>
More information about the Openmp-commits
mailing list