
In a nutshell, this moves our libomptarget code to populate the offload subproject. With this commit, users need to enable the new LLVM/Offload subproject as a runtime in their cmake configuration. No further changes are expected for downstream code. Tests and other components still depend on OpenMP and have also not been renamed. The results below are for a build in which OpenMP and Offload are enabled runtimes. In addition to the pure `git mv`, we needed to adjust some CMake files. Nothing is intended to change semantics. ``` ninja check-offload ``` Works with the X86 and AMDGPU offload tests ``` ninja check-openmp ``` Still works but doesn't build offload tests anymore. ``` ls install/lib ``` Shows all expected libraries, incl. - `libomptarget.devicertl.a` - `libomptarget-nvptx-sm_90.bc` - `libomptarget.rtl.amdgpu.so` -> `libomptarget.rtl.amdgpu.so.18git` - `libomptarget.so` -> `libomptarget.so.18git` Fixes: https://github.com/llvm/llvm-project/issues/75124 --------- Co-authored-by: Saiyedul Islam <Saiyedul.Islam@amd.com>
65 lines
3.0 KiB
CMake
65 lines
3.0 KiB
CMake
##===----------------------------------------------------------------------===##
|
|
#
|
|
# The LLVM Compiler Infrastructure
|
|
#
|
|
# This file is dual licensed under the MIT and the University of Illinois Open
|
|
# Source Licenses. See LICENSE.txt for details.
|
|
#
|
|
##===----------------------------------------------------------------------===##
|
|
#
|
|
# Build a plugin for an AMDGPU machine if available.
|
|
#
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
################################################################################
|
|
set(LIBOMPTARGET_BUILD_AMDGPU_PLUGIN TRUE CACHE BOOL
|
|
"Whether to build AMDGPU plugin")
|
|
if (NOT LIBOMPTARGET_BUILD_AMDGPU_PLUGIN)
|
|
libomptarget_say("Not building AMDGPU NextGen offloading plugin: LIBOMPTARGET_BUILD_AMDGPU_PLUGIN is false")
|
|
return()
|
|
endif()
|
|
|
|
# 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"))
|
|
libomptarget_say("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)
|
|
|
|
target_sources(omptarget.rtl.amdgpu PRIVATE src/rtl.cpp)
|
|
target_include_directories(omptarget.rtl.amdgpu PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/utils)
|
|
|
|
option(LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" OFF)
|
|
if(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()
|
|
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()
|
|
|
|
# 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)
|
|
if (LIBOMPTARGET_FOUND_AMDGPU_GPU OR LIBOMPTARGET_FORCE_AMDGPU_TESTS)
|
|
# Report to the parent scope that we are building a plugin for amdgpu
|
|
set(LIBOMPTARGET_SYSTEM_TARGETS
|
|
"${LIBOMPTARGET_SYSTEM_TARGETS} amdgcn-amd-amdhsa" PARENT_SCOPE)
|
|
list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.amdgpu")
|
|
set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
|
|
else()
|
|
libomptarget_say("Not generating AMDGPU tests, no supported devices detected."
|
|
" Use 'LIBOMPTARGET_FORCE_AMDGPU_TESTS' to override.")
|
|
endif()
|
|
|
|
# Install plugin under the lib destination folder.
|
|
install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
|
|
set_target_properties(omptarget.rtl.amdgpu PROPERTIES
|
|
INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")
|