Skip to content

Commit 64b3cdc

Browse files
authored
[libc] Fix GPU handling for unsupported backends (#92271)
Summary: If the user does not have the selected backend enabled, we should still be able to build the LLVM-IR an ddistribute it. This patch makes logic to suppress tests if the backend can't build it, as well as removing a flag for the building that's only present int he NVPTX backend.
1 parent d542eb7 commit 64b3cdc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function(_get_common_compile_options output_var flags)
101101

102102
if(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
103103
list(APPEND compile_options "-Wno-unknown-cuda-version")
104-
list(APPEND compile_options "SHELL:-mllvm -nvptx-emit-init-fini-kernel=false")
105104
list(APPEND compile_options "--cuda-feature=+ptx63")
106105
if(LIBC_CUDA_ROOT)
107106
list(APPEND compile_options "--cuda-path=${LIBC_CUDA_ROOT}")

libc/cmake/modules/prepare_libc_gpu_build.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@ elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
7676
endif()
7777

7878
set(gpu_test_architecture "")
79-
if(LIBC_GPU_TEST_ARCHITECTURE)
79+
if(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_AMDGPU
80+
AND NOT "AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
81+
set(LIBC_GPU_TESTS_DISABLED TRUE)
82+
message(STATUS "AMDGPU backend is not available, tests will not be built")
83+
elseif(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_AMDGPU
84+
AND NOT "NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
85+
set(LIBC_GPU_TESTS_DISABLED TRUE)
86+
message(STATUS "NVPTX backend is not available, tests will not be built")
87+
elseif(LIBC_GPU_TEST_ARCHITECTURE)
8088
set(LIBC_GPU_TESTS_DISABLED FALSE)
8189
set(gpu_test_architecture ${LIBC_GPU_TEST_ARCHITECTURE})
8290
message(STATUS "Using user-specified GPU architecture for testing: "

0 commit comments

Comments
 (0)