[Offload] Fix enabling plugins on unsupported platforms (#93186)

Summary:
Certain plugins can only be built on specific platforms. Previously this
didn't cause issues becaues each one was handled independently. However,
now that we link these all directly they need to be in a CMake list.
Furthermore we use this list to generate a config file. For this reason
these checks are moved to where we normalize the support.

Fixes: https://github.com/llvm/llvm-project/issues/93183
This commit is contained in:
Joseph Huber 2024-05-23 08:06:41 -05:00 committed by GitHub
parent 4feae05c6a
commit 300e5b9114
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 16 deletions

View File

@ -143,6 +143,25 @@ set(LIBOMPTARGET_PLUGINS_TO_BUILD "all" CACHE STRING
if(LIBOMPTARGET_PLUGINS_TO_BUILD STREQUAL "all")
set(LIBOMPTARGET_PLUGINS_TO_BUILD ${LIBOMPTARGET_ALL_PLUGIN_TARGETS})
endif()
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" AND
"host" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
message(STATUS "Not building host plugin: only Linux systems are supported")
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "host")
endif()
if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$"
AND CMAKE_SYSTEM_NAME MATCHES "Linux"))
if("amdgpu" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
message(STATUS "Not building AMDGPU plugin: only support AMDGPU in "
"Linux x86_64, ppc64le, or aarch64 hosts")
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "amdgpu")
endif()
if("nvptx" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
message(STATUS "Not building CUDA plugin: only support AMDGPU in "
"Linux x86_64, ppc64le, or aarch64 hosts")
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "cuda")
endif()
endif()
message(STATUS "Building the offload library with support for "
"the \"${LIBOMPTARGET_PLUGINS_TO_BUILD}\" plugins")

View File

@ -1,11 +1,6 @@
# 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)
if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux"))
message(STATUS "Not building AMDGPU NextGen plugin: only support AMDGPU in Linux x86_64, ppc64le, or aarch64 hosts")
return()
endif()
# Create the library and add the default arguments.
add_target_library(omptarget.rtl.amdgpu AMDGPU)

View File

@ -1,10 +1,3 @@
if (NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux"))
message(STATUS "Not building CUDA NextGen offloading plugin: only support CUDA in Linux x86_64, ppc64le, or aarch64 hosts.")
return()
endif()
message(STATUS "Building CUDA NextGen offloading plugin.")
# Create the library and add the default arguments.
add_target_library(omptarget.rtl.cuda CUDA)

View File

@ -1,7 +1,3 @@
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
return()
endif()
set(supported_targets x86_64 aarch64 ppc64 ppc64le s390x)
if(NOT ${CMAKE_SYSTEM_PROCESSOR} IN_LIST supported_targets)
message(STATUS "Not building ${machine} NextGen offloading plugin")