From 928886634102273ae52b909db54754b94b97567f Mon Sep 17 00:00:00 2001 From: "Mateusz P. Nowak" Date: Fri, 5 Dec 2025 09:01:18 +0000 Subject: [PATCH 1/4] fix lit to use arch and v2 --- sycl/test-e2e/AddressSanitizer/lit.local.cfg | 3 ++- sycl/test-e2e/MemorySanitizer/lit.local.cfg | 3 ++- sycl/test-e2e/ThreadSanitizer/lit.local.cfg | 3 ++- sycl/test-e2e/format.py | 13 ++++++++++- sycl/test-e2e/lit.cfg.py | 23 ++++++++++++++++++-- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/sycl/test-e2e/AddressSanitizer/lit.local.cfg b/sycl/test-e2e/AddressSanitizer/lit.local.cfg index 50308766f8292..7694aea414c55 100644 --- a/sycl/test-e2e/AddressSanitizer/lit.local.cfg +++ b/sycl/test-e2e/AddressSanitizer/lit.local.cfg @@ -31,4 +31,5 @@ unsupported_san_flags = [ if any(flag in config.cxx_flags for flag in unsupported_san_flags): config.unsupported=True -config.environment["ZE_AFFINITY_MASK"] = "0" +if config.ze_affinity_mask is not None: + config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask diff --git a/sycl/test-e2e/MemorySanitizer/lit.local.cfg b/sycl/test-e2e/MemorySanitizer/lit.local.cfg index a3cbd769b9d5c..18c7f7bd8f73f 100644 --- a/sycl/test-e2e/MemorySanitizer/lit.local.cfg +++ b/sycl/test-e2e/MemorySanitizer/lit.local.cfg @@ -39,4 +39,5 @@ unsupported_san_flags = [ if any(flag in config.cxx_flags for flag in unsupported_san_flags): config.unsupported=True -config.environment["ZE_AFFINITY_MASK"] = "0" +if config.ze_affinity_mask is not None: + config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask diff --git a/sycl/test-e2e/ThreadSanitizer/lit.local.cfg b/sycl/test-e2e/ThreadSanitizer/lit.local.cfg index c8234bc536a41..83db05b539f5b 100644 --- a/sycl/test-e2e/ThreadSanitizer/lit.local.cfg +++ b/sycl/test-e2e/ThreadSanitizer/lit.local.cfg @@ -34,4 +34,5 @@ unsupported_san_flags = [ if any(flag in config.cxx_flags for flag in unsupported_san_flags): config.unsupported=True -config.environment["ZE_AFFINITY_MASK"] = "0" +if config.ze_affinity_mask is not None: + config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask diff --git a/sycl/test-e2e/format.py b/sycl/test-e2e/format.py index b503108f937b1..a6c2a8faf7d10 100644 --- a/sycl/test-e2e/format.py +++ b/sycl/test-e2e/format.py @@ -342,8 +342,14 @@ def get_extra_env(sycl_devices): elif "level_zero_v1" in full_dev_name: expanded += " env UR_LOADER_USE_LEVEL_ZERO_V2=0" + # If ZE_AFFINITY_MASK is set in local config, it filters devices so we should use :0 + device_selector = parsed_dev_name + if test.config.ze_affinity_mask is not None: + backend, _ = parsed_dev_name.split(":", 1) + device_selector = f"{backend}:0" + expanded += " ONEAPI_DEVICE_SELECTOR={} {}".format( - parsed_dev_name, test.config.run_launcher + device_selector, test.config.run_launcher ) cmd = directive.command.replace("%{run}", expanded) # Expand device-specific condtions (%if ... %{ ... %}). @@ -353,6 +359,11 @@ def get_extra_env(sycl_devices): "linux", "windows", "preview-breaking-changes-supported", + # the following entries are used by architecture-based filtering + # (:arch- device, not :gpu or :cpu) + "cpu", + "gpu", + "accelerator", ]: if cond_features in test.config.available_features: conditions[cond_features] = True diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index d39cd7134e603..45b460f6527d0 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -96,6 +96,7 @@ "LIBCLANG_NOTHREADS", "LIBCLANG_RESOURCE_USAGE", "LIBCLANG_CODE_COMPLETION_LOGGING", + "ZE_AFFINITY_MASK", ] # Names of the Release and Debug versions of the XPTIFW library @@ -917,12 +918,14 @@ def get_sycl_ls_verbose(sycl_device, env): env = copy.copy(llvm_config.config.environment) + backend_for_selector = backend.replace("_v2", "").replace("_v1", "") + # Find all available devices under the backend - env["ONEAPI_DEVICE_SELECTOR"] = backend + ":*" + env["ONEAPI_DEVICE_SELECTOR"] = backend_for_selector + ":*" detected_architectures = [] - platform_devices = remove_level_zero_suffix(backend + ":*") + platform_devices = backend_for_selector + ":*" for line in get_sycl_ls_verbose(platform_devices, env).stdout.splitlines(): if re.match(r" *Architecture:", line): @@ -948,6 +951,15 @@ def get_sycl_ls_verbose(sycl_device, env): config.sycl_devices = filtered_sycl_devices +# Determine ZE_AFFINITY_MASK for Level Zero devices. +# Sanitizer tests need to set ZE_AFFINITY_MASK to a single device index +config.ze_affinity_mask = None +for sycl_device in remove_level_zero_suffix(config.sycl_devices): + be, dev = sycl_device.split(":") + if be == "level_zero" and dev.isdigit(): + config.ze_affinity_mask = dev + break + for sycl_device in remove_level_zero_suffix(config.sycl_devices): be, dev = sycl_device.split(":") config.available_features.add("any-device-is-" + dev) @@ -1114,6 +1126,13 @@ def get_sycl_ls_verbose(sycl_device, env): features.update(device_family) be, dev = sycl_device.split(":") + if dev.isdigit(): + backend_devices = available_devices.get(be, "gpu") + if isinstance(backend_devices, tuple): + # arch-selection is typically used to select gpu device + dev = "gpu" + else: + dev = backend_devices features.add(dev.replace("fpga", "accelerator")) if "level_zero_v2" in full_name: features.add("level_zero_v2_adapter") From a1f5651036d73ecf0a00ab223983986b226fbb01 Mon Sep 17 00:00:00 2001 From: "Mateusz P. Nowak" Date: Mon, 8 Dec 2025 08:29:31 +0000 Subject: [PATCH 2/4] fix affinity mask setting Signed-off-by: Mateusz P. Nowak --- sycl/test-e2e/lit.cfg.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 45b460f6527d0..be30d3b98b711 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -960,6 +960,15 @@ def get_sycl_ls_verbose(sycl_device, env): config.ze_affinity_mask = dev break +# If ze_affinity_mask wasn't determined from config.sycl_devices, check if +# ONEAPI_DEVICE_SELECTOR is set in the environment and extract from there +if config.ze_affinity_mask is None: + oneapi_selector = os.environ.get("ONEAPI_DEVICE_SELECTOR", "") + if oneapi_selector.startswith("level_zero:"): + dev = oneapi_selector.split(":", 1)[1] + if dev.isdigit(): + config.ze_affinity_mask = dev + for sycl_device in remove_level_zero_suffix(config.sycl_devices): be, dev = sycl_device.split(":") config.available_features.add("any-device-is-" + dev) From b20e3d30286a085ed02d09bb5a9b0d754a20d8a4 Mon Sep 17 00:00:00 2001 From: "Mateusz P. Nowak" Date: Tue, 9 Dec 2025 14:48:23 +0000 Subject: [PATCH 3/4] fix affinity mask setting Signed-off-by: Mateusz P. Nowak --- sycl/test-e2e/AddressSanitizer/lit.local.cfg | 6 +----- sycl/test-e2e/MemorySanitizer/lit.local.cfg | 6 +----- sycl/test-e2e/ThreadSanitizer/lit.local.cfg | 6 +----- sycl/test-e2e/format.py | 16 +--------------- sycl/test-e2e/lit.cfg.py | 20 -------------------- 5 files changed, 4 insertions(+), 50 deletions(-) diff --git a/sycl/test-e2e/AddressSanitizer/lit.local.cfg b/sycl/test-e2e/AddressSanitizer/lit.local.cfg index 7f317ba5827cf..50308766f8292 100644 --- a/sycl/test-e2e/AddressSanitizer/lit.local.cfg +++ b/sycl/test-e2e/AddressSanitizer/lit.local.cfg @@ -31,8 +31,4 @@ unsupported_san_flags = [ if any(flag in config.cxx_flags for flag in unsupported_san_flags): config.unsupported=True -if config.ze_affinity_mask is not None: - config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask - # When ZE_AFFINITY_MASK is set, it filters devices so the selected device becomes :0 - config.sycl_devices = [dev.replace(":"+config.ze_affinity_mask, ":0") if dev.startswith("level_zero") else dev - for dev in config.sycl_devices] +config.environment["ZE_AFFINITY_MASK"] = "0" diff --git a/sycl/test-e2e/MemorySanitizer/lit.local.cfg b/sycl/test-e2e/MemorySanitizer/lit.local.cfg index 45695d08a7e5b..a3cbd769b9d5c 100644 --- a/sycl/test-e2e/MemorySanitizer/lit.local.cfg +++ b/sycl/test-e2e/MemorySanitizer/lit.local.cfg @@ -39,8 +39,4 @@ unsupported_san_flags = [ if any(flag in config.cxx_flags for flag in unsupported_san_flags): config.unsupported=True -if config.ze_affinity_mask is not None: - config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask - # When ZE_AFFINITY_MASK is set, it filters devices so the selected device becomes :0 - config.sycl_devices = [dev.replace(":"+config.ze_affinity_mask, ":0") if dev.startswith("level_zero") else dev - for dev in config.sycl_devices] +config.environment["ZE_AFFINITY_MASK"] = "0" diff --git a/sycl/test-e2e/ThreadSanitizer/lit.local.cfg b/sycl/test-e2e/ThreadSanitizer/lit.local.cfg index 725714aae864f..c8234bc536a41 100644 --- a/sycl/test-e2e/ThreadSanitizer/lit.local.cfg +++ b/sycl/test-e2e/ThreadSanitizer/lit.local.cfg @@ -34,8 +34,4 @@ unsupported_san_flags = [ if any(flag in config.cxx_flags for flag in unsupported_san_flags): config.unsupported=True -if config.ze_affinity_mask is not None: - config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask - # When ZE_AFFINITY_MASK is set, it filters devices so the selected device becomes :0 - config.sycl_devices = [dev.replace(":"+config.ze_affinity_mask, ":0") if dev.startswith("level_zero") else dev - for dev in config.sycl_devices] +config.environment["ZE_AFFINITY_MASK"] = "0" diff --git a/sycl/test-e2e/format.py b/sycl/test-e2e/format.py index cf3d492e3caa7..e6f18efcf8066 100644 --- a/sycl/test-e2e/format.py +++ b/sycl/test-e2e/format.py @@ -293,14 +293,6 @@ def get_extra_env(sycl_devices): "UR_L0_LEAKS_DEBUG={}".format(test.config.ur_l0_leaks_debug) ) - # Add ZE_AFFINITY_MASK if it's set in config.environment (e.g., by sanitizer tests) - if "ZE_AFFINITY_MASK" in test.config.environment: - extra_env.append( - "ZE_AFFINITY_MASK={}".format( - test.config.environment["ZE_AFFINITY_MASK"] - ) - ) - if "cuda:gpu" in sycl_devices: extra_env.append("SYCL_UR_CUDA_ENABLE_IMAGE_SUPPORT=1") @@ -350,14 +342,8 @@ def get_extra_env(sycl_devices): elif "level_zero_v1" in full_dev_name: expanded += " env UR_LOADER_USE_LEVEL_ZERO_V2=0" - # If ZE_AFFINITY_MASK is set in local config, it filters devices so we should use :0 - device_selector = parsed_dev_name - if test.config.ze_affinity_mask is not None: - backend, _ = parsed_dev_name.split(":", 1) - device_selector = f"{backend}:0" - expanded += " ONEAPI_DEVICE_SELECTOR={} {}".format( - device_selector, test.config.run_launcher + parsed_dev_name, test.config.run_launcher ) cmd = directive.command.replace("%{run}", expanded) # Expand device-specific condtions (%if ... %{ ... %}). diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 0bdb4f02a5bbe..693388e62f473 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -96,7 +96,6 @@ "LIBCLANG_NOTHREADS", "LIBCLANG_RESOURCE_USAGE", "LIBCLANG_CODE_COMPLETION_LOGGING", - "ZE_AFFINITY_MASK", ] # Names of the Release and Debug versions of the XPTIFW library @@ -951,25 +950,6 @@ def get_sycl_ls_verbose(sycl_device, env): config.sycl_devices = filtered_sycl_devices -# Determine ZE_AFFINITY_MASK value for Level Zero devices. -# Sanitizer tests (via their lit.local.cfg) can use this to set ZE_AFFINITY_MASK -# environment variable when needed. The main config does NOT set it in the environment. -config.ze_affinity_mask = None -for sycl_device in remove_level_zero_suffix(config.sycl_devices): - be, dev = sycl_device.split(":") - if be == "level_zero" and dev.isdigit(): - config.ze_affinity_mask = dev - break - -# If ze_affinity_mask wasn't determined from config.sycl_devices, check if -# ONEAPI_DEVICE_SELECTOR is set in the environment and extract from there -if config.ze_affinity_mask is None: - oneapi_selector = os.environ.get("ONEAPI_DEVICE_SELECTOR", "") - if oneapi_selector.startswith("level_zero:"): - dev = oneapi_selector.split(":", 1)[1] - if dev.isdigit(): - config.ze_affinity_mask = dev - for sycl_device in remove_level_zero_suffix(config.sycl_devices): be, dev = sycl_device.split(":") config.available_features.add("any-device-is-" + dev) From dbf40c77e7a44faf91c0118cccc73f0888bcfe37 Mon Sep 17 00:00:00 2001 From: "Mateusz P. Nowak" Date: Wed, 10 Dec 2025 16:56:03 +0000 Subject: [PATCH 4/4] apply comments --- sycl/test-e2e/AddressSanitizer/lit.local.cfg | 2 ++ sycl/test-e2e/format.py | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sycl/test-e2e/AddressSanitizer/lit.local.cfg b/sycl/test-e2e/AddressSanitizer/lit.local.cfg index 50308766f8292..077354e2e749c 100644 --- a/sycl/test-e2e/AddressSanitizer/lit.local.cfg +++ b/sycl/test-e2e/AddressSanitizer/lit.local.cfg @@ -20,6 +20,8 @@ config.unsupported_features += ['spirv-backend'] # https://github.com/intel/llvm/issues/16920 config.unsupported_features += ['arch-intel_gpu_bmg_g21'] +config.unsupported_features += ['arch-intel_gpu_mtl_u'] + # https://github.com/intel/llvm/issues/20142 config.unsupported_features += ['target-native_cpu'] diff --git a/sycl/test-e2e/format.py b/sycl/test-e2e/format.py index e6f18efcf8066..27064a73f6482 100644 --- a/sycl/test-e2e/format.py +++ b/sycl/test-e2e/format.py @@ -353,11 +353,7 @@ def get_extra_env(sycl_devices): "linux", "windows", "preview-breaking-changes-supported", - # the following entries are used by architecture-based filtering - # (:arch- device, not :gpu or :cpu) - "cpu", "gpu", - "accelerator", ]: if cond_features in test.config.available_features: conditions[cond_features] = True