[libc-commits] [libc] b26970e - [libc] Enable integration tests targeting NVIDIA GPUs
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Mon Mar 27 06:49:27 PDT 2023
Author: Joseph Huber
Date: 2023-03-27T08:47:16-05:00
New Revision: b26970ec4b79590f41f5e1dd7cb56d5f8d4d9301
URL: https://github.com/llvm/llvm-project/commit/b26970ec4b79590f41f5e1dd7cb56d5f8d4d9301
DIFF: https://github.com/llvm/llvm-project/commit/b26970ec4b79590f41f5e1dd7cb56d5f8d4d9301.diff
LOG: [libc] Enable integration tests targeting NVIDIA GPUs
This patch adds the necessary build infrastructure to build and run the
integration tests on NVIDIA GPUs. The NVIDIA `nvlink` linker utility is
what is ultimately used to combine these files into a single executable
image. Unfortunately, their tool does not support static libraries. So
we need to link with every object directly instead. This could be solved
by impelementing a "wrapper" utility around `nvlink` like we used to use
for OpenMP. But for now this should be sufficient.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D146861
Added:
Modified:
libc/cmake/modules/LLVMLibCTestRules.cmake
libc/utils/gpu/loader/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index f28b345fd45cf..4e1a63dc37652 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -484,6 +484,8 @@ function(add_integration_test test_name)
add_executable(
${fq_build_target_name}
EXCLUDE_FROM_ALL
+ # The NVIDIA 'nvlink' linker does not currently support static libraries.
+ $<$<BOOL:${LIBC_TARGET_ARCHITECTURE_IS_GPU}>:${link_object_files}>
${INTEGRATION_TEST_SRCS}
${INTEGRATION_TEST_HDRS}
)
@@ -510,9 +512,12 @@ function(add_integration_test test_name)
endif()
target_link_options(${fq_build_target_name} PRIVATE -nostdlib -static)
- target_link_libraries(${fq_build_target_name} ${fq_target_name}.__libc__
- libc.startup.${LIBC_TARGET_OS}.crt1
- libc.test.IntegrationTest.test)
+ target_link_libraries(
+ ${fq_build_target_name}
+ # The NVIDIA 'nvlink' linker does not currently support static libraries.
+ $<$<NOT:$<BOOL:${LIBC_TARGET_ARCHITECTURE_IS_GPU}>>:${fq_target_name}.__libc__>
+ libc.startup.${LIBC_TARGET_OS}.crt1
+ libc.test.IntegrationTest.test)
add_dependencies(${fq_build_target_name}
libc.test.IntegrationTest.test
${INTEGRATION_TEST_DEPENDS})
diff --git a/libc/utils/gpu/loader/CMakeLists.txt b/libc/utils/gpu/loader/CMakeLists.txt
index 5e9f0a1a49559..f037d3f3e205a 100644
--- a/libc/utils/gpu/loader/CMakeLists.txt
+++ b/libc/utils/gpu/loader/CMakeLists.txt
@@ -24,4 +24,12 @@ if(TARGET amdhsa_loader AND LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
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()
More information about the libc-commits
mailing list