diff --git a/openmp/libomptarget/include/DeviceEnvironment.h b/llvm/include/llvm/Frontend/OpenMP/DeviceEnvironment.h rename from openmp/libomptarget/include/DeviceEnvironment.h rename to llvm/include/llvm/Frontend/OpenMP/DeviceEnvironment.h diff --git a/openmp/libomptarget/include/SourceInfo.h b/llvm/include/llvm/Frontend/OpenMP/SourceInfo.h rename from openmp/libomptarget/include/SourceInfo.h rename to llvm/include/llvm/Frontend/OpenMP/SourceInfo.h --- a/openmp/libomptarget/include/SourceInfo.h +++ b/llvm/include/llvm/Frontend/OpenMP/SourceInfo.h @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _SOURCE_INFO_H_ -#define _SOURCE_INFO_H_ +#ifndef LLVM_FRONTEND_OPENMP_SOURCE_INFO_H +#define LLVM_FRONTEND_OPENMP_SOURCE_INFO_H #include diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt --- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt +++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt @@ -117,7 +117,7 @@ ${source_directory}/Workshare.cpp ) -set(clang_opt_flags -O1 -mllvm -openmp-opt-disable -DSHARED_SCRATCHPAD_SIZE=2048) +set(clang_opt_flags -O1 -mllvm -openmp-opt-disable -DSHARED_SCRATCHPAD_SIZE=2048 -DOMPTARGET_DEVICE -DOMPTARGET_DEVICE_RUNTIME) set(link_opt_flags -O1 -openmp-opt-disable) # Prepend -I to each list element diff --git a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp --- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp +++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp @@ -12,9 +12,9 @@ //===----------------------------------------------------------------------===// #include "Configuration.h" -#include "DeviceEnvironment.h" #include "State.h" #include "Types.h" +#include "llvm/Frontend/OpenMP/DeviceEnvironment.h" using namespace _OMP; diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt --- a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt +++ b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt @@ -131,6 +131,8 @@ -fvisibility=default -Wno-unused-value -nogpulib + -DOMPTARGET_DEVICE + -DOMPTARGET_OLD_DEVICE_RUNTIME -O${optimization_level} ${CUDA_DEBUG} -I${CMAKE_CURRENT_SOURCE_DIR}/src diff --git a/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu b/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu --- a/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu @@ -38,7 +38,8 @@ if (threadIdInBlock != GetMasterThreadID()) return; - setExecutionParameters(OMP_TGT_EXEC_MODE_GENERIC, OMP_TGT_RUNTIME_INITIALIZED); + setExecutionParameters(llvm::omp::OMP_TGT_EXEC_MODE_GENERIC, + OMP_TGT_RUNTIME_INITIALIZED); ASSERT0(LT_FUSSY, threadIdInBlock == GetMasterThreadID(), "__kmpc_kernel_init() must be called by team master warp only!"); PRINT0(LD_IO, "call to __kmpc_kernel_init for master\n"); @@ -85,7 +86,7 @@ static void __kmpc_spmd_kernel_init(bool RequiresFullRuntime) { PRINT0(LD_IO, "call to __kmpc_spmd_kernel_init\n"); - setExecutionParameters(OMP_TGT_EXEC_MODE_SPMD, + setExecutionParameters(llvm::omp::OMP_TGT_EXEC_MODE_SPMD, RequiresFullRuntime ? OMP_TGT_RUNTIME_INITIALIZED : OMP_TGT_RUNTIME_UNINITIALIZED); int threadId = __kmpc_get_hardware_thread_id_in_block(); @@ -165,7 +166,8 @@ // by comparision between the parallel level and the return value of this // function. EXTERN int8_t __kmpc_is_spmd_exec_mode() { - return (execution_param & OMP_TGT_EXEC_MODE_SPMD) == OMP_TGT_EXEC_MODE_SPMD; + return (execution_param & llvm::omp::OMP_TGT_EXEC_MODE_SPMD) == + llvm::omp::OMP_TGT_EXEC_MODE_SPMD; } EXTERN int8_t __kmpc_is_generic_main_thread(kmp_int32 Tid) { @@ -210,7 +212,7 @@ int32_t __kmpc_target_init(ident_t *Ident, int8_t Mode, bool UseGenericStateMachine, bool RequiresFullRuntime) { - const bool IsSPMD = Mode & OMP_TGT_EXEC_MODE_SPMD; + const bool IsSPMD = Mode & llvm::omp::OMP_TGT_EXEC_MODE_SPMD; int TId = __kmpc_get_hardware_thread_id_in_block(); if (IsSPMD) __kmpc_spmd_kernel_init(RequiresFullRuntime); @@ -249,7 +251,7 @@ EXTERN void __kmpc_target_deinit(ident_t *Ident, int8_t Mode, bool RequiresFullRuntime) { - const bool IsSPMD = Mode & OMP_TGT_EXEC_MODE_SPMD; + const bool IsSPMD = Mode & llvm::omp::OMP_TGT_EXEC_MODE_SPMD; if (IsSPMD) __kmpc_spmd_kernel_deinit(RequiresFullRuntime); else diff --git a/openmp/libomptarget/deviceRTLs/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu --- a/openmp/libomptarget/deviceRTLs/common/src/support.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/support.cu @@ -19,13 +19,13 @@ // Execution Parameters //////////////////////////////////////////////////////////////////////////////// -void setExecutionParameters(OMPTgtExecModeFlags EMode, +void setExecutionParameters(llvm::omp::OMPTgtExecModeFlags EMode, OMPTgtRuntimeModeFlags RMode) { execution_param = EMode; execution_param |= RMode; } -bool isGenericMode() { return execution_param & OMP_TGT_EXEC_MODE_GENERIC; } +bool isGenericMode() { return execution_param == llvm::omp::OMP_TGT_EXEC_MODE_GENERIC; } bool isRuntimeUninitialized() { return !isRuntimeInitialized(); } diff --git a/openmp/libomptarget/deviceRTLs/common/support.h b/openmp/libomptarget/deviceRTLs/common/support.h --- a/openmp/libomptarget/deviceRTLs/common/support.h +++ b/openmp/libomptarget/deviceRTLs/common/support.h @@ -15,21 +15,17 @@ #include "interface.h" #include "target_impl.h" +#include "llvm/Frontend/OpenMP/ConfigurationEnvironment.h" //////////////////////////////////////////////////////////////////////////////// // Execution Parameters //////////////////////////////////////////////////////////////////////////////// -enum OMPTgtExecModeFlags : int8_t { - OMP_TGT_EXEC_MODE_GENERIC = 1 << 0, - OMP_TGT_EXEC_MODE_SPMD = 1 << 1 -}; - enum OMPTgtRuntimeModeFlags : int8_t { OMP_TGT_RUNTIME_UNINITIALIZED = 0, OMP_TGT_RUNTIME_INITIALIZED = 1 << 2 }; -void setExecutionParameters(OMPTgtExecModeFlags EMode, +void setExecutionParameters(llvm::omp::OMPTgtExecModeFlags EMode, OMPTgtRuntimeModeFlags RMode); bool isGenericMode(); bool isRuntimeUninitialized(); diff --git a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt --- a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt +++ b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt @@ -187,7 +187,7 @@ # Generate a Bitcode library for all the compute capabilities the user requested foreach(sm ${nvptx_sm_list}) - set(cuda_flags -Xclang -target-cpu -Xclang sm_${sm} "-D__CUDA_ARCH__=${sm}0") + set(cuda_flags -Xclang -target-cpu -Xclang sm_${sm} "-D__CUDA_ARCH__=${sm}0" -DOMPTARGET_DEVICE -DOMPTARGET_OLD_DEVICE_RUNTIME) set(bc_files "") foreach(src ${cuda_src_files}) get_filename_component(infile ${src} ABSOLUTE) diff --git a/openmp/libomptarget/deviceRTLs/target_interface.h b/openmp/libomptarget/deviceRTLs/target_interface.h --- a/openmp/libomptarget/deviceRTLs/target_interface.h +++ b/openmp/libomptarget/deviceRTLs/target_interface.h @@ -15,8 +15,8 @@ #include -#include "DeviceEnvironment.h" #include "target_impl.h" +#include "llvm/Frontend/OpenMP/DeviceEnvironment.h" // Calls to the NVPTX layer (assuming 1D layout) EXTERN int __kmpc_get_hardware_thread_id_in_block(); diff --git a/openmp/libomptarget/include/omptarget.h b/openmp/libomptarget/include/omptarget.h --- a/openmp/libomptarget/include/omptarget.h +++ b/openmp/libomptarget/include/omptarget.h @@ -18,7 +18,7 @@ #include #include -#include +#include "llvm/Frontend/OpenMP/SourceInfo.h" #define OFFLOAD_SUCCESS (0) #define OFFLOAD_FAIL (~0) diff --git a/openmp/libomptarget/plugins/CMakeLists.txt b/openmp/libomptarget/plugins/CMakeLists.txt --- a/openmp/libomptarget/plugins/CMakeLists.txt +++ b/openmp/libomptarget/plugins/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories(${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR}) include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR}) + include_directories(${LIBOMPTARGET_LLVM_INCLUDE_DIRS}) # Define macro to be used as prefix of the runtime messages for this target. add_definitions("-DTARGET_NAME=${tmachine_name}") diff --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp --- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp +++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp @@ -30,11 +30,11 @@ #include "internal.h" #include "rt.h" -#include "DeviceEnvironment.h" #include "get_elf_mach_gfx_name.h" #include "omptargetplugin.h" #include "print_tracing.h" +#include "llvm/Frontend/OpenMP/DeviceEnvironment.h" #include "llvm/Frontend/OpenMP/OMPConstants.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" diff --git a/openmp/libomptarget/plugins/cuda/src/rtl.cpp b/openmp/libomptarget/plugins/cuda/src/rtl.cpp --- a/openmp/libomptarget/plugins/cuda/src/rtl.cpp +++ b/openmp/libomptarget/plugins/cuda/src/rtl.cpp @@ -21,7 +21,6 @@ #include #include "Debug.h" -#include "DeviceEnvironment.h" #include "omptargetplugin.h" #define TARGET_NAME CUDA @@ -29,6 +28,7 @@ #include "MemoryManager.h" +#include "llvm/Frontend/OpenMP/DeviceEnvironment.h" #include "llvm/Frontend/OpenMP/OMPConstants.h" // Utility for retrieving and printing CUDA error string. diff --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h --- a/openmp/libomptarget/src/private.h +++ b/openmp/libomptarget/src/private.h @@ -13,10 +13,10 @@ #ifndef _OMPTARGET_PRIVATE_H #define _OMPTARGET_PRIVATE_H +#include "Debug.h" #include "device.h" -#include -#include -#include +#include "omptarget.h" +#include "llvm/Frontend/OpenMP/SourceInfo.h" #include diff --git a/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt b/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt --- a/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt +++ b/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt @@ -16,6 +16,8 @@ llvm_update_compile_flags(llvm-omp-device-info) +include_directories(${LIBOMPTARGET_LLVM_INCLUDE_DIRS}) + target_link_libraries(llvm-omp-device-info PRIVATE omp omptarget