Skip to content

[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

Merged
merged 1 commit into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions offload/DeviceRTL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
14 changes: 10 additions & 4 deletions offload/DeviceRTL/src/Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions offload/DeviceRTL/src/Mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions offload/include/Shared/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Loading