Skip to content

Commit df0392e

Browse files
committed
fix affinity mask in python scripts
1 parent 5742769 commit df0392e

File tree

6 files changed

+40
-13
lines changed

6 files changed

+40
-13
lines changed

devops/actions/run-tests/e2e/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ runs:
7878
continue-on-error: true
7979
shell: bash
8080
env:
81-
LIT_OPTS: -v --no-progress-bar --show-unsupported --show-pass --show-xfail --max-time 3600 --time-tests --param print_features=True --param test-mode=${{ inputs.testing_mode }} --param sycl_devices=${{ inputs.target_devices }} ${{ inputs.extra_lit_opts }}
82-
# LIT_OPTS: -j 12 -v --param "sycl_devices=level_zero_v2:arch-intel_gpu_mtl_u" sycl/test-e2e/
81+
LIT_OPTS: -v --no-progress-bar --show-unsupported --show-pass --show-xfail --max-time 3600 --time-tests --param print_features=True --param test-mode=${{ inputs.testing_mode }} --param sycl_devices=level_zero_v2:arch-intel_gpu_mtl_u ${{ inputs.extra_lit_opts }}
82+
LIT_OPTS: -j 12 -v --param "sycl_devices=level_zero_v2:arch-intel_gpu_mtl_u" sycl/test-e2e/
8383
run: |
8484
echo "LIT_OPTS: $LIT_OPTS"
8585
ninja -C build-e2e check-sycl-e2e > e2e.log 2>&1

sycl/test-e2e/AddressSanitizer/lit.local.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ if any(flag in config.cxx_flags for flag in unsupported_san_flags):
3333

3434
if config.ze_affinity_mask is not None:
3535
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask
36+
# When ZE_AFFINITY_MASK is set, it filters devices so the selected device becomes :0
37+
config.sycl_devices = [dev.replace(":"+config.ze_affinity_mask, ":0") if dev.startswith("level_zero") else dev
38+
for dev in config.sycl_devices]

sycl/test-e2e/MemorySanitizer/lit.local.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ if any(flag in config.cxx_flags for flag in unsupported_san_flags):
4141

4242
if config.ze_affinity_mask is not None:
4343
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask
44+
# When ZE_AFFINITY_MASK is set, it filters devices so the selected device becomes :0
45+
config.sycl_devices = [dev.replace(":"+config.ze_affinity_mask, ":0") if dev.startswith("level_zero") else dev
46+
for dev in config.sycl_devices]

sycl/test-e2e/ThreadSanitizer/lit.local.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ if any(flag in config.cxx_flags for flag in unsupported_san_flags):
3636

3737
if config.ze_affinity_mask is not None:
3838
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask
39+
# When ZE_AFFINITY_MASK is set, it filters devices so the selected device becomes :0
40+
config.sycl_devices = [dev.replace(":"+config.ze_affinity_mask, ":0") if dev.startswith("level_zero") else dev
41+
for dev in config.sycl_devices]

sycl/test-e2e/format.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ def get_extra_env(sycl_devices):
293293
"UR_L0_LEAKS_DEBUG={}".format(test.config.ur_l0_leaks_debug)
294294
)
295295

296+
# Add ZE_AFFINITY_MASK if it's set in config.environment (e.g., by sanitizer tests)
297+
if "ZE_AFFINITY_MASK" in test.config.environment:
298+
extra_env.append("ZE_AFFINITY_MASK={}".format(test.config.environment["ZE_AFFINITY_MASK"]))
299+
296300
if "cuda:gpu" in sycl_devices:
297301
extra_env.append("SYCL_UR_CUDA_ENABLE_IMAGE_SUPPORT=1")
298302

@@ -334,12 +338,6 @@ def get_extra_env(sycl_devices):
334338
expanded = "env"
335339

