-
Notifications
You must be signed in to change notification settings - Fork 804
[SYCL][E2E] Add test to check REQUIRES #16019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sycl
Are you sure you want to change the base?
Changes from 1 commit
239a975
d76ffef
fc10f14
d8bdd59
d0f5fec
473f187
8160444
0976851
fb1f123
c448126
2cd280c
513c796
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This test checks that all "REQUIRES" strings contain the right feature names | ||
// If this test fails: | ||
// 1. there is some typo/non-existing feature request in the | ||
// modified test. | ||
// 2. ...or, there is some new feature. In this case please update the set of | ||
// features in check-correctness-of-requires.py | ||
// | ||
// RUN: grep -rI --include=*.cpp "REQUIRES: " %S/../../test-e2e | sed -E 's|.*/test-e2e/||' > %t | ||
|
||
// Using a python script as it's easier to work with sets there | ||
// RUN: python3 %S/check-correctness-of-requires.py %t %sycl_include |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# See check-correctness-of-requires.cpp | ||
|
||
import re | ||
import sys | ||
|
||
|
||
# To parse .def files to get aspects and architectures | ||
def parse_defines(path, macro, prefix): | ||
features = set() | ||
with open(path, "r") as file: | ||
for line in file: | ||
if line.startswith(macro): | ||
feature = line.split("(")[1].split(",")[0].strip() | ||
features.add(f"{prefix}-{feature}") | ||
return features | ||
|
||
|
||
def parse_requirements(input_data_path, sycl_include_dir_path): | ||
available_features = { | ||
|
||
# host OS: | ||
"windows", | ||
"linux", | ||
# target device: | ||
"cpu", | ||
"gpu", | ||
"accelerator", | ||
# target backend: | ||
"cuda", | ||
"hip", | ||
"opencl", | ||
"level_zero", | ||
"native_cpu", | ||
"hip_amd", | ||
# tools: | ||
"sycl-ls", | ||
"cm-compiler", | ||
"aot_tool", | ||
"ocloc", | ||
"opencl-aot", | ||
"llvm-spirv", | ||
"llvm-link", | ||
# dev-kits: | ||
"level_zero_dev_kit", | ||
"cuda_dev_kit", | ||
# manually-set features (deprecated, no new tests should use these features) | ||
"gpu-intel-gen11", | ||
"gpu-intel-gen12", | ||
"gpu-intel-dg1", | ||
"gpu-intel-dg2", | ||
"gpu-intel-pvc", | ||
"gpu-intel-pvc-vg", | ||
"gpu-amd-gfx90a", | ||
# any-device-is-: | ||
"any-device-is-cpu", | ||
"any-device-is-gpu", | ||
"any-device-is-accelerator", | ||
"any-device-is-cuda", | ||
"any-device-is-hip", | ||
"any-device-is-opencl", | ||
"any-device-is-level_zero", | ||
# sg-sizes (should we allow any sg-X?) | ||
"sg-8", | ||
"sg-16", | ||
"sg-32", | ||
# miscellaneous: | ||
"cl_options", | ||
"opencl_icd", | ||
"dump_ir", | ||
"xptifw", | ||
"has_ndebug", | ||
"zstd", | ||
"preview-breaking-changes-supported", | ||
"vulkan", | ||
# Note: aspects and architectures are gathered below | ||
} | ||
|
||
available_features.update( | ||
parse_defines( | ||
sycl_include_dir_path + "/sycl/info/aspects.def", "__SYCL_ASPECT", "aspect" | ||
) | ||
) | ||
available_features.update( | ||
parse_defines( | ||
sycl_include_dir_path + "/sycl/info/aspects_deprecated.def", | ||
"__SYCL_ASPECT", | ||
"aspect", | ||
) | ||
) | ||
available_features.update( | ||
parse_defines( | ||
sycl_include_dir_path + "/sycl/ext/oneapi/experimental/architectures.def", | ||
"__SYCL_ARCHITECTURE", | ||
"arch", | ||
) | ||
) | ||
|
||
exit_code = 0 | ||
with open(input_data_path, "r") as file: | ||
for line in file: | ||
# get the content of "REQUIRES: " | ||
requirements = re.compile(r"// REQUIRES: (.*)").search(line) | ||
# Drop all symbols except feature names | ||
requirements = re.split(r"&&|\|\||, |,|\(|\)|\s+", requirements.group(1)) | ||
# Filter out empty names | ||
requirements = [req.strip() for req in requirements if req.strip()] | ||
|
||
for feature in requirements: | ||
# some names can start with "!" e.g. "!level_zero", drop "!" | ||
feature = feature.lstrip("!") | ||
if not feature in available_features: | ||
exit_code = 1 | ||
print(line + "contains unsupported feature: " + feature) | ||
sys.exit(exit_code) | ||
|
||
|
||
parse_requirements(sys.argv[1], sys.argv[2]) |
Uh oh!
There was an error while loading. Please reload this page.