[libc-commits] [libc] f8563a2 - [libc] Add `LIBC_GPU_TEST_ARCHITECTURE` option to set architecture

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Feb 6 09:02:15 PST 2023


Author: Joseph Huber
Date: 2023-02-06T11:02:07-06:00
New Revision: f8563a2545416df90e41b4345ccb81f9ca9b7835

URL: https://github.com/llvm/llvm-project/commit/f8563a2545416df90e41b4345ccb81f9ca9b7835
DIFF: https://github.com/llvm/llvm-project/commit/f8563a2545416df90e41b4345ccb81f9ca9b7835.diff

LOG: [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

Added: 
    

Modified: 
    libc/cmake/modules/prepare_libc_gpu_build.cmake

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake
index 8bd7d9d32e690..beea99d468c6a 100644
--- a/libc/cmake/modules/prepare_libc_gpu_build.cmake
+++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake
@@ -42,6 +42,25 @@ if(NOT LIBC_CLANG_OFFLOAD_PACKAGER)
                       "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


        


More information about the libc-commits mailing list