[libc-commits] [PATCH] D147653: [libc] Search for the CUDA patch explicitly when testing
Joseph Huber via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Apr 5 12:19:25 PDT 2023
jhuber6 created this revision.
jhuber6 added reviewers: tra, sivachandra, lntue, michaelrj.
Herald added subscribers: libc-commits, mattd, asavonic, ecnelises, tschuett, yaxunl.
Herald added projects: libc-project, All.
jhuber6 requested review of this revision.
The packaged version of the `libc` library does not depend on the CUDA
installation because it only uses `clang` and emits LLVM-IR. However,
for testing we directly need the CUDA toolkit to emit and execute the
files. This patch explicitly passes `--cuda-path` to the relevant
compilations for NVPTX testing.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147653
Files:
libc/cmake/modules/LLVMLibCObjectRules.cmake
libc/cmake/modules/prepare_libc_gpu_build.cmake
libc/startup/gpu/nvptx/CMakeLists.txt
libc/test/IntegrationTest/CMakeLists.txt
Index: libc/test/IntegrationTest/CMakeLists.txt
===================================================================
--- libc/test/IntegrationTest/CMakeLists.txt
+++ libc/test/IntegrationTest/CMakeLists.txt
@@ -8,6 +8,7 @@
set(TEST_COMPILE_FLAGS
-march=${LIBC_GPU_TARGET_ARCHITECTURE}
--target=${LIBC_GPU_TARGET_TRIPLE}
+ --cuda-path=${LIBC_CUDA_ROOT}
)
endif()
Index: libc/startup/gpu/nvptx/CMakeLists.txt
===================================================================
--- libc/startup/gpu/nvptx/CMakeLists.txt
+++ libc/startup/gpu/nvptx/CMakeLists.txt
@@ -10,6 +10,7 @@
-nogpulib # Do not include any GPU vendor libraries.
-march=${LIBC_GPU_TARGET_ARCHITECTURE}
--target=${LIBC_GPU_TARGET_TRIPLE}
+ --cuda-path=${LIBC_CUDA_ROOT}
NO_GPU_BUNDLE # Compile this file directly without special GPU handling.
)
get_fq_target_name(crt1 fq_name)
@@ -19,4 +20,5 @@
PUBLIC
"-march=${LIBC_GPU_TARGET_ARCHITECTURE}"
"--target=${LIBC_GPU_TARGET_TRIPLE}"
+ "--cuda-path=${LIBC_CUDA_ROOT}"
)
Index: libc/cmake/modules/prepare_libc_gpu_build.cmake
===================================================================
--- libc/cmake/modules/prepare_libc_gpu_build.cmake
+++ libc/cmake/modules/prepare_libc_gpu_build.cmake
@@ -98,3 +98,10 @@
else()
message(FATAL_ERROR "Unknown GPU architecture '${gpu_test_architecture}'")
endif()
+
+if(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
+ find_package(CUDAToolkit QUIET)
+ if(CUDAToolkit_FOUND)
+ get_filename_component(LIBC_CUDA_ROOT "${CUDAToolkit_BIN_DIR}/.." ABSOLUTE)
+ endif()
+endif()
Index: libc/cmake/modules/LLVMLibCObjectRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -195,7 +195,9 @@
if(LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
target_compile_options(${internal_target_name} PRIVATE -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto)
elseif(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
- target_compile_options(${internal_target_name} PRIVATE -march=${LIBC_GPU_TARGET_ARCHITECTURE})
+ target_compile_options(${internal_target_name} PRIVATE
+ -march=${LIBC_GPU_TARGET_ARCHITECTURE}
+ --cuda-path=${LIBC_CUDA_ROOT})
endif()
target_include_directories(${internal_target_name} PRIVATE ${include_dirs})
if(full_deps_list)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147653.511182.patch
Type: text/x-patch
Size: 2441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230405/e9fc51ff/attachment.bin>
More information about the libc-commits
mailing list