-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[OpenMP] Allow to specify what plugins to look for #74538
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-openmp Author: Johannes Doerfert (jdoerfert) ChangesBy 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:
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) {
|
Can we just use arch name, such as |
By default we now only look for the plugins we build, but the user can overwrite that with LIBOMPTARGET_PLUGINS_TO_LOAD="cuda,amdgpu,x86_64"
3f95bdb
to
042ba96
Compare
Done. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
0428f04
to
269a2a0
Compare
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.
LG
By default we now only look for the plugins we build, but the user can overwrite that with
LIBOMPTARGET_PLUGINS_TO_LOAD="cuda,amdgpu,x86_64"