-
-
Save jhuber6/3cdcd37c4a2134e8a5043fe492ab4634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8b7df63ecc4f2cd2b41cc6aca8e989cbfab2856c Mon Sep 17 00:00:00 2001 | |
From: Joseph Huber <huberjn@outlook.com> | |
Date: Sun, 24 Mar 2024 08:00:34 -0500 | |
Subject: [PATCH] [Libomptarget] Unify and simplify plugin CMake #86191 | |
Summary: | |
This patch reworks the CMake handling for building plugins. All | |
this does is pull a lot of shared and common logic into a single helper | |
function. This also simplifies the OMPT libraries from being built | |
separately instead of just added. | |
--- | |
openmp/libomptarget/hostexec/CMakeLists.txt | 4 +- | |
.../hostexec/services/amdgcn_hostexec.cpp | 10 +- | |
.../hostexec/services/urilocator.h | 5 + | |
.../plugins-nextgen/CMakeLists.txt | 57 ++++++++++ | |
.../plugins-nextgen/amdgpu/CMakeLists.txt | 106 +++++------------- | |
.../plugins-nextgen/common/CMakeLists.txt | 55 ++------- | |
.../common/OMPT/CMakeLists.txt | 71 ------------ | |
.../plugins-nextgen/cuda/CMakeLists.txt | 40 +------ | |
.../plugins-nextgen/host/CMakeLists.txt | 44 ++------ | |
9 files changed, 122 insertions(+), 270 deletions(-) | |
delete mode 100644 openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt | |
diff --git a/openmp/libomptarget/hostexec/CMakeLists.txt b/openmp/libomptarget/hostexec/CMakeLists.txt | |
index 0db2d2ddbe3..baccbf92996 100644 | |
--- a/openmp/libomptarget/hostexec/CMakeLists.txt | |
+++ b/openmp/libomptarget/hostexec/CMakeLists.txt | |
@@ -27,7 +27,8 @@ endif() | |
if(DEFINED HSA_RUNTIME) | |
libomptarget_say("Building hostexec for AMDGCN linked against libhsa") | |
- set(HSA_INCLUDE ${LIBOMPTARGET_EXTERNAL_PROJECT_HSA_PATH}/inc) | |
+ get_filename_component(library_path ${HSA_RUNTIME} DIRECTORY) | |
+ set(HSA_INCLUDE ${library_path}/../include) | |
set(HOSTEXEC_EXTRA_SOURCE) | |
set(HOSTEXEC_DEP_LIBRARIES ${HSA_RUNTIME}) | |
elseif(${hsa-runtime64_FOUND}) | |
@@ -181,6 +182,7 @@ foreach(archname ${HOSTRPC_ARCHS}) | |
elseif(${archname} STREQUAL "nvptx") | |
set(openmp_device_args | |
-I../../runtime/src # to pickup omp.h, we may need a dependency | |
+ -I${CMAKE_CURRENT_SOURCE_DIR}/../DeviceRTL/include # pickup Platform.h | |
-fopenmp -fopenmp-cuda-mode -mllvm -openmp-opt-disable | |
-std=c++17 -fvisibility=hidden | |
-fopenmp-targets=${triple} -Xopenmp-target=${triple} -march=${mcpu} | |
diff --git a/openmp/libomptarget/hostexec/services/amdgcn_hostexec.cpp b/openmp/libomptarget/hostexec/services/amdgcn_hostexec.cpp | |
index 9f34be4a824..3483e0ad3e0 100644 | |
--- a/openmp/libomptarget/hostexec/services/amdgcn_hostexec.cpp | |
+++ b/openmp/libomptarget/hostexec/services/amdgcn_hostexec.cpp | |
@@ -18,13 +18,19 @@ | |
#include <atomic> | |
#include <cstring> | |
#include <functional> | |
-#include <hsa.h> | |
-#include <hsa_ext_amd.h> | |
#include <iostream> | |
#include <list> | |
#include <mutex> | |
#include <thread> | |
+#if __has_include("hsa/hsa.h") | |
+#include "hsa/hsa.h" | |
+#include "hsa/hsa_ext_amd.h" | |
+#else | |
+#include "hsa.h" | |
+#include "hsa_ext_amd.h" | |
+#endif | |
+ | |
/// Defines how many GPUs are maximally supported on a system | |
#define AMD_MAX_HSA_AGENTS 16 | |
diff --git a/openmp/libomptarget/hostexec/services/urilocator.h b/openmp/libomptarget/hostexec/services/urilocator.h | |
index b12a91965ed..bccc52ab24c 100644 | |
--- a/openmp/libomptarget/hostexec/services/urilocator.h | |
+++ b/openmp/libomptarget/hostexec/services/urilocator.h | |
@@ -29,7 +29,12 @@ | |
#ifndef URILOCATOR_H | |
#define URILOCATOR_H | |
+ | |
+#if __has_include("hsa/hsa.h") | |
+#include "hsa/hsa_ven_amd_loader.h" | |
+#else | |
#include "hsa_ven_amd_loader.h" | |
+#endif | |
#include <string> | |
#include <vector> | |
diff --git a/openmp/libomptarget/plugins-nextgen/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/CMakeLists.txt | |
index 75540f05584..a227e5c8786 100644 | |
--- a/openmp/libomptarget/plugins-nextgen/CMakeLists.txt | |
+++ b/openmp/libomptarget/plugins-nextgen/CMakeLists.txt | |
@@ -10,7 +10,64 @@ | |
# | |
##===----------------------------------------------------------------------===## | |
+# Common interface to handle creating a plugin library. | |
+set(common_dir ${CMAKE_CURRENT_SOURCE_DIR}/common) | |
add_subdirectory(common) | |
+function(add_target_library target_name lib_name) | |
+ add_llvm_library(${target_name} SHARED | |
+ LINK_COMPONENTS | |
+ ${LLVM_TARGETS_TO_BUILD} | |
+ AggressiveInstCombine | |
+ Analysis | |
+ BinaryFormat | |
+ BitReader | |
+ BitWriter | |
+ CodeGen | |
+ Core | |
+ Extensions | |
+ InstCombine | |
+ Instrumentation | |
+ IPO | |
+ IRReader | |
+ Linker | |
+ MC | |
+ Object | |
+ Passes | |
+ Remarks | |
+ ScalarOpts | |
+ Support | |
+ Target | |
+ TargetParser | |
+ TransformUtils | |
+ Vectorize | |
+ NO_INSTALL_RPATH | |
+ BUILDTREE_ONLY | |
+ ) | |
+ | |
+ llvm_update_compile_flags(${target_name}) | |
+ target_link_libraries(${target_name} PRIVATE | |
+ PluginCommon ${llvm_libs} ${OPENMP_PTHREAD_LIB}) | |
+ | |
+ target_compile_definitions(${target_name} PRIVATE TARGET_NAME=${lib_name}) | |
+ target_compile_definitions(${target_name} PRIVATE | |
+ DEBUG_PREFIX="TARGET ${lib_name} RTL") | |
+ | |
+ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") | |
+ # On FreeBSD, the 'environ' symbol is undefined at link time, but resolved by | |
+ # the dynamic linker at runtime. Therefore, allow the symbol to be undefined | |
+ # when creating a shared library. | |
+ target_link_libraries(${target_name} PRIVATE "-Wl,--allow-shlib-undefined") | |
+ else() | |
+ target_link_libraries(${target_name} PRIVATE "-Wl,-z,defs") | |
+ endif() | |
+ | |
+ if(LIBOMP_HAVE_VERSION_SCRIPT_FLAG) | |
+ target_link_libraries(${target_name} PRIVATE | |
+ "-Wl,--version-script=${common_dir}/../exports") | |
+ endif() | |
+ set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET protected) | |
+endfunction() | |
+ | |
add_subdirectory(amdgpu) | |
add_subdirectory(cuda) | |
add_subdirectory(host) | |
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt | |
index e09556382a8..28978bb126d 100644 | |
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt | |
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt | |
@@ -22,98 +22,53 @@ endif() | |
# If we are bootstrapping hsa via external project we need to use find_library | |
# as it will not be installed. | |
if(DEFINED LIBOMPTARGET_EXTERNAL_PROJECT_HSA_PATH) | |
- find_library(HSA_RUNTIME hsa-runtime64 HINTS ${CMAKE_BINARY_DIR}/../../runtimes/rocr-runtime-prefix/src/rocr-runtime-build ${CMAKE_INSTALL_PREFIX}) | |
+ find_library(HSA_RUNTIME hsa-runtime64 | |
+ HINTS | |
+ ${CMAKE_BINARY_DIR}/../../runtimes/rocr-runtime-prefix/src/rocr-runtime-build | |
+ ${CMAKE_INSTALL_PREFIX} | |
+ PATHS | |
+ ${LIBOMPTARGET_EXTERNAL_PROJECT_HSA_PATH} | |
+ ) | |
else() | |
# As of rocm-3.7, hsa is installed with cmake packages and kmt is found via hsa | |
find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) | |
endif() | |
-# Check for COMGr package , ASan requires COMGr with minimum version 2.4 | |
-if(SANITIZER_AMDGPU) | |
- add_definitions(-DSANITIZER_AMDGPU=1) | |
- find_package(amd_comgr QUIET 2.4.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) | |
-endif() | |
- | |
if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux")) | |
libomptarget_say("Not building AMDGPU NextGen plugin: only support AMDGPU in Linux x86_64, ppc64le, or aarch64 hosts") | |
return() | |
endif() | |
-################################################################################ | |
-# Define the suffix for the runtime messaging dumps. | |
-add_definitions(-DTARGET_NAME=AMDGPU) | |
+# Create the library and add the default arguments. | |
+add_target_library(omptarget.rtl.amdgpu AMDGPU) | |
-# Define debug prefix. TODO: This should be automatized in the Debug.h but it | |
-# requires changing the original plugins. | |
-add_definitions(-DDEBUG_PREFIX="TARGET AMDGPU RTL") | |
+target_sources(omptarget.rtl.amdgpu PRIVATE src/rtl.cpp) | |
+target_include_directories(omptarget.rtl.amdgpu PRIVATE | |
+ ${CMAKE_CURRENT_SOURCE_DIR}/utils) | |
+target_link_libraries(omptarget.rtl.amdgpu PRIVATE | |
+ -Wl,--whole-archive amdgcn_hostexec_services -Wl,--no-whole-archive) | |
-set(LIBOMPTARGET_DLOPEN_LIBHSA OFF) | |
-option(LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" ${LIBOMPTARGET_DLOPEN_LIBHSA}) | |
- | |
-if(DEFINED HSA_RUNTIME AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA) | |
- libomptarget_say("Building AMDGPU NextGen plugin linked against libhsa") | |
- set(LIBOMPTARGET_EXTRA_SOURCE) | |
- set(LIBOMPTARGET_DEP_LIBRARIES ${HSA_RUNTIME}) | |
-elseif(${hsa-runtime64_FOUND} AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA) | |
- libomptarget_say("Building AMDGPU NextGen plugin linked against libhsa") | |
- set(LIBOMPTARGET_EXTRA_SOURCE) | |
- set(LIBOMPTARGET_DEP_LIBRARIES hsa-runtime64::hsa-runtime64) | |
-else() | |
- libomptarget_say("Building AMDGPU NextGen plugin for dlopened libhsa") | |
- include_directories(dynamic_hsa) | |
- set(LIBOMPTARGET_EXTRA_SOURCE dynamic_hsa/hsa.cpp) | |
- set(LIBOMPTARGET_DEP_LIBRARIES) | |
+# Check for COMGr package , ASan requires COMGr with minimum version 2.4 | |
+if(SANITIZER_AMDGPU) | |
+ target_compile_definitions(omptarget.rtl.amdgpu PRIVATE SANITIZER_AMDGPU=1) | |
+ find_package(amd_comgr QUIET 2.4.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) | |
endif() | |
-if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") | |
- # On FreeBSD, the 'environ' symbol is undefined at link time, but resolved by | |
- # the dynamic linker at runtime. Therefore, allow the symbol to be undefined | |
- # when creating a shared library. | |
- set(LDFLAGS_UNDEFINED "-Wl,--allow-shlib-undefined") | |
+option(LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" OFF) | |
+if(DEFINED HSA_RUNTIME AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA) | |
+ libomptarget_say("Building AMDGPU plugin linked against libhsa") | |
+ target_link_libraries(omptarget.rtl.amdgpu PRIVATE ${HSA_RUNTIME}) | |
+ get_filename_component(library_path ${HSA_RUNTIME} DIRECTORY) | |
+ target_include_directories(omptarget.rtl.amdgpu PRIVATE ${library_path}/../include) | |
+elseif(hsa-runtime64_FOUND AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA) | |
+ libomptarget_say("Building AMDGPU plugin linked against libhsa") | |
+ target_link_libraries(omptarget.rtl.amdgpu PRIVATE hsa-runtime64::hsa-runtime64) | |
else() | |
- set(LDFLAGS_UNDEFINED "-Wl,-z,defs") | |
+ libomptarget_say("Building AMDGPU plugin for dlopened libhsa") | |
+ target_include_directories(omptarget.rtl.amdgpu PRIVATE dynamic_hsa) | |
+ target_sources(omptarget.rtl.amdgpu PRIVATE dynamic_hsa/hsa.cpp) | |
endif() | |
-add_llvm_library(omptarget.rtl.amdgpu SHARED | |
- src/rtl.cpp | |
- ${LIBOMPTARGET_EXTRA_SOURCE} | |
- | |
- ADDITIONAL_HEADER_DIRS | |
- ${LIBOMPTARGET_INCLUDE_DIR} | |
- ${CMAKE_CURRENT_SOURCE_DIR}/utils | |
- | |
- LINK_COMPONENTS | |
- Support | |
- Object | |
- | |
- LINK_LIBS | |
- PRIVATE | |
- OMPT | |
- PluginCommon | |
- ${LIBOMPTARGET_DEP_LIBRARIES} | |
- ${OPENMP_PTHREAD_LIB} | |
- -Wl,--whole-archive amdgcn_hostexec_services -Wl,--no-whole-archive | |
- ${LDFLAGS_UNDEFINED} | |
- | |
- NO_INSTALL_RPATH | |
- BUILDTREE_ONLY | |
-) | |
-add_dependencies(omptarget.rtl.amdgpu amdgcn_hostexec_services) | |
- | |
-if (LIBOMP_HAVE_VERSION_SCRIPT_FLAG) | |
- target_link_libraries( | |
- omptarget.rtl.amdgpu | |
- PRIVATE | |
- "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports") | |
-endif() | |
- | |
-target_include_directories( | |
- omptarget.rtl.amdgpu | |
- PRIVATE | |
- ${LIBOMPTARGET_INCLUDE_DIR} | |
- ${CMAKE_CURRENT_SOURCE_DIR}/utils | |
-) | |
- | |
# Configure testing for the AMDGPU plugin. We will build tests if we could a | |
# functional AMD GPU on the system, or if manually specifies by the user. | |
option(LIBOMPTARGET_FORCE_AMDGPU_TESTS "Build AMDGPU libomptarget tests" OFF) | |
@@ -130,7 +85,6 @@ endif() | |
# Install plugin under the lib destination folder. | |
install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") | |
- | |
if(NOT DEFINED CMAKE_INSTALL_RPATH) | |
set_target_properties(omptarget.rtl.amdgpu PROPERTIES | |
INSTALL_RPATH "$ORIGIN") | |
diff --git a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt | |
index 085d4430716..0417fd56cbc 100644 | |
--- a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt | |
+++ b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt | |
@@ -19,6 +19,7 @@ add_library(PluginCommon OBJECT | |
src/RPC.cpp | |
src/Utils/ELF.cpp | |
) | |
+add_dependencies(PluginCommon intrinsics_gen) | |
# Only enable JIT for those targets that LLVM can support. | |
string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported) | |
@@ -26,45 +27,6 @@ foreach(Target ${TargetsSupported}) | |
target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${Target}") | |
endforeach() | |
-# This is required when using LLVM libraries. | |
-llvm_update_compile_flags(PluginCommon) | |
- | |
-if (LLVM_LINK_LLVM_DYLIB) | |
- set(llvm_libs LLVM) | |
-else() | |
- llvm_map_components_to_libnames(llvm_libs | |
- ${LLVM_TARGETS_TO_BUILD} | |
- AggressiveInstCombine | |
- Analysis | |
- BinaryFormat | |
- BitReader | |
- BitWriter | |
- CodeGen | |
- Core | |
- Extensions | |
- InstCombine | |
- Instrumentation | |
- IPO | |
- IRReader | |
- Linker | |
- MC | |
- Object | |
- Passes | |
- Remarks | |
- ScalarOpts | |
- Support | |
- Target | |
- TargetParser | |
- TransformUtils | |
- Vectorize | |
- ) | |
-endif() | |
- | |
-target_link_libraries(PluginCommon | |
- PUBLIC | |
- ${llvm_libs} | |
-) | |
- | |
# Include the RPC server from the `libc` project if availible. | |
if(TARGET llvmlibc_rpc_server AND ${LIBOMPTARGET_GPU_LIBC_SUPPORT}) | |
target_link_libraries(PluginCommon PRIVATE llvmlibc_rpc_server) | |
@@ -82,8 +44,10 @@ elseif(${LIBOMPTARGET_GPU_LIBC_SUPPORT}) | |
endif() | |
endif() | |
-if ((OMPT_TARGET_DEFAULT) AND (LIBOMPTARGET_OMPT_SUPPORT)) | |
- target_link_libraries(PluginCommon PUBLIC OMPT) | |
+# If we have OMPT enabled include it in the list of sources. | |
+if (OMPT_TARGET_DEFAULT AND LIBOMPTARGET_OMPT_SUPPORT) | |
+ target_sources(PluginCommon PRIVATE OMPT/OmptCallback.cpp OMPT/OmptTracing.cpp) | |
+ target_include_directories(PluginCommon PUBLIC OMPT) | |
endif() | |
# Define the TARGET_NAME and DEBUG_PREFIX. | |
@@ -95,16 +59,11 @@ target_compile_definitions(PluginCommon PRIVATE | |
target_compile_options(PluginCommon PUBLIC ${offload_compile_flags}) | |
target_link_options(PluginCommon PUBLIC ${offload_link_flags}) | |
-target_include_directories(PluginCommon | |
- PRIVATE | |
- ${LIBOMPTARGET_INCLUDE_DIR} | |
- PUBLIC | |
+target_include_directories(PluginCommon PUBLIC | |
${CMAKE_CURRENT_SOURCE_DIR}/include | |
+ ${LIBOMPTARGET_INCLUDE_DIR} | |
) | |
set_target_properties(PluginCommon PROPERTIES | |
POSITION_INDEPENDENT_CODE ON | |
CXX_VISIBILITY_PRESET protected) | |
- | |
-add_subdirectory(OMPT) | |
- | |
diff --git a/openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt | |
deleted file mode 100644 | |
index 9a6de321a8c..00000000000 | |
--- a/openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt | |
+++ /dev/null | |
@@ -1,71 +0,0 @@ | |
-##===----------------------------------------------------------------------===## | |
-# | |
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
-# See https://llvm.org/LICENSE.txt for license information. | |
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
-# | |
-##===----------------------------------------------------------------------===## | |
-# | |
-# Aggregation of parts which can be used by OpenMP tools | |
-# | |
-##===----------------------------------------------------------------------===## | |
- | |
-# NOTE: Don't try to build `OMPT` using `add_llvm_library` because we | |
-# don't want to export `OMPT` while `add_llvm_library` requires that. | |
-add_library(OMPT OBJECT | |
- OmptCallback.cpp | |
- OmptTracing.cpp) | |
- | |
-# This is required when using LLVM libraries. | |
-llvm_update_compile_flags(OMPT) | |
- | |
-if (LLVM_LINK_LLVM_DYLIB) | |
- set(llvm_libs LLVM) | |
-else() | |
- llvm_map_components_to_libnames(llvm_libs | |
- ${LLVM_TARGETS_TO_BUILD} | |
- AggressiveInstCombine | |
- Analysis | |
- BinaryFormat | |
- BitReader | |
- BitWriter | |
- CodeGen | |
- Core | |
- Extensions | |
- InstCombine | |
- Instrumentation | |
- IPO | |
- IRReader | |
- Linker | |
- MC | |
- Object | |
- Passes | |
- Remarks | |
- ScalarOpts | |
- Support | |
- Target | |
- TargetParser | |
- TransformUtils | |
- Vectorize | |
- ) | |
-endif() | |
- | |
-target_link_libraries(OMPT | |
- PUBLIC | |
- ${llvm_libs} | |
-) | |
- | |
-# Define the TARGET_NAME and DEBUG_PREFIX. | |
-target_compile_definitions(OMPT PRIVATE | |
- TARGET_NAME="OMPT" | |
- DEBUG_PREFIX="OMPT" | |
-) | |
- | |
-target_include_directories(OMPT | |
- INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} | |
- PRIVATE ${LIBOMPTARGET_INCLUDE_DIR} | |
-) | |
- | |
-set_target_properties(OMPT PROPERTIES | |
- POSITION_INDEPENDENT_CODE ON | |
- CXX_VISIBILITY_PRESET protected) | |
diff --git a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt | |
index f81d9ce2b5e..17f0b907b0c 100644 | |
--- a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt | |
+++ b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt | |
@@ -23,31 +23,12 @@ endif() | |
libomptarget_say("Building CUDA NextGen offloading plugin.") | |
-set(LIBOMPTARGET_DLOPEN_LIBCUDA OFF) | |
-option(LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA "Build with dlopened libcuda" ${LIBOMPTARGET_DLOPEN_LIBCUDA}) | |
- | |
-add_llvm_library(omptarget.rtl.cuda SHARED | |
- src/rtl.cpp | |
- | |
- LINK_COMPONENTS | |
- Support | |
- Object | |
- | |
- LINK_LIBS PRIVATE | |
- OMPT | |
- PluginCommon | |
- ${OPENMP_PTHREAD_LIB} | |
- | |
- NO_INSTALL_RPATH | |
- BUILDTREE_ONLY | |
-) | |
- | |
-if (LIBOMP_HAVE_VERSION_SCRIPT_FLAG) | |
- target_link_libraries(omptarget.rtl.cuda PRIVATE | |
- "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports,-z,defs") | |
-endif() | |
+# Create the library and add the default arguments. | |
+add_target_library(omptarget.rtl.cuda CUDA) | |
+target_sources(omptarget.rtl.cuda PRIVATE src/rtl.cpp) | |
+option(LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA "Build with dlopened libcuda" OFF) | |
if(LIBOMPTARGET_DEP_CUDA_FOUND AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA) | |
libomptarget_say("Building CUDA plugin linked against libcuda") | |
target_link_libraries(omptarget.rtl.cuda PRIVATE CUDA::cuda_driver) | |
@@ -57,13 +38,6 @@ else() | |
target_sources(omptarget.rtl.cuda PRIVATE dynamic_cuda/cuda.cpp) | |
endif() | |
-# Define debug prefix. TODO: This should be automatized in the Debug.h but it | |
-# requires changing the original plugins. | |
-target_compile_definitions(omptarget.rtl.cuda PRIVATE TARGET_NAME="CUDA") | |
-target_compile_definitions(omptarget.rtl.cuda PRIVATE DEBUG_PREFIX="TARGET CUDA RTL") | |
- | |
-target_include_directories(omptarget.rtl.cuda PRIVATE ${LIBOMPTARGET_INCLUDE_DIR}) | |
- | |
# Configure testing for the CUDA plugin. We will build tests if we could a | |
# functional NVIDIA GPU on the system, or if manually specifies by the user. | |
option(LIBOMPTARGET_FORCE_NVIDIA_TESTS "Build NVIDIA libomptarget tests" OFF) | |
@@ -83,9 +57,5 @@ install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR} | |
if(NOT DEFINED CMAKE_INSTALL_RPATH) | |
set_target_properties(omptarget.rtl.cuda PROPERTIES | |
- INSTALL_RPATH "$ORIGIN") | |
+ INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..") | |
endif() | |
- | |
-set_target_properties(omptarget.rtl.amdgpu PROPERTIES | |
- BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.." | |
- CXX_VISIBILITY_PRESET protected) | |
diff --git a/openmp/libomptarget/plugins-nextgen/host/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/host/CMakeLists.txt | |
index ca35cac64f9..e84310464d1 100644 | |
--- a/openmp/libomptarget/plugins-nextgen/host/CMakeLists.txt | |
+++ b/openmp/libomptarget/plugins-nextgen/host/CMakeLists.txt | |
@@ -2,11 +2,6 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") | |
return() | |
endif() | |
- # build_generic_elf64("s390x" "S390X" "s390x" "systemz" "s390x-ibm-linux-gnu" "22") | |
- # build_generic_elf64("aarch64" "aarch64" "aarch64" "aarch64" "aarch64-unknown-linux-gnu" "183") | |
- # build_generic_elf64("ppc64" "PPC64" "ppc64" "ppc64" "powerpc64-ibm-linux-gnu" "21") | |
- # build_generic_elf64("x86_64" "x86_64" "x86_64" "x86_64" "x86_64-pc-linux-gnu" "62") | |
- # build_generic_elf64("ppc64le" "PPC64le" "ppc64" "ppc64le" "powerpc64le-ibm-linux-gnu" "21") | |
set(supported_targets x86_64 aarch64 ppc64 ppc64le s390x) | |
if(NOT ${CMAKE_SYSTEM_PROCESSOR} IN_LIST supported_targets) | |
libomptarget_say("Not building ${machine} NextGen offloading plugin") | |
@@ -18,16 +13,10 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le$") | |
set(machine ppc64) | |
endif() | |
-add_llvm_library(omptarget.rtl.${machine} SHARED | |
- src/rtl.cpp | |
- ADDITIONAL_HEADER_DIRS | |
- ${LIBOMPTARGET_INCLUDE_DIR} | |
- LINK_LIBS PRIVATE | |
- PluginCommon | |
- ${OPENMP_PTHREAD_LIB} | |
- NO_INSTALL_RPATH | |
- BUILDTREE_ONLY | |
-) | |
+# Create the library and add the default arguments. | |
+add_target_library(omptarget.rtl.${machine} ${machine}) | |
+ | |
+target_sources(omptarget.rtl.${machine} PRIVATE src/rtl.cpp) | |
if(LIBOMPTARGET_DEP_LIBFFI_FOUND) | |
libomptarget_say("Building ${machine} plugin linked with libffi") | |
@@ -42,29 +31,16 @@ else() | |
target_include_directories(omptarget.rtl.${machine} PRIVATE dynamic_ffi) | |
endif() | |
-if(OMPT_TARGET_DEFAULT AND LIBOMPTARGET_OMPT_SUPPORT) | |
- target_link_libraries(omptarget.rtl.${machine} PRIVATE OMPT) | |
-endif() | |
- | |
-if(LIBOMP_HAVE_VERSION_SCRIPT_FLAG) | |
- target_link_libraries(omptarget.rtl.${machine} PRIVATE | |
- "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports") | |
-endif() | |
- | |
# Install plugin under the lib destination folder. | |
install(TARGETS omptarget.rtl.${machine} | |
LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") | |
if(NOT DEFINED CMAKE_INSTALL_RPATH) | |
- set_target_properties(omptarget.rtl.amdgpu PROPERTIES | |
- INSTALL_RPATH "$ORIGIN") | |
+ set_target_properties(omptarget.rtl.${machine} PROPERTIES | |
+ INSTALL_RPATH "$ORIGIN" | |
+ BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..") | |
endif() | |
-set_target_properties(omptarget.rtl.${machine} PROPERTIES | |
- BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.." | |
- POSITION_INDEPENDENT_CODE ON | |
- CXX_VISIBILITY_PRESET protected) | |
- | |
target_include_directories(omptarget.rtl.${machine} PRIVATE | |
${LIBOMPTARGET_INCLUDE_DIR}) | |
@@ -76,12 +52,6 @@ else() | |
libomptarget_say("Not generating ${tmachine_name} tests. LibFFI not found.") | |
endif() | |
-# Define macro to be used as prefix of the runtime messages for this target. | |
-target_compile_definitions(omptarget.rtl.${machine} PRIVATE TARGET_NAME=${machine}) | |
-# TODO: This should be automatized in Debug.h. | |
-target_compile_definitions(omptarget.rtl.${machine} PRIVATE | |
- DEBUG_PREFIX="TARGET ${machine} RTL") | |
- | |
# Define the target specific triples and ELF machine values. | |
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le$" OR | |
CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64$") | |
-- | |
2.44.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment