Skip to content

Commit

Permalink
[OpenMP] Fix redefining stdint.h types (llvm#108607)
Browse files Browse the repository at this point in the history
Summary:
We can include `stdint.h` just fine as long as we don't allow it to find
system headers, passing `-nostdlibinc` and `-nogpuinc` suppresses these
extra paths so we will just use the clang resource headers for
`stdint.h` and `stddef.h`.
  • Loading branch information
jhuber6 authored Sep 13, 2024
1 parent 39f2d2f commit c3ac3fe
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 54 deletions.
4 changes: 2 additions & 2 deletions offload/DeviceRTL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,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 -nostdinc
-nocudalib -nogpulib -nogpuinc -nostdlibinc
-fopenmp -fopenmp-cuda-mode
-Wno-unknown-cuda-version
-DOMPTARGET_DEVICE_RUNTIME
Expand Down Expand Up @@ -270,7 +270,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
-fopenmp --offload-arch=${target_cpu} -fopenmp-cuda-mode
-mllvm -openmp-opt-disable
-foffload-lto -fvisibility=hidden --offload-device-only
-nocudalib -nogpulib -nostdinc -Wno-unknown-cuda-version
-nocudalib -nogpulib -nogpuinc -nostdlibinc -Wno-unknown-cuda-version
)
target_compile_definitions(${ide_target_name} PRIVATE SHARED_SCRATCHPAD_SIZE=512)
target_include_directories(${ide_target_name} PRIVATE
Expand Down
29 changes: 3 additions & 26 deletions offload/DeviceRTL/include/DeviceTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#ifndef OMPTARGET_TYPES_H
#define OMPTARGET_TYPES_H

#include <stddef.h>
#include <stdint.h>

// 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
Expand All @@ -21,32 +24,6 @@
// 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,
omp_proc_bind_true = 1,
Expand Down
6 changes: 3 additions & 3 deletions offload/include/Shared/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#ifndef OMPTARGET_SHARED_ENVIRONMENT_H
#define OMPTARGET_SHARED_ENVIRONMENT_H

#include <stdint.h>

#ifdef OMPTARGET_DEVICE_RUNTIME
#include "Types.h"
#include "DeviceTypes.h"
#else
#include "SourceInfo.h"

#include <cstdint>

using IdentTy = ident_t;
#endif

Expand Down
22 changes: 0 additions & 22 deletions offload/include/Shared/Types.h

This file was deleted.

2 changes: 1 addition & 1 deletion offload/include/Shared/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ifndef OMPTARGET_SHARED_UTILS_H
#define OMPTARGET_SHARED_UTILS_H

#include "Types.h"
#include <stdint.h>

namespace utils {

Expand Down

0 comments on commit c3ac3fe

Please sign in to comment.