[libc-commits] [PATCH] D143400: [libc] Add `LIBC_GPU_TEST_ARCHITECTURE` option to set architecture

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Feb 6 07:17:06 PST 2023


jhuber6 created this revision.
jhuber6 added reviewers: michaelrj, lntue, sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
jhuber6 requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143400

Files:
  libc/cmake/modules/prepare_libc_gpu_build.cmake


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
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143400.495121.patch
Type: text/x-patch
Size: 1322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230206/12b32bce/attachment-0001.bin>


More information about the libc-commits mailing list