[llvm] [OpenMP] Remove dependency on LLVM include directory from DeviceRTL (PR #136359)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 18 12:38:44 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/136359.diff
4 Files Affected:
- (modified) offload/DeviceRTL/CMakeLists.txt (-6)
- (modified) offload/DeviceRTL/src/Kernel.cpp (+1-4)
- (modified) offload/DeviceRTL/src/Mapping.cpp (-2)
- (modified) offload/include/Shared/Environment.h (+3-9)
``````````diff
diff --git a/offload/DeviceRTL/CMakeLists.txt b/offload/DeviceRTL/CMakeLists.txt
index 2da2ade94f4e4..cce360236960f 100644
--- a/offload/DeviceRTL/CMakeLists.txt
+++ b/offload/DeviceRTL/CMakeLists.txt
@@ -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()
diff --git a/offload/DeviceRTL/src/Kernel.cpp b/offload/DeviceRTL/src/Kernel.cpp
index 9bb89573dc0cb..32d3b6cf4b75a 100644
--- a/offload/DeviceRTL/src/Kernel.cpp
+++ b/offload/DeviceRTL/src/Kernel.cpp
@@ -21,8 +21,6 @@
#include "Synchronization.h"
#include "Workshare.h"
-#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
-
using namespace ompx;
static void
@@ -74,8 +72,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=*/1;
bool UseGenericStateMachine = Configuration.UseGenericStateMachine;
if (IsSPMD) {
inititializeRuntime(/*IsSPMD=*/true, KernelEnvironment,
diff --git a/offload/DeviceRTL/src/Mapping.cpp b/offload/DeviceRTL/src/Mapping.cpp
index e951556c2ad4e..b145892d1ece0 100644
--- a/offload/DeviceRTL/src/Mapping.cpp
+++ b/offload/DeviceRTL/src/Mapping.cpp
@@ -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
diff --git a/offload/include/Shared/Environment.h b/offload/include/Shared/Environment.h
index db8443a7be933..2f943eaefa0f4 100644
--- a/offload/include/Shared/Environment.h
+++ b/offload/include/Shared/Environment.h
@@ -15,15 +15,9 @@
#include <stdint.h>
-#ifdef OMPTARGET_DEVICE_RUNTIME
-#include "DeviceTypes.h"
-#else
-#include "SourceInfo.h"
+struct IdentTy;
-using IdentTy = ident_t;
-#endif
-
-#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
+using OMPTgtExecModeFlags = unsigned char;
enum class DeviceDebugKind : uint32_t {
Assertion = 1U << 0,
@@ -80,7 +74,7 @@ struct DynamicEnvironmentTy {
struct ConfigurationEnvironmentTy {
uint8_t UseGenericStateMachine = 2;
uint8_t MayUseNestedParallelism = 2;
- llvm::omp::OMPTgtExecModeFlags ExecMode = llvm::omp::OMP_TGT_EXEC_MODE_SPMD;
+ OMPTgtExecModeFlags ExecMode;
// Information about (legal) launch configurations.
//{
int32_t MinThreads = -1;
``````````
</details>
https://github.com/llvm/llvm-project/pull/136359
More information about the llvm-commits
mailing list