Skip to content

Commit f8563a2

Browse files
committed
[libc] Add LIBC_GPU_TEST_ARCHITECTURE option to set architecture
Currently, the plan is to support testing on a single GPU architecture. We query the supported architectures from the user's system. However, there are times when the user would want to override this. This patch adds the `LIBC_GPU_TEST_ARCHITECTURE` option, which allows users to specify which GPU architecture to build for. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D143400
1 parent 8537a7c commit f8563a2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

libc/cmake/modules/prepare_libc_gpu_build.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@ if(NOT LIBC_CLANG_OFFLOAD_PACKAGER)
4242
"build")
4343
endif()
4444

45+
set(LIBC_GPU_TEST_ARCHITECTURE "" CACHE STRING "Architecture for the GPU tests")
46+
if(LIBC_GPU_TEST_ARCHITECTURE)
47+
message(STATUS "Using user-specified GPU architecture for testing "
48+
"'${LIBC_GPU_TARGET_ARCHITECTURE}'")
49+
if("${LIBC_GPU_TARGET_ARCHITECTURE}" IN_LIST all_amdgpu_architectures)
50+
set(LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU TRUE)
51+
set(LIBC_GPU_TARGET_TRIPLE "amdgcn-amd-amdhsa")
52+
set(LIBC_GPU_TARGET_ARCHITECTURE "${LIBC_GPU_TEST_ARCHITECTURE}")
53+
elseif("${LIBC_GPU_TARGET_ARCHITECTURE}" IN_LIST all_nvptx_architectures)
54+
set(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX TRUE)
55+
set(LIBC_GPU_TARGET_TRIPLE "nvptx64-nvidia-cuda")
56+
set(LIBC_GPU_TARGET_ARCHITECTURE "${LIBC_GPU_TEST_ARCHITECTURE}")
57+
else()
58+
message(FATAL_ERROR
59+
"Unknown GPU architecture '${LIBC_GPU_TARGET_ARCHITECTURE}'")
60+
endif()
61+
return()
62+
endif()
63+
4564
# Identify any locally installed AMD GPUs on the system to use for testing.
4665
find_program(LIBC_AMDGPU_ARCH
4766
NAMES amdgpu-arch

0 commit comments

Comments
 (0)