From f2e28cb7e8b9d6689b197a772bda6902ea79db20 Mon Sep 17 00:00:00 2001 From: "Garcia Orozco, David" Date: Fri, 11 Apr 2025 13:56:35 -0700 Subject: [PATCH 1/4] [SYCL][E2E] Check for run-time features when in build-only --- sycl/test-e2e/E2EExpr.py | 30 ++++++++++++++++++++++-------- sycl/test-e2e/lit.cfg.py | 9 +++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/sycl/test-e2e/E2EExpr.py b/sycl/test-e2e/E2EExpr.py index db929d3f08a7a..7e987ad971269 100644 --- a/sycl/test-e2e/E2EExpr.py +++ b/sycl/test-e2e/E2EExpr.py @@ -34,6 +34,11 @@ class E2EExpr(BooleanExpression): "hip_dev_kit", "zstd", "vulkan", + "host=None", + "target=None", + "shell", + "llvm-spirv", + "llvm-link", "true", "false", } @@ -63,14 +68,10 @@ def evaluate(string, variables, build_only_mode, final_unknown_value=True): def parseMATCH(self): token = self.token BooleanExpression.parseMATCH(self) - if token not in self.build_specific_features and self.build_only_mode: + if token not in E2EExpr.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() @@ -110,6 +111,18 @@ def parseAll(self): self.expect(BooleanExpression.END) return self.final_unknown_value if self.unknown else self.value + @staticmethod + def check_build_features(variables): + rt_features = [x for x in variables if x not in E2EExpr.build_specific_features] + if rt_features: + raise ValueError( + "Runtime features: " + + str(rt_features) + + " evaluated to True in build-only\n" + + "If this is a new build specific feature append it to:" + + "`build_specific_features` in `sycl/test-e2e/E2EExpr.py`" + ) + import unittest @@ -162,11 +175,12 @@ def test_basic(self): self.assertFalse( UnsupportedBuildEval("linux && (vulkan && rt_feature)", {"linux"}) ) - # runtime feature is present in build-only + # Check that no runtime features are present in build-only with self.assertRaises(ValueError): - RequiresBuildEval("rt_feature", {"rt_feature"}) + E2EExpr.check_build_features({"rt-feature"}) with self.assertRaises(ValueError): - UnsupportedBuildEval("rt_feature", {"rt_feature"}) + E2EExpr.check_build_features({"build-only", "rt-feature"}) + E2EExpr.check_build_features({"build-mode"}) if __name__ == "__main__": diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 5c8f5f7732e30..e39ffae2ff054 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -171,6 +171,7 @@ # Disable the UR logger callback sink during test runs as output to SYCL RT can interfere with some tests relying on standard input/output llvm_config.with_environment("UR_LOG_CALLBACK", "disabled") + # Temporarily modify environment to be the same that we use when running tests class test_env: def __enter__(self): @@ -254,6 +255,7 @@ def quote_path(path): return f'"{path}"' return shlex.quote(path) + # Call the function to perform the check and add the feature check_igc_tag_and_add_feature() @@ -273,6 +275,7 @@ def quote_path(path): if lit_config.params.get("spirv-backend", False): config.available_features.add("spirv-backend") + # Use this to make sure that any dynamic checks below are done in the build # directory and not where the sources are located. This is important for the # in-tree configuration (as opposite to the standalone one). @@ -1013,6 +1016,12 @@ def remove_level_zero_suffix(devices): clangxx += config.cxx_flags config.substitutions.append(("%clangxx", clangxx)) +# Check that no runtime features are available when in build-only +from E2EExpr import E2EExpr + +if config.test_mode == "build-only": + E2EExpr.check_build_features(config.available_features) + if lit_config.params.get("print_features", False): lit_config.note( "Global features: {}".format(" ".join(sorted(config.available_features))) From cf608a83c0f024d59f9eed09315c641a86a3b68c Mon Sep 17 00:00:00 2001 From: "Garcia Orozco, David" Date: Fri, 11 Apr 2025 16:34:24 -0700 Subject: [PATCH 2/4] Add non-root-user to build features list --- sycl/test-e2e/E2EExpr.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test-e2e/E2EExpr.py b/sycl/test-e2e/E2EExpr.py index 7e987ad971269..0af840cbe26b8 100644 --- a/sycl/test-e2e/E2EExpr.py +++ b/sycl/test-e2e/E2EExpr.py @@ -37,6 +37,7 @@ class E2EExpr(BooleanExpression): "host=None", "target=None", "shell", + "non-root-user", "llvm-spirv", "llvm-link", "true", From 186727dd4a0ac40af8961aa8229bc4a78689748b Mon Sep 17 00:00:00 2001 From: "Garcia Orozco, David" Date: Mon, 14 Apr 2025 12:48:10 -0700 Subject: [PATCH 3/4] Remove whitespace changes --- sycl/test-e2e/lit.cfg.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index b910a64b65631..41cb0bfda7d9b 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -171,7 +171,6 @@ # Disable the UR logger callback sink during test runs as output to SYCL RT can interfere with some tests relying on standard input/output llvm_config.with_environment("UR_LOG_CALLBACK", "disabled") - # Temporarily modify environment to be the same that we use when running tests class test_env: def __enter__(self): @@ -255,7 +254,6 @@ def quote_path(path): return f'"{path}"' return shlex.quote(path) - # Call the function to perform the check and add the feature check_igc_tag_and_add_feature() @@ -275,7 +273,6 @@ def quote_path(path): if lit_config.params.get("spirv-backend", False): config.available_features.add("spirv-backend") - # Use this to make sure that any dynamic checks below are done in the build # directory and not where the sources are located. This is important for the # in-tree configuration (as opposite to the standalone one). From 4365fa8aa32f3548ef1f1ce59386ec8b8cbd6441 Mon Sep 17 00:00:00 2001 From: "Garcia Orozco, David" Date: Wed, 21 May 2025 09:11:07 -0700 Subject: [PATCH 4/4] Add `ze_debug` to build-only features --- sycl/test-e2e/E2EExpr.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test-e2e/E2EExpr.py b/sycl/test-e2e/E2EExpr.py index eb4d757196ea4..dc1be96784d5b 100644 --- a/sycl/test-e2e/E2EExpr.py +++ b/sycl/test-e2e/E2EExpr.py @@ -45,6 +45,7 @@ class E2EExpr(BooleanExpression): "true", "false", "pdtracker", + "ze_debug", } def __init__(self, string, variables, build_only_mode, final_unknown_value):