[OpenMP] Remove dependency on LLVM include directory from DeviceRTL (#136359)
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. @ronlieb AMD version https://gist.github.com/jhuber6/3313e6f957be14dc79fe85e5126d2cb3
This commit is contained in:
@@ -75,10 +75,6 @@ if(${LIBOMPTARGET_GPU_LIBC_SUPPORT})
|
||||
list(APPEND clang_opt_flags -DOMPTARGET_HAS_LIBC)
|
||||
endif()
|
||||
|
||||
# Prepend -I to each list element
|
||||
set (LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL "${LIBOMPTARGET_LLVM_INCLUDE_DIRS}")
|
||||
list(TRANSFORM LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL PREPEND "-I")
|
||||
|
||||
# Set flags for LLVM Bitcode compilation.
|
||||
set(bc_flags -c -flto -std=c++17 -fvisibility=hidden
|
||||
${clang_opt_flags} -nogpulib -nostdlibinc
|
||||
@@ -88,7 +84,6 @@ set(bc_flags -c -flto -std=c++17 -fvisibility=hidden
|
||||
-I${include_directory}
|
||||
-I${devicertl_base_directory}/../include
|
||||
-I${devicertl_base_directory}/../../libc
|
||||
${LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL}
|
||||
)
|
||||
|
||||
# first create an object target
|
||||
@@ -172,7 +167,6 @@ function(compileDeviceRTLLibrary target_name target_triple)
|
||||
${include_directory}
|
||||
${devicertl_base_directory}/../../libc
|
||||
${devicertl_base_directory}/../include
|
||||
${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
|
||||
)
|
||||
install(TARGETS ${ide_target_name} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
@@ -21,10 +21,17 @@
|
||||
#include "Synchronization.h"
|
||||
#include "Workshare.h"
|
||||
|
||||
#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
|
||||
|
||||
using namespace ompx;
|
||||
|
||||
// These flags are copied from "llvm/Frontend/OpenMP/OMPDeviceConstants.h" and
|
||||
// must be kept in-sync.
|
||||
enum OMPTgtExecModeFlags : unsigned char {
|
||||
OMP_TGT_EXEC_MODE_GENERIC = 1 << 0,
|
||||
OMP_TGT_EXEC_MODE_SPMD = 1 << 1,
|
||||
OMP_TGT_EXEC_MODE_GENERIC_SPMD =
|
||||
OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD
|
||||
};
|
||||
|
||||
static void
|
||||
inititializeRuntime(bool IsSPMD, KernelEnvironmentTy &KernelEnvironment,
|
||||
KernelLaunchEnvironmentTy &KernelLaunchEnvironment) {
|
||||
@@ -74,8 +81,7 @@ extern "C" {
|
||||
int32_t __kmpc_target_init(KernelEnvironmentTy &KernelEnvironment,
|
||||
KernelLaunchEnvironmentTy &KernelLaunchEnvironment) {
|
||||
ConfigurationEnvironmentTy &Configuration = KernelEnvironment.Configuration;
|
||||
bool IsSPMD = Configuration.ExecMode &
|
||||
llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_SPMD;
|
||||
bool IsSPMD = Configuration.ExecMode & OMP_TGT_EXEC_MODE_SPMD;
|
||||
bool UseGenericStateMachine = Configuration.UseGenericStateMachine;
|
||||
if (IsSPMD) {
|
||||
inititializeRuntime(/*IsSPMD=*/true, KernelEnvironment,
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include "State.h"
|
||||
#include "gpuintrin.h"
|
||||
|
||||
#include "llvm/Frontend/OpenMP/OMPGridValues.h"
|
||||
|
||||
using namespace ompx;
|
||||
|
||||
// FIXME: This resolves the handling for the AMDGPU workgroup size when the ABI
|
||||
|
||||
@@ -15,15 +15,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef OMPTARGET_DEVICE_RUNTIME
|
||||
#include "DeviceTypes.h"
|
||||
#else
|
||||
#include "SourceInfo.h"
|
||||
|
||||
using IdentTy = ident_t;
|
||||
#endif
|
||||
|
||||
#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
|
||||
struct IdentTy;
|
||||
|
||||
enum class DeviceDebugKind : uint32_t {
|
||||
Assertion = 1U << 0,
|
||||
@@ -80,7 +72,7 @@ struct DynamicEnvironmentTy {
|
||||
struct ConfigurationEnvironmentTy {
|
||||
uint8_t UseGenericStateMachine = 2;
|
||||
uint8_t MayUseNestedParallelism = 2;
|
||||
llvm::omp::OMPTgtExecModeFlags ExecMode = llvm::omp::OMP_TGT_EXEC_MODE_SPMD;
|
||||
uint8_t ExecMode = 0;
|
||||
// Information about (legal) launch configurations.
|
||||
//{
|
||||
int32_t MinThreads = -1;
|
||||
|
||||
Reference in New Issue
Block a user