336340
extra_env = get_extra_env([parsed_dev_name])
337-
backend, device = parsed_dev_name.split(":", 1)
338-
device_selector = parsed_dev_name
339-
if backend == "level_zero" and device.isdigit():
340-
extra_env.append(f"ZE_AFFINITY_MASK={device}")
341-
device_selector = f"{backend}:0"
342-
343341
if extra_env:
344342
expanded += " {}".format(" ".join(extra_env))
345343

@@ -348,8 +346,14 @@ def get_extra_env(sycl_devices):
348346
elif "level_zero_v1" in full_dev_name:
349347
expanded += " env UR_LOADER_USE_LEVEL_ZERO_V2=0"
350348

349+
# If ZE_AFFINITY_MASK is set in local config, it filters devices so we should use :0
350+
device_selector = parsed_dev_name
351+
if test.config.ze_affinity_mask is not None:
352+
backend, _ = parsed_dev_name.split(":", 1)
353+
device_selector = f"{backend}:0"
354+
351355
expanded += " ONEAPI_DEVICE_SELECTOR={} {}".format(
352-
parsed_dev_name, test.config.run_launcher
356+
device_selector, test.config.run_launcher
353357
)
354358
cmd = directive.command.replace("%{run}", expanded)
355359
# Expand device-specific condtions (%if ... %{ ... %}).
@@ -359,6 +363,11 @@ def get_extra_env(sycl_devices):
359363
"linux",
360364
"windows",
361365
"preview-breaking-changes-supported",
366+
# the following entries are used by architecture-based filtering
367+
# (:arch- device, not :gpu or :cpu)
368+
"cpu",
369+
"gpu",
370+
"accelerator",
362371
]:
363372
if cond_features in test.config.available_features:
364373
conditions[cond_features] = True

sycl/test-e2e/lit.cfg.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def remove_level_zero_suffix(devices):
707707
available_devices = {
708708
"opencl": ("cpu", "gpu", "fpga"),
709709
"cuda": "gpu",
710-
"level_zero": ("gpu", "0", "1"),
710+
"level_zero": "gpu",
711711
"hip": "gpu",
712712
"native_cpu": "cpu",
713713
"offload": "gpu",
@@ -951,15 +951,25 @@ def get_sycl_ls_verbose(sycl_device, env):
951951

952952
config.sycl_devices = filtered_sycl_devices
953953

954-
# Determine ZE_AFFINITY_MASK for Level Zero devices.
955-
# Sanitizer tests need to set ZE_AFFINITY_MASK to a single device index
954+
# Determine ZE_AFFINITY_MASK value for Level Zero devices.
955+
# Sanitizer tests (via their lit.local.cfg) can use this to set ZE_AFFINITY_MASK
956+
# environment variable when needed. The main config does NOT set it in the environment.
956957
config.ze_affinity_mask = None
957958
for sycl_device in remove_level_zero_suffix(config.sycl_devices):
958959
be, dev = sycl_device.split(":")
959960
if be == "level_zero" and dev.isdigit():
960961
config.ze_affinity_mask = dev
961962
break
962963

964+
# If ze_affinity_mask wasn't determined from config.sycl_devices, check if
965+
# ONEAPI_DEVICE_SELECTOR is set in the environment and extract from there
966+
if config.ze_affinity_mask is None:
967+
oneapi_selector = os.environ.get("ONEAPI_DEVICE_SELECTOR", "")
968+
if oneapi_selector.startswith("level_zero:"):
969+
dev = oneapi_selector.split(":", 1)[1]
970+
if dev.isdigit():
971+
config.ze_affinity_mask = dev
972+
963973
for sycl_device in remove_level_zero_suffix(config.sycl_devices):
964974
be, dev = sycl_device.split(":")
965975
config.available_features.add("any-device-is-" + dev)
@@ -1124,7 +1134,6 @@ def get_sycl_ls_verbose(sycl_device, env):
11241134
features.update(sg_size_features)
11251135
features.update(architecture_feature)
11261136
features.update(device_family)
1127-
features.update(aspects)
11281137

11291138
be, dev = sycl_device.split(":")
11301139
if dev.isdigit():

0 commit comments

Comments
 (0)