[Openmp-commits] [PATCH] D108349: [openmp][devicertl] Freestanding nvptx via stub printf

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 23 15:08:09 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd26000e4cc2b: [openmp][devicertl] Freestanding nvptx via stub printf (authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108349

Files:
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h


Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -12,12 +12,15 @@
 #ifndef _TARGET_IMPL_H_
 #define _TARGET_IMPL_H_
 
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "nvptx_interface.h"
 
+#include <stddef.h>
+#include <stdint.h>
+
+// subset of inttypes.h
+#define PRId64 "ld"
+#define PRIu64 "lu"
+
 typedef uint32_t __kmpc_impl_lanemask_t;
 
 #define INLINE inline __attribute__((always_inline))
@@ -80,4 +83,6 @@
   __kmpc_impl_all_lanes = ~(__kmpc_impl_lanemask_t)0
 };
 
+#define printf(...)
+
 #endif
Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -181,6 +181,11 @@
   return __kmpc_atomic_add(lock, 0u);
 }
 
+extern "C" {
+void *malloc(size_t);
+void free(void *);
+}
+
 EXTERN void *__kmpc_impl_malloc(size_t x) { return malloc(x); }
 EXTERN void __kmpc_impl_free(void *x) { free(x); }
 
Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -10,8 +10,8 @@
 #
 ##===----------------------------------------------------------------------===##
 
-# By default we will not build NVPTX deviceRTL on a CUDA free system
-set(LIBOMPTARGET_BUILD_NVPTX_BCLIB FALSE CACHE BOOL
+# By default we will build NVPTX deviceRTL on a CUDA free system
+set(LIBOMPTARGET_BUILD_NVPTX_BCLIB TRUE CACHE BOOL
   "Whether build NVPTX deviceRTL on CUDA free system.")
 
 if (NOT (LIBOMPTARGET_DEP_CUDA_FOUND OR LIBOMPTARGET_BUILD_NVPTX_BCLIB))
@@ -163,6 +163,7 @@
 # Set flags for LLVM Bitcode compilation.
 set(bc_flags -S -x c++ -O1 -std=c++14
              -mllvm -openmp-opt-disable
+             -ffreestanding
              -target nvptx64
              -Xclang -emit-llvm-bc
              -Xclang -aux-triple -Xclang ${aux_triple}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108349.368220.patch
Type: text/x-patch
Size: 2247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210823/8584a18e/attachment-0001.bin>


More information about the Openmp-commits mailing list