From: Joseph Huber Date: Sat, 25 Mar 2023 02:00:25 +0000 (-0500) Subject: [libc] Enable integration tests targeting NVIDIA GPUs X-Git-Tag: upstream/17.0.6~13588 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b26970ec4b79590f41f5e1dd7cb56d5f8d4d9301;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index f28b345..4e1a63d 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. + $<$:${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. + $<$>:${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 5e9f0a1..f037d3f 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 "$" ) +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 "$" + ) endif()