-
Notifications
You must be signed in to change notification settings - Fork 752
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
123b4ac
Add method to set triple + react to `REQUIRES` in build-only
ayylol cdd3aa1
Address comments related to new expressions
ayylol 0be2b74
Rename triples to build_target where appropriate
ayylol 5a2b31f
Address 2 more comments
ayylol 9a5f6c8
Re-add `REQUIRES: build-and-run-mode` for tests failing on run-only
ayylol d95ce2f
Add final_unknown_value as defaulted param in `getMatchedFromList`
ayylol a917988
Add test to run E2EExpr unit tests, and move unit tests to separate file
ayylol 184d9d9
Simplify code by using build_targets set throughout execute function
ayylol d1f8409
Add requires linux on E2EExpr tests
ayylol cff4341
Move E2EExpr unit tests back into E2EExpr.py
ayylol 51c46b4
Format changes
ayylol 6947371
Fix variable name typo
ayylol 74cab12
Rework how E2EExpr tests are called + add exception
ayylol ee5e8ff
Use helper functions when calling getMatchedFromList
ayylol 64bccab
Add more build-mode features
ayylol 9159957
Add `any-target-is-` features
ayylol 8f8b648
Add missing comma to build-only features list
ayylol 71ebbe7
Format
ayylol 87c0fa5
Merge branch 'sycl' into tristate-expr-logic
ayylol 3e75a1e
Revert changes in matrix, bindless_images and syclcompat tests
ayylol 737ab86
Revert changes to adapters tests
ayylol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
from lit.BooleanExpression import BooleanExpression | ||
|
||
|
||
class E2EExpr(BooleanExpression): | ||
build_specific_features = { | ||
"build-and-run-mode", | ||
"target-spir", | ||
"target-nvidia", | ||
"target-amd", | ||
"target-native_cpu", | ||
"any-target-is-spir", | ||
"any-target-is-nvidia", | ||
"any-target-is-amd", | ||
"any-target-is-native_cpu", | ||
"linux", | ||
"system-linux", | ||
"windows", | ||
"system-windows", | ||
"enable-perf-tests", | ||
"preview-breaking-changes-supported", | ||
"has_ndebug", | ||
"ocloc", | ||
"opencl-aot", | ||
"opencl_icd", | ||
"cm-compiler", | ||
"xptifw", | ||
"level_zero_dev_kit", | ||
"cuda_dev_kit", | ||
"zstd", | ||
"vulkan", | ||
"true", | ||
"false", | ||
} | ||
|
||
def __init__(self, string, variables, build_only_mode, final_unknown_value): | ||
BooleanExpression.__init__(self, string, variables) | ||
self.build_only_mode = build_only_mode | ||
self.unknown = False | ||
self.final_unknown_value = final_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 | ||
final_unknown_value: final 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 | ||
if self.value and self.unknown: | ||
raise ValueError("Runtime feature \"" + token +"\" evaluated to True in build-only") | ||
|
||
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.final_unknown_value if self.unknown else self.value | ||
|
||
|
||
import unittest | ||
|
||
|
||
class TestE2EExpr(unittest.TestCase): | ||
def test_basic(self): | ||
BuildOnly = True | ||
BuildAndRun = False | ||
RequiresDirective = True | ||
UnsupportedDirective = False | ||
RegularEval= lambda expr, features: E2EExpr.evaluate(expr, features, BuildAndRun) | ||
RequiresBuildEval = lambda expr, features: E2EExpr.evaluate(expr, features, BuildOnly, RequiresDirective) | ||
UnsupportedBuildEval = lambda expr, features: E2EExpr.evaluate(expr, features, BuildOnly, UnsupportedDirective) | ||
# Non build-only expressions should work the same | ||
self.assertTrue(RegularEval("linux", {"linux", "rt_feature"})) | ||
self.assertTrue(RegularEval("rt_feature", {"linux", "rt_feature"})) | ||
self.assertFalse(RegularEval("rt_feature1 && rt_feature2", {"linux", "rt_feature1"})) | ||
# build-only expressions with no unknowns should work the same | ||
self.assertTrue(UnsupportedBuildEval("linux", {"linux"})) | ||
self.assertFalse(RequiresBuildEval("linux && windows", {"linux"})) | ||
self.assertTrue(UnsupportedBuildEval("!(windows || zstd)", {"linux"})) | ||
# build-only expressions where unknown affects the resulting value | ||
self.assertTrue(RequiresBuildEval("rt_feature", {})) | ||
self.assertFalse(UnsupportedBuildEval("rt_feature", {})) | ||
self.assertFalse(UnsupportedBuildEval("!rt_feature", {})) | ||
self.assertTrue(RequiresBuildEval("windows || rt_feature", {"linux"})) | ||
self.assertFalse(UnsupportedBuildEval("windows || rt_feature", {"linux"})) | ||
self.assertTrue(RequiresBuildEval("linux && rt_feature", {"linux"})) | ||
self.assertFalse(UnsupportedBuildEval("linux && rt_feature", {"linux"})) | ||
self.assertTrue(RequiresBuildEval("linux && !(zstd || rt_feature)", {"linux"})) | ||
self.assertFalse(UnsupportedBuildEval("linux && !(zstd || rt_feature)", {"linux"})) | ||
# build-only expressions where unknown does not affect the resulting value | ||
self.assertTrue(RequiresBuildEval("linux || rt_feature", {"linux"})) | ||
self.assertTrue(UnsupportedBuildEval("linux || rt_feature", {"linux"})) | ||
self.assertFalse(RequiresBuildEval("windows && rt_feature", {"linux"})) | ||
self.assertFalse(UnsupportedBuildEval("windows && rt_feature", {"linux"})) | ||
self.assertFalse(RequiresBuildEval("linux && (vulkan && rt_feature)", {"linux"})) | ||
self.assertFalse(UnsupportedBuildEval("linux && (vulkan && rt_feature)", {"linux"})) | ||
# runtime feature is present in build-only | ||
with self.assertRaises(ValueError): | ||
RequiresBuildEval("rt_feature", {"rt_feature"}) | ||
with self.assertRaises(ValueError): | ||
UnsupportedBuildEval("rt_feature", {"rt_feature"}) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/EnqueueNativeCommand/custom-command-multiple-dev-cuda.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/HostInteropTask/interop-task-cuda-buffer-migrate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_amdgcn.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_nvptx64.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_several_targets.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64_fpga.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64_gen.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64_x86_64.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
sycl/test-e2e/bindless_images/examples/example_5_sample_cubemap.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
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.
I implemented something along these lines. lmk how it looks.
llvm/sycl/test-e2e/format.py
Lines 93 to 113 in 9159957
llvm/sycl/test-e2e/E2EExpr.py
Lines 111 to 117 in 9159957
I made the functions used in the unit tests separate from the ones used in format.py since these work on single expressions rather than lists of expressions.
Also I didn't add a XFAIL version of the build-only checks since I dont think we want to use it (since it allows us to cleanly separate xfails from compilation vs execution)