-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[OpenMP] Remove dependency on LLVM include directory from DeviceRTL #136359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-offload Author: Joseph Huber (jhuber6) ChangesSummary: Full diff: https://github.com/llvm/llvm-project/pull/136359.diff 4 Files Affected:
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;
|
This is a bad idea. Why do you want to remove that dependency so bad? |
Because I want to put this back in |
In the past if I remember correctly, we need more values from LLVM headers for AMDGPU, such as the wavefront size. It seems like as we evolve recently, we only need one value. It might be "overkill" to include it. If we move it back to |
The idea is that it will build this version if you compile with the respective GPU triple, and the CPU library otherwise. So, if you enter in |
How are you gonna compile the entire |
if ("${TRIPLE}" MATCHES "^nvptx64|^amdgcn")
add_subdirectory(device)
else()
add_subdirectory(runtime)
endif() |
That's not going to completely work, right? If someone builds |
I don't see how that's an issue. We already require that the device RTL is built with a 'just-built' clang that we pull out of the user's path. If anything, this lets you build 'cpu offloading' with a full GCC toolchain if you so desired, because right now it'll error without |
If that is the case, to depend on LLVM headers is not an issue? |
It's not an issue conceptually, we could definitely make it work, but there's no reason to make |
There is definitely a reason, and that's to avoid hardcoding things. There are precedents where definitions of certain enumerations are duplicated. You could follow that---copy/paste the definition of the one that's introducing the dependence with a comment that it must be in sync with the one in LLVM. |
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.
43c9c19
to
1e0d978
Compare
Updated, better? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as long as @kparzysz is fine with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
…lvm#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
…lvm#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
…lvm#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
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 sowe 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'sa valid trade considering that this flag is highly unlikely to change at
this point.
@ronlieb AMD version https://gist.github.com/jhuber6/3313e6f957be14dc79fe85e5126d2cb3