Skip to content

Commit 39ef280

Browse files
committed
[UR] Move adapter tests over to lit
This moves the CUDA/HIP and Level Zero adapter tests over to lit. New targets are available, `check-unified-runtime-level_zero`, `check-unified-runtime-hip` and `check-unified-runtime-cuda` where applicable. The generic `check-unified-runtime-adapter` can be used to run it all the above.
1 parent e185000 commit 39ef280

32 files changed

+283
-314
lines changed

.github/workflows/ur-build-hw.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ jobs:
176176
- name: Test adapter specific
177177
env:
178178
ZE_ENABLE_LOADER_DEBUG_TRACE: 1
179-
run: ctest -C ${{matrix.build_type}} --test-dir build --output-on-failure -L "adapter-specific" -E "memcheck" --timeout 600 -VV
179+
LIT_OPTS: " --timeout 120"
180+
run: cmake --build build -j $(nproc) -- check-unified-runtime-adapter
180181
# Don't run adapter specific tests when building multiple adapters
181182
if: ${{ matrix.adapter.other_name == '' }}
182183

unified-runtime/test/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ set(INSTALL_GTEST OFF)
2626
FetchContent_MakeAvailable(googletest)
2727
enable_testing()
2828

29+
find_program(VALGRIND valgrind)
30+
2931
# Set up the root `check-unified-runtime` target
3032
configure_file(lit.site.cfg.py.in lit.site.cfg.py)
3133
add_custom_target(deps_check-unified-runtime)

unified-runtime/test/adapters/CMakeLists.txt

+1-72
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,7 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
function(add_adapter_test name)
7-
cmake_parse_arguments(args
8-
"" # options
9-
"FIXTURE" # one value keywords
10-
"SOURCES;ENVIRONMENT" # multi value keywords
11-
${ARGN})
12-
13-
set(target test-adapter-${name})
14-
add_ur_executable(${target} ${args_SOURCES}
15-
${PROJECT_SOURCE_DIR}/test/conformance/source/environment.cpp
16-
${PROJECT_SOURCE_DIR}/test/conformance/source/main.cpp
17-
)
18-
19-
set(fixtures "PLATFORM;DEVICES;KERNELS")
20-
if(NOT args_FIXTURE IN_LIST fixtures)
21-
message(FATAL_ERROR
22-
"FIXTURE must be one of: ${fixtures}. Found: ${args_FIXTURE}")
23-
endif()
24-
25-
target_compile_definitions(${target} PRIVATE
26-
${args_FIXTURE}_ENVIRONMENT)
27-
28-
if(${args_FIXTURE} STREQUAL "KERNELS")
29-
target_compile_definitions(${target} PRIVATE KERNELS_ENVIRONMENT PRIVATE
30-
KERNELS_DEFAULT_DIR="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}")
31-
target_include_directories(${target}
32-
PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR})
33-
add_dependencies(${target} generate_device_binaries kernel_names_header)
34-
endif()
35-
36-
target_link_libraries(${target} PRIVATE
37-
${PROJECT_NAME}::loader
38-
${PROJECT_NAME}::headers
39-
${PROJECT_NAME}::testing
40-
${PROJECT_NAME}::common
41-
GTest::gtest)
42-
43-
add_test(NAME ${target} COMMAND $<TARGET_FILE:${target}>
44-
--devices_count=${UR_TEST_DEVICES_COUNT}
45-
--platforms_count=${UR_TEST_DEVICES_COUNT})
46-
set_tests_properties(${target} PROPERTIES
47-
LABELS "adapter-specific;${name}"
48-
ENVIRONMENT "${args_ENVIRONMENT}")
49-
endfunction()
50-
51-
find_program(VALGRIND valgrind)
52-
53-
function(add_adapter_memcheck_test name)
54-
cmake_parse_arguments(args
55-
"" # options
56-
"" # one value keywords
57-
"ENVIRONMENT" # multi value keywords
58-
${ARGN})
59-
if(VALGRIND)
60-
set(target test-adapter-${name})
61-
set(test_name ${target}-memcheck)
62-
63-
add_test(NAME ${test_name}
64-
COMMAND ${CMAKE_COMMAND}
65-
-D TEST_FILE=valgrind
66-
-D TEST_ARGS="--tool=memcheck --leak-check=full $<TARGET_FILE:${target}> --backend=${backend} --devices_count=${UR_TEST_DEVICES_COUNT} --platforms_count=${UR_TEST_DEVICES_COUNT}"
67-
-D MODE=stderr
68-
-D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}_memcheck.match
69-
-P ${PROJECT_SOURCE_DIR}/cmake/match.cmake
70-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
71-
)
72-
73-
set_tests_properties(${test_name} PROPERTIES
74-
LABELS "adapter-specific;${name}"
75-
ENVIRONMENT "${args_ENVIRONMENT}")
76-
endif()
77-
endfunction()
6+
add_custom_target(check-unified-runtime-adapter)
787

798
if(UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_ALL)
809
add_subdirectory(cuda)

unified-runtime/test/adapters/cuda/CMakeLists.txt

+20-21
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,31 @@ if(NOT UR_FOUND_DPCXX)
99
return()
1010
endif()
1111

