Skip to content

Commit c5dc456

Browse files
committed
[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.
1 parent 4a44e4b commit c5dc456

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

offload/DeviceRTL/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ elseif(LIBOMPTARGET_DEVICE_ARCHITECTURES STREQUAL "auto" OR
6969
"${LIBOMPTARGET_NVPTX_DETECTED_ARCH_LIST};${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST}")
7070
endif()
7171
list(REMOVE_DUPLICATES LIBOMPTARGET_DEVICE_ARCHITECTURES)
72+
# for tests
73+
set(LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES ${LIBOMPTARGET_DEVICE_ARCHITECTURES}
74+
PARENT_SCOPE)
7275

7376
set(include_files
7477
${include_directory}/Allocator.h

offload/test/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM
3737
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
3838
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
3939

40+
if(CURRENT_TARGET MATCHES "^amdgcn" AND
41+
NOT "${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST}"
42+
IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
43+
message(WARNING "Detected AMDGPU arch ${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST} "
44+
"not in built arch list, ${CURRENT_TARGET} tests will be skipped")
45+
continue()
46+
elseif(CURRENT_TARGET MATCHES "^nvptx" AND
47+
NOT "${LIBOMPTARGET_DEP_CUDA_ARCH}"
48+
IN_LIST LIBOMPTARGET_EXPANDED_DEVICE_ARCHITECTURES)
49+
message(WARNING "Detected NVPTX arch ${LIBOMPTARGET_DEP_CUDA_ARCH} "
50+
"not in built arch list, ${CURRENT_TARGET} tests will be skipped")
51+
continue()
52+
endif()
53+
4054
add_offload_testsuite(check-libomptarget-${CURRENT_TARGET}
4155
"Running libomptarget tests"
4256
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}

0 commit comments

Comments
 (0)