Skip to content

Commit 44ed9b7

Browse files
authored
Revert "[UR] Move conformance tests over to lit" (#18382)
Reverts #17998
1 parent 309b0b2 commit 44ed9b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+548
-186
lines changed

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

+14-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
runner_name:
1414
required: true
1515
type: string
16+
platform:
17+
description: "Platform string, `UR_CTS_ADAPTER_PLATFORM` will be set to this."
18+
required: false
19+
type: string
20+
default: ""
1621
static_loader:
1722
required: false
1823
type: string
@@ -41,6 +46,11 @@ on:
4146
runner_name:
4247
required: true
4348
type: string
49+
platform:
50+
description: "Platform string, `UR_CTS_ADAPTER_PLATFORM` will be set to this."
51+
required: false
52+
type: string
53+
default: ""
4454
static_loader:
4555
required: false
4656
type: string
@@ -79,6 +89,7 @@ jobs:
7989
{
8090
name: "${{inputs.adapter_name}}",
8191
other_name: "${{inputs.other_adapter_name}}",
92+
platform: "${{inputs.platform}}",
8293
static_Loader: "${{inputs.static_loader}}",
8394
static_adapter: "${{inputs.static_loader}}"
8495
}
@@ -94,6 +105,7 @@ jobs:
94105
steps:
95106
# TODO:
96107
# - investigate if DUR_CONFORMANCE_AMD_ARCH could be removed
108+
# - find better way to handle platform param (e.g. "Intel(R) OpenCL" -> "opencl")
97109
# - switch to Ninja generator in CMake
98110
# - downloading DPC++ should be integrated somehow; most likely use nightly release.
99111
#
@@ -144,6 +156,7 @@ jobs:
144156
-DUR_DEVELOPER_MODE=ON
145157
-DUR_BUILD_TESTS=ON
146158
-DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON
159+
-DUR_CONFORMANCE_TEST_LOADER=${{ matrix.adapter.other_name != '' && 'ON' || 'OFF' }}
147160
${{ matrix.adapter.other_name != '' && format('-DUR_BUILD_ADAPTER_{0}=ON', matrix.adapter.other_name) || '' }}
148161
-DUR_STATIC_LOADER=${{matrix.adapter.static_Loader}}
149162
-DUR_STATIC_ADAPTER_${{matrix.adapter.name}}=${{matrix.adapter.static_adapter}}
@@ -171,8 +184,7 @@ jobs:
171184
- name: Test adapters
172185
env:
173186
ZE_ENABLE_LOADER_DEBUG_TRACE: 1
174-
LIT_OPTS: " --timeout 120"
175-
run: cmake --build build -j $(nproc) -- check-unified-runtime-conformance
187+
run: env UR_CTS_ADAPTER_PLATFORM="${{matrix.adapter.platform}}" ctest -C ${{matrix.build_type}} --test-dir build --output-on-failure -L "conformance" --timeout 600 -VV
176188

177189
- name: Get information about platform
178190
if: ${{ always() }}

.github/workflows/ur-precommit.yml

+2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ jobs:
7777
image_options: -u 1001 --privileged --cap-add SYS_ADMIN --gpus all
7878
- name: OPENCL
7979
runner: UR_OPENCL
80+
platform: "Intel(R) OpenCL"
8081
docker_image: "ghcr.io/intel/llvm/ubuntu2204_build:latest"
8182
image_options: -u 1001 --device=/dev/dri --device=/dev/kfd --privileged --cap-add SYS_ADMIN
8283
- name: OPENCL
8384
runner: UR_OPENCL
85+
platform: "OPENCL:Intel(R) OpenCL"
8486
other_adapter: NATIVE_CPU
8587
docker_image: "ghcr.io/intel/llvm/ubuntu2204_build:latest"
8688
image_options: -u 1001 --device=/dev/dri --device=/dev/kfd --privileged --cap-add SYS_ADMIN

unified-runtime/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ set(UR_SYCL_LIBRARY_DIR "" CACHE PATH
6565
set(UR_CONFORMANCE_TARGET_TRIPLES "" CACHE STRING
6666
"List of sycl targets to build CTS device binaries for")
6767
set(UR_CONFORMANCE_AMD_ARCH "" CACHE STRING "AMD device target ID to build CTS binaries for")
68-
set(UR_CONFORMANCE_SELECTOR "" CACHE STRING "If nonempty, the device selector for conformance tests")
68+
option(UR_CONFORMANCE_ENABLE_MATCH_FILES "Enable CTS match files" ON)
69+
option(UR_CONFORMANCE_TEST_LOADER "Also test the loader in the conformance tests" OFF)
6970
option(UR_USE_DEBUG_POSTFIX "Enable debug postfix 'd' for libraries" OFF)
7071
set(UR_ADAPTER_LEVEL_ZERO_SOURCE_DIR "" CACHE PATH
7172
"Path to external 'level_zero' adapter source dir")

unified-runtime/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ List of options provided by CMake:
128128
| UR_ENABLE_SANITIZER | Enable device sanitizer layer | ON/OFF | ON |
129129
| UR_CONFORMANCE_TARGET_TRIPLES | SYCL triples to build CTS device binaries for | Comma-separated list | spir64 |
130130
| UR_CONFORMANCE_AMD_ARCH | AMD device target ID to build CTS binaries for | string | `""` |
131-
| UR_CONFORMANCE_SELECTOR | `ONEAPI_DEVICE_SELECTOR` for conformance testing | string | All enabled adapters |
131+
| UR_CONFORMANCE_ENABLE_MATCH_FILES | Enable CTS match files | ON/OFF | ON |
132+
| UR_CONFORMANCE_TEST_LOADER | Additionally build and run "loader" tests for the CTS | ON/OFF | OFF |
132133
| UR_BUILD_ADAPTER_L0 | Build the Level-Zero adapter | ON/OFF | OFF |
133134
| UR_BUILD_ADAPTER_OPENCL | Build the OpenCL adapter | ON/OFF | OFF |
134135
| UR_BUILD_ADAPTER_CUDA | Build the CUDA adapter | ON/OFF | OFF |

unified-runtime/scripts/core/CONTRIB.rst

+5-12
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,14 @@ Conformance tests *must* not make assumptions about the adapter under test.
272272
Tests fixtures or cases *must* query for support of optional features and skip
273273
testing if unsupported by the adapter.
274274

275-
Conformance tests are ran as part of the main ``test`` target, but can also be
276-
executed using the `check-unified-runtime-conformance` target as follows:
275+
All tests in the Unified Runtime project are configured to use CTest to run.
276+
All conformance tests have the ``conformance`` label attached to them which
277+
allows them to be run independently. To run all the conformance tests, execute
278+
the following command from the build directory.
277279

278280
.. code-block:: console
279281
280-
cmake --build build --target check-unified-runtime-conformance
281-
282-
A specific device/adapter can be specified by using ``ONEAPI_DEVICE_SELECTOR``
283-
in the same way as in the `DPC++ compiler
284-
<https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md#oneapi_device_selector>`_.
285-
286-
A number of tests are skipped on certain adapters due to being known failures.
287-
To force all tests to run, including known failures,
288-
``UR_CTS_ALSO_RUN_KNOWN_FAILURES`` may be set to ``1`` as an environment
289-
variable.
282+
ctest -L "conformance"
290283
291284
Experimental Features
292285
=====================

unified-runtime/scripts/core/INTRO.rst

+18-4
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,26 @@ CTS Environment Variables
417417

418418
The following environment variables are used by the CTS runner and can be used to specify the platform that the test
419419
framework should run on. This can be used during development and testing to run CTS tests in case multiple platforms
420-
are available. Conformance tests will be skipped if there are no valid platforms.
420+
are available. If both filters are specified, then they both must match a platform for it to be selected. If there are
421+
no valid platforms, then the tests will fail. Command line arguments take priority over these variables.
421422

422-
.. envvar:: ONEAPI_DEVICE_SELECTOR
423+
.. envvar:: UR_CTS_ADAPTER_PLATFORM
423424

424-
If ``ONEAPI_DEVICE_SELECTOR`` is set in the environment, only devices
425-
matched by the selector will be tested.
425+
A specifier list in the form of `[(backend):](platform name)[;[(backend)]:(platform name)]...`. If a backend
426+
specific specifier is present in the list and the test is running for that backend, the device with the given name
427+
is chosen. Otherwise, it must match the name of the specifier from the list with no backend. Backend names are case-
428+
insensitive, however platform names must match exactly.
429+
430+
For example, if the test device has multiple platforms and you want to run tests on the "ABC Corp" backend when
431+
testing OpenCL and "XYZ Org" when testing level zero, you'd use `OPENCL:ABC Corp;LEVEL_ZERO:XYZ Org`. This form is
432+
useful when running the `build` target with a build with multiple backends.
433+
434+
For testing only one platform, the backend can be omitted. For example, just `ABC Corp` is sufficient if the tests
435+
are only going to be testing OpenCL.
436+
437+
.. envvar:: UR_CTS_BACKEND
438+
439+
A (case insensitive) backend to force the test to use. For example, `opencl`, `level_zero`, `hip` and so on.
426440

427441
.. envvar:: UR_CTS_ALSO_RUN_KNOWN_FAILURES
428442

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright (C) 2022 Intel Corporation
4+
#
5+
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
6+
# See LICENSE.TXT
7+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8+
9+
from subprocess import Popen, DEVNULL, PIPE
10+
import argparse
11+
import os
12+
import json
13+
14+
TMP_RESULTS_FILE = "tmp-results-file.json"
15+
16+
17+
def get_cts_test_suite_names(working_directory):
18+
process = Popen(
19+
["ctest", "--show-only=json-v1"],
20+
cwd=working_directory,
21+
stdout=PIPE,
22+
env=os.environ.copy(),
23+
)
24+
out, _ = process.communicate()
25+
testsuites = json.loads(out)
26+
return [test["name"][: test["name"].rfind("-")] for test in testsuites["tests"]]
27+
28+
29+
def percent(amount, total):
30+
return round((amount / (total or 1)) * 100, 2)
31+
32+
33+
def summarize_results(results):
34+
total = results["Total"]
35+
total_passed = len(results["Passed"])
36+
total_skipped = len(results["Skipped"])
37+
total_failed = len(results["Failed"])
38+
total_crashed = total - (total_passed + total_skipped + total_failed)
39+
40+
pass_rate_incl_skipped = percent(total_passed + total_skipped, total)
41+
pass_rate_excl_skipped = percent(total_passed, total)
42+
43+
skipped_rate = percent(total_skipped, total)
44+
failed_rate = percent(total_failed, total)
45+
crash_rate = percent(total_crashed, total)
46+
47+
ljust_param = len(str(total))
48+
49+
print(
50+
f"""[CTest Parser] Results:
51+
Total [{str(total).ljust(ljust_param)}]
52+
Passed [{str(total_passed).ljust(ljust_param)}] ({pass_rate_incl_skipped}%) - ({pass_rate_excl_skipped}% with skipped tests excluded)
53+
Skipped [{str(total_skipped).ljust(ljust_param)}] ({skipped_rate}%)
54+
Failed [{str(total_failed).ljust(ljust_param)}] ({failed_rate}%)
55+
Crashed [{str(total_crashed).ljust(ljust_param)}] ({crash_rate}%)
56+
"""
57+
)
58+
59+
60+
def parse_results(results):
61+
parsed_results = {
62+
"Passed": {},
63+
"Skipped": {},
64+
"Failed": {},
65+
"Crashed": {},
66+
"Total": 0,
67+
"Success": True,
68+
}
69+
for _, result in results.items():
70+
if result["actual"] is None:
71+
parsed_results["Success"] = False
72+
parsed_results["Total"] += result["expected"]["tests"]
73+
continue
74+
75+
parsed_results["Total"] += result["actual"]["tests"]
76+
for testsuite in result["actual"].get("testsuites"):
77+
for test in testsuite.get("testsuite"):
78+
test_name = f"{testsuite['name']}.{test['name']}"
79+
test_time = test["time"]
80+
if "failures" in test:
81+
parsed_results["Failed"][test_name] = {"time": test_time}
82+
elif test["result"] == "SKIPPED":
83+
parsed_results["Skipped"][test_name] = {"time": test_time}
84+
else:
85+
parsed_results["Passed"][test_name] = {"time": test_time}
86+
return parsed_results
87+
88+
89+
def run(args):
90+
results = {}
91+
92+
tmp_results_file = f"{args.ctest_path}/{TMP_RESULTS_FILE}"
93+
env = os.environ.copy()
94+
env["GTEST_OUTPUT"] = f"json:{tmp_results_file}"
95+
96+
test_suite_names = get_cts_test_suite_names(f"{args.ctest_path}/test/conformance/")
97+
98+
## try and list all the available tests
99+
for suite in test_suite_names:
100+
results[suite] = {}
101+
test_executable = f"{args.ctest_path}/bin/test-{suite}"
102+
process = Popen(
103+
[test_executable, "--gtest_list_tests"],
104+
env=env,
105+
stdout=DEVNULL if args.quiet else None,
106+
stderr=DEVNULL if args.quiet else None,
107+
)
108+
process.wait()
109+
try:
110+
with open(tmp_results_file, "r") as test_list:
111+
all_tests = json.load(test_list)
112+
results[suite]["expected"] = all_tests
113+
os.remove(tmp_results_file)
114+
except FileNotFoundError:
115+
print(f"Could not discover tests for {suite}")
116+
117+
for suite in test_suite_names:
118+
ctest_path = f"{args.ctest_path}/test/conformance/{suite}"
119+
process = Popen(
120+
["ctest", ctest_path],
121+
env=env,
122+
cwd=ctest_path,
123+
stdout=DEVNULL if args.quiet else None,
124+
stderr=DEVNULL if args.quiet else None,
125+
)
126+
process.wait()
127+
128+
try:
129+
with open(tmp_results_file, "r") as results_file:
130+
json_data = json.load(results_file)
131+
results[suite]["actual"] = json_data
132+
os.remove(tmp_results_file)
133+
except FileNotFoundError:
134+
results[suite]["actual"] = None
135+
print(
136+
"\033[91m"
137+
+ f"Conformance test suite '{suite}' : likely crashed!"
138+
+ "\033[0m"
139+
)
140+
141+
return results
142+
143+
144+
def dir_path(string):
145+
if os.path.isdir(string):
146+
return os.path.abspath(string)
147+
else:
148+
raise NotADirectoryError(string)
149+
150+
151+
def main():
152+
parser = argparse.ArgumentParser()
153+
parser.add_argument(
154+
"ctest_path",
155+
type=dir_path,
156+
nargs="?",
157+
default=".",
158+
help="Optional path to test directory containing "
159+
"CTestTestfile. Defaults to current directory.",
160+
)
161+
parser.add_argument(
162+
"-q", "--quiet", action="store_true", help="Output only failed tests."
163+
)
164+
args = parser.parse_args()
165+
166+
raw_results = run(args)
167+
parsed_results = parse_results(raw_results)
168+
summarize_results(parsed_results)
169+
170+
171+
if __name__ == "__main__":
172+
try:
173+
main()
174+
except KeyboardInterrupt:
175+
exit(130)

unified-runtime/source/adapters/level_zero/image.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
#include "loader/ze_loader.h"
2222

23-
namespace {
24-
25-
} // namespace
23+
namespace {} // namespace
2624

2725
namespace ur::level_zero {
2826

unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp

+6-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/test/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ configure_file(lit.site.cfg.py.in lit.site.cfg.py)
3131
add_custom_target(deps_check-unified-runtime)
3232
if(UR_STANDALONE_BUILD)
3333
add_custom_target(check-unified-runtime
34-
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -sv
34+
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -v
3535
DEPENDS deps_check-unified-runtime
36-
USES_TERMINAL
3736
)
3837
else()
3938
# Use the LLVM method to add the test suite - this also registers it under `check-all`
@@ -61,8 +60,7 @@ function(add_ur_lit_testsuite suite)
6160

6261
if(UR_STANDALONE_BUILD)
6362
add_custom_target(${TARGET}
64-
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -sv
65-
USES_TERMINAL
63+
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -v
6664
)
6765
else()
6866
add_lit_testsuite(${TARGET} "Running Unified Runtime ${suite} tests"

0 commit comments

Comments
 (0)