diff --git a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt --- a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt +++ b/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)) @@ -154,6 +154,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} diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h --- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h +++ b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h @@ -12,12 +12,15 @@ #ifndef _TARGET_IMPL_H_ #define _TARGET_IMPL_H_ -#include -#include -#include - #include "nvptx_interface.h" +#include +#include + +// subset of inttypes.h +#define PRId64 "ld" +#define PRIu64 "lu" + #define INLINE inline __attribute__((always_inline)) #define NOINLINE __attribute__((noinline)) #define ALIGN(N) __attribute__((aligned(N))) @@ -77,4 +80,6 @@ __kmpc_impl_all_lanes = ~(__kmpc_impl_lanemask_t)0 }; +#define printf(...) + #endif diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu --- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu +++ b/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); }