Skip to content

Commit 239a975

Browse files
committed
[SYCL][E2E] Add test to check REQUIRES
This test checks the content of every "REQUIRES" to avoid typos and non-existing requirements. This PR also updates some tests requirements found during test development.
1 parent aebfdc0 commit 239a975

File tree

7 files changed

+131
-6
lines changed

7 files changed

+131
-6
lines changed

sycl/test-e2e/Basic/fpga_tests/fpga_aocx_win.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// REQUIRES: opencl-aot, accelerator
10-
// REQUIRES: system-windows
9+
// REQUIRES: opencl-aot, accelerator, windows
1110

1211
/// E2E test for AOCX creation/use/run for FPGA
1312
// Produce an archive with device (AOCX) image. To avoid appending objects to

sycl/test-e2e/Plugin/sycl-ls-gpu-default-level-zero.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// REQUIRES: gpu, level-zero
1+
// REQUIRES: gpu, level_zero
22

33
// TODO: Remove unsetting SYCL_DEVICE_FILTER when feature is dropped
44
// RUN: env --unset=SYCL_DEVICE_FILTER --unset=ONEAPI_DEVICE_SELECTOR sycl-ls --verbose >%t.default.out

sycl/test-e2e/Regression/msvc_crt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %{run} %t1.exe
33
// RUN: %{build} /MDd -o %t2.exe
44
// RUN: %{run} %t2.exe
5-
// REQUIRES: system-windows, cl_options
5+
// REQUIRES: windows, cl_options
66
//==-------------- msvc_crt.cpp - SYCL MSVC CRT test -----------------------==//
77
//
88
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// (because only SPIR-V supports specialization constants natively)
44

55
// FIXME: This set is never satisfied all at once in our infrastructure.
6-
// REQUIRES: opencl, level-zero, cpu, gpu, opencl-aot, ocloc
6+
// REQUIRES: opencl, level_zero, cpu, gpu, opencl-aot, ocloc
77

88
// RUN: %clangxx -fsycl -DJIT %s -o %t.out
99
// RUN: %{run} %t.out
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This test checks that all "REQUIRES" strings contain the right feature names
2+
// If this test fails:
3+
// 1. there is some typo/non-existing feature request in the
4+
// modified test.
5+
// 2. ...or, there is some new feature. In this case please update the set of
6+
// features in check-correctness-of-requires.py
7+
//
8+
// RUN: grep -rI --include=*.cpp "REQUIRES: " %S/../../test-e2e | sed -E 's|.*/test-e2e/||' > %t
9+
// Using a python script as it's easier to work with sets there
10+
// RUN: python3 %S/check-correctness-of-requires.py %t %sycl_include
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# See check-correctness-of-requires.cpp
2+
3+
import re
4+
import sys
5+
6+
7+
# To parse .def files to get aspects and architectures
8+
def parse_defines(path, macro, prefix):
9+
features = set()
10+
with open(path, "r") as file:
11+
for line in file:
12+
if line.startswith(macro):
13+
feature = line.split("(")[1].split(",")[0].strip()
14+
features.add(f"{prefix}-{feature}")
15+
return features
16+
17+
18+
def parse_requirements(input_data_path, sycl_include_dir_path):
19+
available_features = {
20+
# host OS:
21+
"windows",
22+
"linux",
23+
# target device:
24+
"cpu",
25+
"gpu",
26+
"accelerator",
27+
# target backend:
28+
"cuda",
29+
"hip",
30+
"opencl",
31+
"level_zero",
32+
"native_cpu",
33+
"hip_amd",
34+
# tools:
35+
"sycl-ls",
36+
"cm-compiler",
37+
"aot_tool",
38+
"ocloc",
39+
"opencl-aot",
40+
"llvm-spirv",
41+
"llvm-link",
42+
# dev-kits:
43+
"level_zero_dev_kit",
44+
"cuda_dev_kit",
45+
# manually-set features (deprecated, no new tests should use these features)
46+
"gpu-intel-gen11",
47+
"gpu-intel-gen12",
48+
"gpu-intel-dg1",
49+
"gpu-intel-dg2",
50+
"gpu-intel-pvc",
51+
"gpu-intel-pvc-vg",
52+
"gpu-amd-gfx90a",
53+
# any-device-is-:
54+
"any-device-is-cpu",
55+
"any-device-is-gpu",
56+
"any-device-is-accelerator",
57+
"any-device-is-cuda",
58+
"any-device-is-hip",
59+
"any-device-is-opencl",
60+
"any-device-is-level_zero",
61+
# sg-sizes (should we allow any sg-X?)
62+
"sg-8",
63+
"sg-16",
64+
"sg-32",
65+
# miscellaneous:
66+
"cl_options",
67+
"opencl_icd",
68+
"dump_ir",
69+
"xptifw",
70+
"has_ndebug",
71+
"zstd",
72+
"preview-breaking-changes-supported",
73+
"vulkan",
74+
# Note: aspects and architectures are gathered below
75+
}
76+
77+
available_features.update(
78+
parse_defines(
79+
sycl_include_dir_path + "/sycl/info/aspects.def", "__SYCL_ASPECT", "aspect"
80+
)
81+
)
82+
available_features.update(
83+
parse_defines(
84+
sycl_include_dir_path + "/sycl/info/aspects_deprecated.def",
85+
"__SYCL_ASPECT",
86+
"aspect",
87+
)
88+
)
89+
available_features.update(
90+
parse_defines(
91+
sycl_include_dir_path + "/sycl/ext/oneapi/experimental/architectures.def",
92+
"__SYCL_ARCHITECTURE",
93+
"arch",
94+
)
95+
)
96+
97+
exit_code = 0
98+
with open(input_data_path, "r") as file:
99+
for line in file:
100+
# get the content of "REQUIRES: "
101+
requirements = re.compile(r"// REQUIRES: (.*)").search(line)
102+
# Drop all symbols except feature names
103+
requirements = re.split(r"&&|\|\||, |,|\(|\)|\s+", requirements.group(1))
104+
# Filter out empty names
105+
requirements = [req.strip() for req in requirements if req.strip()]
106+
107+
for feature in requirements:
108+
# some names can start with "!" e.g. "!level_zero", drop "!"
109+
feature = feature.lstrip("!")
110+
if not feature in available_features:
111+
exit_code = 1
112+
print(line + "contains unsupported feature: " + feature)
113+
sys.exit(exit_code)
114+
115+
116+
parse_requirements(sys.argv[1], sys.argv[2])

sycl/test/regression/sycl-include-gnu17.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clangxx -std=gnu++17 -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: %t.out
33

4-
// UNSUPPORTED: system-windows
4+
// UNSUPPORTED: windows
55

66
#include <iostream>
77
#include <sycl/sycl.hpp>

0 commit comments

Comments
 (0)