-
Notifications
You must be signed in to change notification settings - Fork 754
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
[SYCL][E2E] Add logic to react to REQUIRED
/UNSUPPORTED
in build-only
#16725
base: sycl
Are you sure you want to change the base?
Changes from all commits
123b4ac
cdd3aa1
0be2b74
5a2b31f
9a5f6c8
d95ce2f
a917988
184d9d9
d1f8409
cff4341
51c46b4
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
// using --offload-compress without zstd should throw an error. | ||
// REQUIRES: !zstd | ||
// REQUIRES: build-and-run-mode | ||
// RUN: not %{build} %O0 -g --offload-compress %S/Inputs/single_kernel.cpp -o %t_compress.out 2>&1 | FileCheck %s | ||
// CHECK: '--offload-compress' option is specified but zstd is not available. The device image will not be compressed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
from lit.BooleanExpression import BooleanExpression | ||
|
||
|
||
class E2EExpr(BooleanExpression): | ||
build_specific_features = { | ||
"build-and-run-mode", | ||
"target-spir", | ||
"target-nvidia", | ||
"target-amd", | ||
"target-native_cpu", | ||
"linux", | ||
"system-linux", | ||
"windows", | ||
"system-windows", | ||
"enable-perf-tests", | ||
"opencl_icd", | ||
"cuda_dev_kit", | ||
"zstd", | ||
"vulkan", | ||
"true", | ||
"false", | ||
} | ||
|
||
def __init__(self, string, variables, build_only_mode, findal_unknown_value): | ||
BooleanExpression.__init__(self, string, variables) | ||
self.build_only_mode = build_only_mode | ||
self.unknown = False | ||
self.findal_unknown_value = findal_unknown_value | ||
|
||
@staticmethod | ||
def evaluate(string, variables, build_only_mode, final_unknown_value=True): | ||
""" | ||
string: Expression to evaluate | ||
variables: variables that evaluate to true | ||
build_only_mode: if true enables unknown values | ||
findal_unknown_value: findal boolean result if evaluation results in `unknown` | ||
""" | ||
try: | ||
parser = E2EExpr( | ||
string, set(variables), build_only_mode, final_unknown_value | ||
) | ||
return parser.parseAll() | ||
except ValueError as e: | ||
raise ValueError(str(e) + ("\nin expression: %r" % string)) | ||
|
||
def parseMATCH(self): | ||
token = self.token | ||
BooleanExpression.parseMATCH(self) | ||
if token not in self.build_specific_features and self.build_only_mode: | ||
self.unknown = True | ||
else: | ||
self.unknown = False | ||
|
||
def parseAND(self): | ||
self.parseNOT() | ||
while self.accept("&&"): | ||
left = self.value | ||
left_unknown = self.unknown | ||
self.parseNOT() | ||
right = self.value | ||
right_unknown = self.unknown | ||
self.value = left and right | ||
# Unknown if both are unknown or if one is true and the other is unknown | ||
self.unknown = ( | ||
(left_unknown and right_unknown) | ||
or (left_unknown and right) | ||
or (left and right_unknown) | ||
) | ||
|
||
def parseOR(self): | ||
self.parseAND() | ||
while self.accept("||"): | ||
left = self.value | ||
left_unknown = self.unknown | ||
self.parseAND() | ||
right = self.value | ||
right_unknown = self.unknown | ||
self.value = left or right | ||
# Unknown if both are unknown or if one is false and the other is unknown | ||
self.unknown = ( | ||
(left_unknown and right_unknown) | ||
or (left_unknown and not right) | ||
or (not left and right_unknown) | ||
) | ||
|
||
def parseAll(self): | ||
self.token = next(self.tokens) | ||
self.parseOR() | ||
self.expect(BooleanExpression.END) | ||
return self.findal_unknown_value if self.unknown else self.value | ||
|
||
|
||
import unittest | ||
|
||
|
||
class TestE2EExpr(unittest.TestCase): | ||
def test_basic(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to see this:
And now that I spelled it out, it can be even better (C++-like syntax, names to be improved):
Also, since we want these name improvements in the tests, we might as well want to propagate them all the way to the interfaces somehow. |
||
# Non build-only expressions should work the same | ||
self.assertTrue(E2EExpr.evaluate("linux", {"linux", "rt_feature"}, False)) | ||
self.assertTrue(E2EExpr.evaluate("rt_feature", {"linux", "rt_feature"}, False)) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"another_aspect && rt_feature", {"linux", "rt_feature"}, False | ||
) | ||
) | ||
# build-only expressions with no unknowns should work the same | ||
self.assertTrue( | ||
E2EExpr.evaluate("linux", {"linux"}, True, final_unknown_value=False) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"linux && windows", {"linux"}, True, final_unknown_value=True | ||
) | ||
) | ||
self.assertTrue( | ||
E2EExpr.evaluate( | ||
"!(windows || zstd)", {"linux"}, True, final_unknown_value=False | ||
) | ||
) | ||
# build-only expressions where unknown affects the resulting value | ||
self.assertTrue( | ||
E2EExpr.evaluate("rt_feature", {}, True, final_unknown_value=True) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate("rt_feature", {}, True, final_unknown_value=False) | ||
) | ||
self.assertTrue( | ||
E2EExpr.evaluate( | ||
"rt_feature", {"rt_feature"}, True, final_unknown_value=True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we assert/raise an error instead? |
||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"rt_feature", {"rt_feature"}, True, final_unknown_value=False | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate("!rt_feature", {}, True, final_unknown_value=False) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate("!!rt_feature", {}, True, final_unknown_value=False) | ||
) | ||
self.assertTrue( | ||
E2EExpr.evaluate( | ||
"windows || rt_feature", {"linux"}, True, final_unknown_value=True | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"windows || rt_feature", {"linux"}, True, final_unknown_value=False | ||
) | ||
) | ||
self.assertTrue( | ||
E2EExpr.evaluate( | ||
"linux && rt_feature", {"linux"}, True, final_unknown_value=True | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"linux && rt_feature", {"linux"}, True, final_unknown_value=False | ||
) | ||
) | ||
self.assertTrue( | ||
E2EExpr.evaluate( | ||
"linux && !(windows || rt_feature)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have hard time mapping that to a possible |
||
{"linux"}, | ||
True, | ||
final_unknown_value=True, | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"linux && !(windows || rt_feature)", | ||
{"linux"}, | ||
True, | ||
final_unknown_value=False, | ||
) | ||
) | ||
# build-only expressions where unknown does not affect the resulting value | ||
self.assertTrue( | ||
E2EExpr.evaluate( | ||
"linux || rt_feature", {"linux"}, True, final_unknown_value=True | ||
) | ||
) | ||
self.assertTrue( | ||
E2EExpr.evaluate( | ||
"linux || rt_feature", {"linux"}, True, final_unknown_value=False | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"windows && rt_feature", {"linux"}, True, final_unknown_value=True | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"windows && rt_feature", {"linux"}, True, final_unknown_value=False | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"linux && (windows && rt_feature)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change "windows" to something that can make sense in real world. Same in the next one. |
||
{"linux"}, | ||
True, | ||
final_unknown_value=True, | ||
) | ||
) | ||
self.assertFalse( | ||
E2EExpr.evaluate( | ||
"linux && (windows && rt_feature)", | ||
{"linux"}, | ||
True, | ||
final_unknown_value=False, | ||
) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
// REQUIRES: ocloc, any-device-is-level_zero, any-device-is-gpu, any-device-is-cpu | ||
// REQUIRES: build-and-run-mode | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device *" %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run-unfiltered-devices} not %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %{run-unfiltered-devices} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %{run-unfiltered-devices} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %{run-unfiltered-devices} %t.out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and everywhere below.