12-
add_adapter_test(cuda
13-
FIXTURE DEVICES
14-
SOURCES
15-
fixtures.h
16-
context_tests.cpp
17-
urContextGetNativeHandle.cpp
18-
urDeviceGetNativeHandle.cpp
19-
urDeviceCreateWithNativeHandle.cpp
20-
urEventGetNativeHandle.cpp
21-
urEventCreateWithNativeHandle.cpp
22-
urQueueGetNativeHandle.cpp
23-
kernel_tests.cpp
24-
memory_tests.cpp
25-
event_tests.cpp
26-
#FIXME: make this cleaner
27-
${CMAKE_CURRENT_SOURCE_DIR}/../../../source/adapters/cuda/queue.cpp
28-
${CMAKE_CURRENT_SOURCE_DIR}/../../../source/adapters/cuda/common.cpp
29-
ENVIRONMENT
30-
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_cuda>\""
12+
add_ur_lit_testsuite(cuda)
13+
add_dependencies(check-unified-runtime-adapter check-unified-runtime-cuda)
14+
15+
add_conformance_devices_test(adapter-cuda
16+
fixtures.h
17+
context_tests.cpp
18+
urContextGetNativeHandle.cpp
19+
urDeviceGetNativeHandle.cpp
20+
urDeviceCreateWithNativeHandle.cpp
21+
urEventGetNativeHandle.cpp
22+
urEventCreateWithNativeHandle.cpp
23+
urQueueGetNativeHandle.cpp
24+
kernel_tests.cpp
25+
memory_tests.cpp
26+
event_tests.cpp
27+
#FIXME: make this cleaner
28+
${CMAKE_CURRENT_SOURCE_DIR}/../../../source/adapters/cuda/queue.cpp
29+
${CMAKE_CURRENT_SOURCE_DIR}/../../../source/adapters/cuda/common.cpp
3130
)
3231

33-
target_include_directories(test-adapter-cuda PRIVATE
32+
target_include_directories(adapter-cuda-test PRIVATE
3433
${PROJECT_SOURCE_DIR}/source
3534
${PROJECT_SOURCE_DIR}/source/adapters/cuda
3635
)
3736

3837
find_package(CUDAToolkit 10.1 REQUIRED)
3938

40-
target_link_libraries(test-adapter-cuda PRIVATE cudadrv CUDA::nvml ${PROJECT_NAME}::umf)
39+
target_link_libraries(adapter-cuda-test PRIVATE cudadrv CUDA::nvml ${PROJECT_NAME}::umf)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Copyright (C) 2025 Intel Corporation
3+
4+
Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5+
See LICENSE.TXT
6+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
8+
"""
9+
10+
import lit.formats
11+
12+
config.name = "Unified Runtime Adapter (CUDA)"
13+
config.test_format = lit.formats.GoogleTest("", "-test")
14+
config.test_source_root = config.binary_dir
15+
config.test_exec_root = config.binary_dir
16+
17+
config.environment["ONEAPI_DEVICE_SELECTOR"] = "cuda:*"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@"
2+
3+
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")

unified-runtime/test/adapters/hip/CMakeLists.txt

+14-15
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,28 @@ if(NOT UR_FOUND_DPCXX)
99
return()
1010
endif()
1111

12-
add_adapter_test(hip
13-
FIXTURE KERNELS
14-
SOURCES
15-
fixtures.h
16-
urContextGetNativeHandle.cpp
17-
urDeviceGetNativeHandle.cpp
18-
urEventGetNativeHandle.cpp
19-
test_context.cpp
20-
test_event.cpp
21-
kernel_tests.cpp
22-
ENVIRONMENT
23-
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_hip>\""
12+
add_ur_lit_testsuite(hip)
13+
add_dependencies(check-unified-runtime-adapter check-unified-runtime-hip)
14+
15+
add_conformance_devices_test(adapter-hip
16+
fixtures.h
17+
urContextGetNativeHandle.cpp
18+
urDeviceGetNativeHandle.cpp
19+
urEventGetNativeHandle.cpp
20+
test_context.cpp
21+
test_event.cpp
22+
kernel_tests.cpp
2423
)
2524

26-
target_include_directories(test-adapter-hip PRIVATE
25+
target_include_directories(adapter-hip-test PRIVATE
2726
${PROJECT_SOURCE_DIR}/source
2827
${PROJECT_SOURCE_DIR}/source/adapters/hip
2928
)
3029

3130
get_target_property(HIP_COMPILE_DEFINITIONS
3231
ur_adapter_hip COMPILE_DEFINITIONS)
33-
target_compile_definitions(test-adapter-hip PRIVATE
32+
target_compile_definitions(adapter-hip-test PRIVATE
3433
${HIP_COMPILE_DEFINITIONS}
3534
)
3635

37-
target_link_libraries(test-adapter-hip PRIVATE rocmdrv ${PROJECT_NAME}::umf)
36+
target_link_libraries(adapter-hip-test PRIVATE rocmdrv ${PROJECT_NAME}::umf)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Copyright (C) 2025 Intel Corporation
3+
4+
Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5+
See LICENSE.TXT
6+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
8+
"""
9+
10+
import lit.formats
11+
12+
config.name = "Unified Runtime Adapter (HIP)"
13+
config.test_format = lit.formats.GoogleTest("", "-test")
14+
config.test_source_root = config.binary_dir
15+
config.test_exec_root = config.binary_dir
16+
17+
config.environment["ONEAPI_DEVICE_SELECTOR"] = "hip:*"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@"
2+
3+
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")

0 commit comments

Comments
 (0)