[Openmp-commits] [openmp] cfd1816 - Revert "[Libomptarget] Use freestanding stdint.h header for DeviceRTL"

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 13 12:17:15 PDT 2023


Author: Joseph Huber
Date: 2023-03-13T14:17:05-05:00
New Revision: cfd18167c8b9d4922e99aed7241a86eb02bc653d

URL: https://github.com/llvm/llvm-project/commit/cfd18167c8b9d4922e99aed7241a86eb02bc653d
DIFF: https://github.com/llvm/llvm-project/commit/cfd18167c8b9d4922e99aed7241a86eb02bc653d.diff

LOG: Revert "[Libomptarget] Use freestanding stdint.h header for DeviceRTL"

This patch breaks the handling of `printf` in the OpenMP library. Usiing
`-ffreestanding` prevents clang from emitting LLVM builtins, which we
use for OpenMP printing support. Shelve this until we have functioning
`printf` in the GPU `libc` and we can remove that code.

This reverts commit a92eaa3ebee6ff85549e8f1c50da4958dbbdcb30.

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/CMakeLists.txt
    openmp/libomptarget/DeviceRTL/include/Types.h

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index b36caf9fc5645..53da2661011e5 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -121,7 +121,7 @@ list(TRANSFORM LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL PREPEND "-I")
 # Set flags for LLVM Bitcode compilation.
 set(bc_flags -c -foffload-lto -std=c++17 -fvisibility=hidden
               ${clang_opt_flags} --offload-device-only
-             -nocudalib -nogpulib -nogpuinc -ffreestanding
+             -nocudalib -nogpulib -nostdinc
              -fopenmp -fopenmp-cuda-mode
              -Wno-unknown-cuda-version
              -I${include_directory}

diff  --git a/openmp/libomptarget/DeviceRTL/include/Types.h b/openmp/libomptarget/DeviceRTL/include/Types.h
index 76e8090fc3afc..628755bc55ed5 100644
--- a/openmp/libomptarget/DeviceRTL/include/Types.h
+++ b/openmp/libomptarget/DeviceRTL/include/Types.h
@@ -12,10 +12,6 @@
 #ifndef OMPTARGET_TYPES_H
 #define OMPTARGET_TYPES_H
 
-#include <stdint.h>
-
-using size_t = decltype(sizeof(char));
-
 // Tell the compiler that we do not have any "call-like" inline assembly in the
 // device rutime. That means we cannot have inline assembly which will call
 // another function but only inline assembly that performs some operation or
@@ -25,6 +21,31 @@ using size_t = decltype(sizeof(char));
 // TODO: Find a good place for this
 #pragma omp assumes ext_no_call_asm
 
+/// Base type declarations for freestanding mode
+///
+///{
+using int8_t = char;
+using uint8_t = unsigned char;
+using int16_t = short;
+using uint16_t = unsigned short;
+using int32_t = int;
+using uint32_t = unsigned int;
+using int64_t = long;
+using uint64_t = unsigned long;
+using size_t = decltype(sizeof(char));
+// TODO: Properly implement this
+using intptr_t = int64_t;
+using uintptr_t = uint64_t;
+
+static_assert(sizeof(int8_t) == 1, "type size mismatch");
+static_assert(sizeof(uint8_t) == 1, "type size mismatch");
+static_assert(sizeof(int16_t) == 2, "type size mismatch");
+static_assert(sizeof(uint16_t) == 2, "type size mismatch");
+static_assert(sizeof(int32_t) == 4, "type size mismatch");
+static_assert(sizeof(uint32_t) == 4, "type size mismatch");
+static_assert(sizeof(int64_t) == 8, "type size mismatch");
+static_assert(sizeof(uint64_t) == 8, "type size mismatch");
+///}
 
 enum omp_proc_bind_t {
   omp_proc_bind_false = 0,


        


More information about the Openmp-commits mailing list