[Openmp-commits] [PATCH] D141933: [Libomptarget] Replace Nvidia arch lookup with 'nvptx-arch'

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 17 07:04:17 PST 2023


jhuber6 updated this revision to Diff 489811.
jhuber6 added a comment.

Fix conditional in case the program isn't found.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141933/new/

https://reviews.llvm.org/D141933

Files:
  openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
  openmp/libomptarget/test/lit.cfg


Index: openmp/libomptarget/test/lit.cfg
===================================================================
--- openmp/libomptarget/test/lit.cfg
+++ openmp/libomptarget/test/lit.cfg
@@ -85,7 +85,7 @@
 supports_unified_shared_memory = True
 if config.libomptarget_current_target.startswith('nvptx'):
   try:
-    cuda_arch = int(config.cuda_test_arch)
+      cuda_arch = int(config.cuda_test_arch[:3])
     if cuda_arch < 70:
       supports_unified_shared_memory = False
   except ValueError:
Index: openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
===================================================================
--- openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -106,15 +106,19 @@
 endif()
 find_package(CUDA QUIET)
 
-# Try to get the highest Nvidia GPU architecture the system supports
-if (CUDA_FOUND)
-  cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS)
-  string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH_OUTPUT ${CUDA_ARCH_FLAGS})
-  if (NOT DEFINED CUDA_ARCH_MATCH_OUTPUT OR "${CMAKE_MATCH_1}" LESS 35)
-    libomptarget_warning_say("Setting Nvidia GPU architecture support for OpenMP target runtime library to sm_35 by default")
-    set(LIBOMPTARGET_DEP_CUDA_ARCH "35")
-  else()
-    set(LIBOMPTARGET_DEP_CUDA_ARCH "${CMAKE_MATCH_1}")
+# Identify any locally installed GPUs to use for testing.
+set(LIBOMPTARGET_DEP_CUDA_ARCH "sm_35")
+
+find_program(LIBOMPTARGET_NVPTX_ARCH NAMES nvptx-arch PATHS ${LLVM_BINARY_DIR}/bin)
+if(LIBOMPTARGET_NVPTX_ARCH)
+  execute_process(COMMAND ${LIBOMPTARGET_NVPTX_ARCH}
+                  OUTPUT_VARIABLE LIBOMPTARGET_NVPTX_ARCH_OUTPUT
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+  string(FIND "${LIBOMPTARGET_NVPTX_ARCH_OUTPUT}" "\n" first_arch_string)
+  string(SUBSTRING "${LIBOMPTARGET_NVPTX_ARCH_OUTPUT}" 0 ${first_arch_string}
+         arch_string)
+  if(arch_string)
+    set(LIBOMPTARGET_DEP_CUDA_ARCH "${arch_string}")
   endif()
 endif()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141933.489811.patch
Type: text/x-patch
Size: 2022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230117/dcbcaac5/attachment.bin>


More information about the Openmp-commits mailing list