[Openmp-commits] [PATCH] D154619: [Libomptarget] Fix tests after deleting the next-gen plugins

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jul 6 08:39:24 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: jdenny, jdoerfert, tianshilei1992, JonChesterfield, ye-luo.
Herald added subscribers: kerbowa, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

The next-gen plugins didn't correctly configure tests and were never
actually being run. Since deleting the old plugin we stopped getting
`libomptarget` tests. This patch fixes the issue and allows the targets
to be built


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154619

Files:
  openmp/libomptarget/plugins-nextgen/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt


Index: openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
+++ openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
@@ -68,6 +68,22 @@
 
 target_include_directories(omptarget.rtl.cuda PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})
 
+# Configure testing for the CUDA plugin. We will build tests if we could a
+# functional NVIDIA GPU on the system, or if manually specifies by the user.
+option(LIBOMPTARGET_FORCE_NVIDIA_TESTS "Build NVIDIA libomptarget tests" OFF)
+if (LIBOMPTARGET_FOUND_NVIDIA_GPU OR LIBOMPTARGET_FORCE_NVIDIA_TESTS)
+  libomptarget_say("Enable tests using CUDA plugin")
+  set(LIBOMPTARGET_SYSTEM_TARGETS 
+      "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda" PARENT_SCOPE)
+  set(LIBOMPTARGET_SYSTEM_TARGETS 
+      "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda-LTO" PARENT_SCOPE)
+  list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.cuda")
+  set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
+else()
+  libomptarget_say("Not generating NVIDIA tests, no supported devices detected."
+                   " Use 'LIBOMPTARGET_FORCE_NVIDIA_TESTS' to override.")
+endif()
+
 # Install plugin under the lib destination folder.
 install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
 set_target_properties(omptarget.rtl.cuda PROPERTIES
Index: openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
+++ openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
@@ -106,6 +106,20 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/utils
 )
 
+# Configure testing for the AMDGPU plugin. We will build tests if we could a
+# functional AMD GPU on the system, or if manually specifies by the user.
+option(LIBOMPTARGET_FORCE_AMDGPU_TESTS "Build AMDGPU libomptarget tests" OFF)
+if (LIBOMPTARGET_FOUND_AMDGPU_GPU OR LIBOMPTARGET_FORCE_AMDGPU_TESTS)
+  # Report to the parent scope that we are building a plugin for amdgpu
+  set(LIBOMPTARGET_SYSTEM_TARGETS 
+      "${LIBOMPTARGET_SYSTEM_TARGETS} amdgcn-amd-amdhsa" PARENT_SCOPE)
+  list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.amdgpu")
+  set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
+else()
+  libomptarget_say("Not generating AMDGPU tests, no supported devices detected."
+                   " Use 'LIBOMPTARGET_FORCE_AMDGPU_TESTS' to override.")
+  return()
+endif()
 
 # Install plugin under the lib destination folder.
 install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
Index: openmp/libomptarget/plugins-nextgen/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins-nextgen/CMakeLists.txt
+++ openmp/libomptarget/plugins-nextgen/CMakeLists.txt
@@ -73,8 +73,13 @@
       ${LIBOMPTARGET_INCLUDE_DIR}
       ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})
 
-    list(APPEND LIBOMPTARGET_TESTED_PLUGINS
-      "omptarget.rtl.${tmachine_libname}")
+    list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.${tmachine_libname}")
+    set(LIBOMPTARGET_TESTED_PLUGINS
+        "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
+    set(LIBOMPTARGET_SYSTEM_TARGETS 
+        "${LIBOMPTARGET_SYSTEM_TARGETS} ${tmachine_triple} " PARENT_SCOPE)
+    set(LIBOMPTARGET_SYSTEM_TARGETS 
+        "${LIBOMPTARGET_SYSTEM_TARGETS} ${tmachine_triple}-LTO" PARENT_SCOPE)
 
   else(LIBOMPTARGET_DEP_LIBFFI_FOUND)
     libomptarget_say("Not building ${tmachine_name} NextGen offloading plugin: libffi dependency not found.")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154619.537746.patch
Type: text/x-patch
Size: 3717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230706/47b8c2c1/attachment-0001.bin>


More information about the Openmp-commits mailing list