diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake --- a/libc/cmake/modules/prepare_libc_gpu_build.cmake +++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake @@ -42,6 +42,25 @@ "build") endif() +set(LIBC_GPU_TEST_ARCHITECTURE "" CACHE STRING "Architecture for the GPU tests") +if(LIBC_GPU_TEST_ARCHITECTURE) + message(STATUS "Using user-specified GPU architecture for testing " + "'${LIBC_GPU_TARGET_ARCHITECTURE}'") + if("${LIBC_GPU_TARGET_ARCHITECTURE}" IN_LIST all_amdgpu_architectures) + set(LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU TRUE) + set(LIBC_GPU_TARGET_TRIPLE "amdgcn-amd-amdhsa") + set(LIBC_GPU_TARGET_ARCHITECTURE "${LIBC_GPU_TEST_ARCHITECTURE}") + elseif("${LIBC_GPU_TARGET_ARCHITECTURE}" IN_LIST all_nvptx_architectures) + set(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX TRUE) + set(LIBC_GPU_TARGET_TRIPLE "nvptx64-nvidia-cuda") + set(LIBC_GPU_TARGET_ARCHITECTURE "${LIBC_GPU_TEST_ARCHITECTURE}") + else() + message(FATAL_ERROR + "Unknown GPU architecture '${LIBC_GPU_TARGET_ARCHITECTURE}'") + endif() + return() +endif() + # Identify any locally installed AMD GPUs on the system to use for testing. find_program(LIBC_AMDGPU_ARCH NAMES amdgpu-arch