[Openmp-commits] [PATCH] D95467: [libomptarget][cuda] Only run tests when sure there is cuda available

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 26 12:41:35 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGfdeffd6fb0c1: [libomptarget][cuda] Only run tests when sure there is cuda available (authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95467

Files:
  openmp/libomptarget/plugins/cuda/CMakeLists.txt


Index: openmp/libomptarget/plugins/cuda/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/cuda/CMakeLists.txt
+++ openmp/libomptarget/plugins/cuda/CMakeLists.txt
@@ -24,10 +24,15 @@
 
 include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS})
 
-option(LIBOMPTARGET_DLOPEN_LIBCUDA "Build with dlopened libcuda" OFF)
+set(LIBOMPTARGET_DLOPEN_LIBCUDA OFF)
+option(LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA "Build with dlopened libcuda" ${LIBOMPTARGET_DLOPEN_LIBCUDA})
 
-if (LIBOMPTARGET_DEP_CUDA_FOUND AND LIBOMPTARGET_DEP_CUDA_DRIVER_FOUND
-      AND NOT LIBOMPTARGET_DLOPEN_LIBCUDA)
+set(LIBOMPTARGET_CAN_LINK_LIBCUDA FALSE)
+if (LIBOMPTARGET_DEP_CUDA_FOUND AND LIBOMPTARGET_DEP_CUDA_DRIVER_FOUND)
+  set(LIBOMPTARGET_CAN_LINK_LIBCUDA TRUE)
+endif()
+
+if (LIBOMPTARGET_CAN_LINK_LIBCUDA AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
   libomptarget_say("Building CUDA plugin linked against libcuda")
   include_directories(${LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS})
   add_library(omptarget.rtl.cuda SHARED src/rtl.cpp)
@@ -51,4 +56,12 @@
   "-Wl,-z,defs")
 
 # Report to the parent scope that we are building a plugin for CUDA.
-set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda" PARENT_SCOPE)
+# This controls whether tests are run for the nvptx offloading target
+# Run them if libcuda is available, or if the user explicitly asked for dlopen
+# Otherwise this plugin is being built speculatively and there may be no cuda available
+if (LIBOMPTARGET_CAN_LINK_LIBCUDA OR LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
+  libomptarget_say("Enable tests using CUDA plugin")
+  set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda" PARENT_SCOPE)
+else()
+  libomptarget_say("Disabling tests using CUDA plugin as cuda may not be available")
+endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95467.319387.patch
Type: text/x-patch
Size: 1855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210126/97382475/attachment.bin>


More information about the Openmp-commits mailing list