[llvm] [offload] [test] Skip amdgcn/nvptx tests if detected arch is not built (PR #119006)
Michał Górny via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 7 08:58:29 PST 2024
https://github.com/mgorny updated https://github.com/llvm/llvm-project/pull/119006
>From c5dc45653ce6e77e08747fe4ec4f6c94b18d9566 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny at gentoo.org>
Date: Fri, 6 Dec 2024 19:20:44 +0100
Subject: [PATCH 1/2] [offload] [test] Skip amdgcn/nvptx tests if detected arch
is not built
Skip amdgcn and/or nvptx tests, if the detected GPU architecture
is not present among GPUs offload was built for. Without this change,
the tests are run if any GPU is detected -- which could lead
to cryptic test failures, such as the ones reported in #118824.
---
offload/DeviceRTL/CMakeLists.txt | 3 +++
offload/test/CMakeLists.txt | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/offload/DeviceRTL/CMakeLists.txt b/offload/DeviceRTL/CMakeLists.txt
index 32a7510be980d8..94746b35ea7e0d 100644
--- a/offload/DeviceRTL/CMakeLists.txt
+++ b/offload/DeviceRTL/CMakeLists.txt
@@ -69,6 +69,9 @@ elseif(LIBOMPTARGET_DEVICE_ARCHITECTURES STREQUAL "auto" OR
"${LIBOMPTARGET_NVPTX_DETECTED_ARCH_LIST};${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST}")
endif()
list(REMOVE_DUPLICATES LIBOMPTARGET_DEVICE_ARCHITECTURES)
+# for tests
+set(LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES ${LIBOMPTARGET_DEVICE_ARCHITECTURES}
+ PARENT_SCOPE)
set(include_files
${include_directory}/Allocator.h
diff --git a/offload/test/CMakeLists.txt b/offload/test/CMakeLists.txt
index 8a827e0a625eff..9ab213acd23be2 100644
--- a/offload/test/CMakeLists.txt
+++ b/offload/test/CMakeLists.txt
@@ -37,6 +37,20 @@ string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
+ if(CURRENT_TARGET MATCHES "^amdgcn" AND
+ NOT "${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST}"
+ IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
+ message(WARNING "Detected AMDGPU arch ${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST} "
+ "not in built arch list, ${CURRENT_TARGET} tests will be skipped")
+ continue()
+ elseif(CURRENT_TARGET MATCHES "^nvptx" AND
+ NOT "${LIBOMPTARGET_DEP_CUDA_ARCH}"
+ IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
+ message(WARNING "Detected NVPTX arch ${LIBOMPTARGET_DEP_CUDA_ARCH} "
+ "not in built arch list, ${CURRENT_TARGET} tests will be skipped")
+ continue()
+ endif()
+
add_offload_testsuite(check-libomptarget-${CURRENT_TARGET}
"Running libomptarget tests"
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}
>From 8492bda7f4377d39dca7ccb86d966d209c82888f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny at gentoo.org>
Date: Sat, 7 Dec 2024 17:57:25 +0100
Subject: [PATCH 2/2] [offload] Move test gpu arch checks into plugins-nextgen
---
offload/CMakeLists.txt | 2 +-
offload/plugins-nextgen/amdgpu/CMakeLists.txt | 5 ++++-
offload/plugins-nextgen/cuda/CMakeLists.txt | 5 ++++-
offload/test/CMakeLists.txt | 14 --------------
4 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 8da95c5c74e445..c7c5f4ecfbac76 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -370,8 +370,8 @@ set(LIBOMPTARGET_LLVM_LIBRARY_INTDIR "${LIBOMPTARGET_INTDIR}" CACHE STRING
"Path to folder where intermediate libraries will be output")
# Build offloading plugins and device RTLs if they are available.
-add_subdirectory(plugins-nextgen)
add_subdirectory(DeviceRTL)
+add_subdirectory(plugins-nextgen)
add_subdirectory(tools)
# Build target agnostic offloading library.
diff --git a/offload/plugins-nextgen/amdgpu/CMakeLists.txt b/offload/plugins-nextgen/amdgpu/CMakeLists.txt
index 47cd2feefc7288..7e443114057f4d 100644
--- a/offload/plugins-nextgen/amdgpu/CMakeLists.txt
+++ b/offload/plugins-nextgen/amdgpu/CMakeLists.txt
@@ -20,7 +20,10 @@ endif()
# 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)
+if ((LIBOMPTARGET_FOUND_AMDGPU_GPU
+ AND "${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST}"
+ IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
+ 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)
diff --git a/offload/plugins-nextgen/cuda/CMakeLists.txt b/offload/plugins-nextgen/cuda/CMakeLists.txt
index 5fdfb8f9cf6282..6c0dca80d71212 100644
--- a/offload/plugins-nextgen/cuda/CMakeLists.txt
+++ b/offload/plugins-nextgen/cuda/CMakeLists.txt
@@ -16,7 +16,10 @@ endif()
# 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)
+if ((LIBOMPTARGET_FOUND_NVIDIA_GPU
+ AND "${LIBOMPTARGET_DEP_CUDA_ARCH}"
+ IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
+ OR LIBOMPTARGET_FORCE_NVIDIA_TESTS)
message(STATUS "Enable tests using CUDA plugin")
set(LIBOMPTARGET_SYSTEM_TARGETS
"${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda nvptx64-nvidia-cuda-LTO" PARENT_SCOPE)
diff --git a/offload/test/CMakeLists.txt b/offload/test/CMakeLists.txt
index 9ab213acd23be2..8a827e0a625eff 100644
--- a/offload/test/CMakeLists.txt
+++ b/offload/test/CMakeLists.txt
@@ -37,20 +37,6 @@ string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
- if(CURRENT_TARGET MATCHES "^amdgcn" AND
- NOT "${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST}"
- IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
- message(WARNING "Detected AMDGPU arch ${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST} "
- "not in built arch list, ${CURRENT_TARGET} tests will be skipped")
- continue()
- elseif(CURRENT_TARGET MATCHES "^nvptx" AND
- NOT "${LIBOMPTARGET_DEP_CUDA_ARCH}"
- IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
- message(WARNING "Detected NVPTX arch ${LIBOMPTARGET_DEP_CUDA_ARCH} "
- "not in built arch list, ${CURRENT_TARGET} tests will be skipped")
- continue()
- endif()
-
add_offload_testsuite(check-libomptarget-${CURRENT_TARGET}
"Running libomptarget tests"
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}
More information about the llvm-commits
mailing list