[Openmp-commits] [openmp] [OpenMP] Allow to specify what plugins to look for (PR #74538)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue Dec 5 15:52:23 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-openmp
Author: Johannes Doerfert (jdoerfert)
<details>
<summary>Changes</summary>
By default we now only look for the plugins we build, but the user can overwrite that with LIBOMPTARGET_PLUGINS_TO_LOAD="plugA.so","plugB.so"
---
Full diff: https://github.com/llvm/llvm-project/pull/74538.diff
3 Files Affected:
- (modified) openmp/libomptarget/CMakeLists.txt (+4-4)
- (modified) openmp/libomptarget/src/CMakeLists.txt (+22)
- (modified) openmp/libomptarget/src/PluginManager.cpp (+4)
``````````diff
diff --git a/openmp/libomptarget/CMakeLists.txt b/openmp/libomptarget/CMakeLists.txt
index 972b887c7c952..115189a28ce16 100644
--- a/openmp/libomptarget/CMakeLists.txt
+++ b/openmp/libomptarget/CMakeLists.txt
@@ -110,10 +110,6 @@ set(LIBOMPTARGET_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
message(STATUS "OpenMP tools dir in libomptarget: ${LIBOMP_OMP_TOOLS_INCLUDE_DIR}")
include_directories(${LIBOMP_OMP_TOOLS_INCLUDE_DIR})
-# Build target agnostic offloading library.
-set(LIBOMPTARGET_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
-add_subdirectory(${LIBOMPTARGET_SRC_DIR})
-
# Definitions for testing, for reuse when testing libomptarget-nvptx.
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${LIBOMP_INCLUDE_DIR}" CACHE STRING
"Path to folder containing omp.h")
@@ -129,5 +125,9 @@ add_subdirectory(plugins-nextgen)
add_subdirectory(DeviceRTL)
add_subdirectory(tools)
+# Build target agnostic offloading library.
+set(LIBOMPTARGET_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
+add_subdirectory(${LIBOMPTARGET_SRC_DIR})
+
# Add tests.
add_subdirectory(test)
diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt
index 7c311f738ac8e..f5e0672087c38 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -55,6 +55,28 @@ target_compile_definitions(omptarget PRIVATE
DEBUG_PREFIX="omptarget"
)
+macro(check_plugin_target target)
+if (TARGET ${target})
+ if (NOT LIBOMPTARGET_PLUGINS_TO_LOAD)
+ set(LIBOMPTARGET_PLUGINS_TO_LOAD "\"lib${target}\"")
+ else()
+ set(LIBOMPTARGET_PLUGINS_TO_LOAD ${LIBOMPTARGET_PLUGINS_TO_LOAD},"lib${target}")
+ endif()
+endif()
+endmacro()
+
+set(LIBOMPTARGET_PLUGINS_TO_LOAD "" CACHE STRING
+ "Comma separated list of plugin names to look for at runtime")
+if (NOT LIBOMPTARGET_PLUGINS_TO_LOAD)
+ check_plugin_target(omptarget.rtl.ppc64)
+ check_plugin_target(omptarget.rtl.x86_64)
+ check_plugin_target(omptarget.rtl.cuda)
+ check_plugin_target(omptarget.rtl.aarch64)
+ check_plugin_target(omptarget.rtl.amdgpu)
+endif()
+
+target_compile_definitions(omptarget PRIVATE ENABLED_OFFLOAD_PLUGINS=${LIBOMPTARGET_PLUGINS_TO_LOAD})
+
# libomptarget.so needs to be aware of where the plugins live as they
# are now separated in the build directory.
set_target_properties(omptarget PROPERTIES
diff --git a/openmp/libomptarget/src/PluginManager.cpp b/openmp/libomptarget/src/PluginManager.cpp
index 931143ad2347d..f9f19240a17b5 100644
--- a/openmp/libomptarget/src/PluginManager.cpp
+++ b/openmp/libomptarget/src/PluginManager.cpp
@@ -23,11 +23,15 @@ PluginManager *PM;
// List of all plugins that can support offloading.
static const char *RTLNames[] = {
+#ifdef ENABLED_OFFLOAD_PLUGINS
+ ENABLED_OFFLOAD_PLUGINS
+#else
/* PowerPC target */ "libomptarget.rtl.ppc64",
/* x86_64 target */ "libomptarget.rtl.x86_64",
/* CUDA target */ "libomptarget.rtl.cuda",
/* AArch64 target */ "libomptarget.rtl.aarch64",
/* AMDGPU target */ "libomptarget.rtl.amdgpu",
+#endif
};
PluginAdaptorTy::PluginAdaptorTy(const std::string &Name) : Name(Name) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/74538
More information about the Openmp-commits
mailing list