Files
clang-p2996/libc/utils/gpu/loader/CMakeLists.txt
Joseph Huber dcdfc963d7 [libc] Export GPU extensions to libc for external use
The GPU port of the LLVM C library needs to export a few extensions to
the interface such that users can interface with it. This patch adds the
necessary logic to define a GPU extension. Currently, this only exports
a `rpc_reset_client` function. This allows us to use the server in
D147054 to set up the RPC interface outside of `libc`.

Depends on https://reviews.llvm.org/D147054

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D152283
2023-06-15 11:02:24 -05:00

49 lines
1.6 KiB
CMake

add_library(gpu_loader OBJECT Main.cpp)
target_include_directories(gpu_loader PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${LIBC_SOURCE_DIR}/include
${LIBC_SOURCE_DIR}
)
find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
if(hsa-runtime64_FOUND)
add_subdirectory(amdgpu)
else()
message(STATUS "Skipping HSA loader for gpu target, no HSA was detected")
endif()
find_package(CUDAToolkit QUIET)
# The CUDA loader requires LLVM to traverse the ELF image for symbols.
find_package(LLVM QUIET)
if(CUDAToolkit_FOUND AND LLVM_FOUND AND
"${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "11.2")
add_subdirectory(nvptx)
else()
if("${CUDAToolkit_VERSION}" VERSION_LESS "11.2")
message(WARNING
"Skipping CUDA loader for gpu target, CUDA must be version 11.2 or later.
Found CUDA Version ${CUDAToolkit_VERSION}")
else()
message(STATUS "Skipping CUDA loader for gpu target, no CUDA was detected")
endif()
endif()
# Add a custom target to be used for testing.
if(TARGET amdhsa_loader AND LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
add_custom_target(libc.utils.gpu.loader)
add_dependencies(libc.utils.gpu.loader amdhsa_loader)
set_target_properties(
libc.utils.gpu.loader
PROPERTIES
EXECUTABLE "$<TARGET_FILE:amdhsa_loader>"
)
elseif(TARGET nvptx_loader AND LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
add_custom_target(libc.utils.gpu.loader)
add_dependencies(libc.utils.gpu.loader nvptx_loader)
set_target_properties(
libc.utils.gpu.loader
PROPERTIES
EXECUTABLE "$<TARGET_FILE:nvptx_loader>"
)
endif()