Skip to content

Commit 1e0d978

Browse files
committed
[OpenMP] Remove dependency on LLVM include directory from DeviceRTL
Summary: Currently we depend on a single LLVM include directory. This is actually only required to define one enum, which is highly unlikely to change. THis patch makes the `Environment.h` include directory more hermetic so we no long depend on other libraries. In exchange, we get a simpler dependency list for the price of hard-coding `1` somewhere. I think it's a valid trade considering that this flag is highly unlikely to change at this point.
1 parent f12078e commit 1e0d978

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

offload/DeviceRTL/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ if(${LIBOMPTARGET_GPU_LIBC_SUPPORT})
7575
list(APPEND clang_opt_flags -DOMPTARGET_HAS_LIBC)
7676
endif()
7777

78-
# Prepend -I to each list element
79-
set (LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL "${LIBOMPTARGET_LLVM_INCLUDE_DIRS}")
80-
list(TRANSFORM LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL PREPEND "-I")
81-
8278
# Set flags for LLVM Bitcode compilation.
8379
set(bc_flags -c -flto -std=c++17 -fvisibility=hidden
8480
${clang_opt_flags} -nogpulib -nostdlibinc
@@ -88,7 +84,6 @@ set(bc_flags -c -flto -std=c++17 -fvisibility=hidden
8884
-I${include_directory}
8985
-I${devicertl_base_directory}/../include
9086
-I${devicertl_base_directory}/../../libc
91-
${LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL}
9287
)
9388

9489
# first create an object target
@@ -172,7 +167,6 @@ function(compileDeviceRTLLibrary target_name target_triple)
172167
${include_directory}
173168
${devicertl_base_directory}/../../libc
174169
${devicertl_base_directory}/../include
175-
${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
176170
)
177171
install(TARGETS ${ide_target_name} EXCLUDE_FROM_ALL)
178172
endif()

offload/DeviceRTL/src/Kernel.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121
#include "Synchronization.h"
2222
#include "Workshare.h"
2323

24-
#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
25-
2624
using namespace ompx;
2725

26+
// These flags are copied from "llvm/Frontend/OpenMP/OMPDeviceConstants.h" and
27+
// must be kept in-sync.
28+
enum OMPTgtExecModeFlags : unsigned char {
29+
OMP_TGT_EXEC_MODE_GENERIC = 1 << 0,
30+
OMP_TGT_EXEC_MODE_SPMD = 1 << 1,
31+
OMP_TGT_EXEC_MODE_GENERIC_SPMD =
32+
OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD
33+
};
34+
2835
static void
2936
inititializeRuntime(bool IsSPMD, KernelEnvironmentTy &KernelEnvironment,
3037
KernelLaunchEnvironmentTy &KernelLaunchEnvironment) {
@@ -74,8 +81,7 @@ extern "C" {
7481
int32_t __kmpc_target_init(KernelEnvironmentTy &KernelEnvironment,
7582
KernelLaunchEnvironmentTy &KernelLaunchEnvironment) {
7683
ConfigurationEnvironmentTy &Configuration = KernelEnvironment.Configuration;
77-
bool IsSPMD = Configuration.ExecMode &
78-
llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_SPMD;
84+
bool IsSPMD = Configuration.ExecMode & OMP_TGT_EXEC_MODE_SPMD;
7985
bool UseGenericStateMachine = Configuration.UseGenericStateMachine;
8086
if (IsSPMD) {
8187
inititializeRuntime(/*IsSPMD=*/true, KernelEnvironment,

offload/DeviceRTL/src/Mapping.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include "State.h"
1717
#include "gpuintrin.h"
1818

19-
#include "llvm/Frontend/OpenMP/OMPGridValues.h"
20-
2119
using namespace ompx;
2220

2321
// FIXME: This resolves the handling for the AMDGPU workgroup size when the ABI

offload/include/Shared/Environment.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515

1616
#include <stdint.h>
1717

18-
#ifdef OMPTARGET_DEVICE_RUNTIME
19-
#include "DeviceTypes.h"
20-
#else
21-
#include "SourceInfo.h"
22-
23-
using IdentTy = ident_t;
24-
#endif
25-
26-
#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
18+
struct IdentTy;
2719

2820
enum class DeviceDebugKind : uint32_t {
2921
Assertion = 1U << 0,
@@ -80,7 +72,7 @@ struct DynamicEnvironmentTy {
8072
struct ConfigurationEnvironmentTy {
8173
uint8_t UseGenericStateMachine = 2;
8274
uint8_t MayUseNestedParallelism = 2;
83-
llvm::omp::OMPTgtExecModeFlags ExecMode = llvm::omp::OMP_TGT_EXEC_MODE_SPMD;
75+
uint8_t ExecMode = 0;
8476
// Information about (legal) launch configurations.
8577
//{
8678
int32_t MinThreads = -1;

0 commit comments

Comments
 (0)