Skip to content

Commit 9288866

Browse files
committed
fix lit to use arch and v2
1 parent 894db96 commit 9288866

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ unsupported_san_flags = [
3131
if any(flag in config.cxx_flags for flag in unsupported_san_flags):
3232
config.unsupported=True
3333

34-
config.environment["ZE_AFFINITY_MASK"] = "0"
34+
if config.ze_affinity_mask is not None:
35+
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ unsupported_san_flags = [
3939
if any(flag in config.cxx_flags for flag in unsupported_san_flags):
4040
config.unsupported=True
4141

42-
config.environment["ZE_AFFINITY_MASK"] = "0"
42+
if config.ze_affinity_mask is not None:
43+
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ unsupported_san_flags = [
3434
if any(flag in config.cxx_flags for flag in unsupported_san_flags):
3535
config.unsupported=True
3636

37-
config.environment["ZE_AFFINITY_MASK"] = "0"
37+
if config.ze_affinity_mask is not None:
38+
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask

sycl/test-e2e/format.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,14 @@ def get_extra_env(sycl_devices):
342342
elif "level_zero_v1" in full_dev_name:
343343
expanded += " env UR_LOADER_USE_LEVEL_ZERO_V2=0"
344344

345+
# If ZE_AFFINITY_MASK is set in local config, it filters devices so we should use :0
346+
device_selector = parsed_dev_name
347+
if test.config.ze_affinity_mask is not None:
348+
backend, _ = parsed_dev_name.split(":", 1)
349+
device_selector = f"{backend}:0"
350+
345351
expanded += " ONEAPI_DEVICE_SELECTOR={} {}".format(
346-
parsed_dev_name, test.config.run_launcher
352+
device_selector, test.config.run_launcher
347353
)
348354
cmd = directive.command.replace("%{run}", expanded)
349355
# Expand device-specific condtions (%if ... %{ ... %}).
@@ -353,6 +359,11 @@ def get_extra_env(sycl_devices):
353359
"linux",
354360
"windows",
355361
"preview-breaking-changes-supported",
362+
# the following entries are used by architecture-based filtering
363+
# (:arch- device, not :gpu or :cpu)
364+
"cpu",
365+
"gpu",
366+
"accelerator",
356367
]:
357368
if cond_features in test.config.available_features:
358369
conditions[cond_features] = True

sycl/test-e2e/lit.cfg.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"LIBCLANG_NOTHREADS",
9797
"LIBCLANG_RESOURCE_USAGE",
9898
"LIBCLANG_CODE_COMPLETION_LOGGING",
99+
"ZE_AFFINITY_MASK",
99100
]
100101

101102
# Names of the Release and Debug versions of the XPTIFW library
@@ -917,12 +918,14 @@ def get_sycl_ls_verbose(sycl_device, env):
917918

918919
env = copy.copy(llvm_config.config.environment)
919920

921+
backend_for_selector = backend.replace("_v2", "").replace("_v1", "")
922+
920923
# Find all available devices under the backend
921-
env["ONEAPI_DEVICE_SELECTOR"] = backend + ":*"
924+
env["ONEAPI_DEVICE_SELECTOR"] = backend_for_selector + ":*"
922925

923926
detected_architectures = []
924927

925-
platform_devices = remove_level_zero_suffix(backend + ":*")
928+
platform_devices = backend_for_selector + ":*"
926929

927930
for line in get_sycl_ls_verbose(platform_devices, env).stdout.splitlines():
928931
if re.match(r" *Architecture:", line):
@@ -948,6 +951,15 @@ def get_sycl_ls_verbose(sycl_device, env):
948951

949952
config.sycl_devices = filtered_sycl_devices
950953

954+
# Determine ZE_AFFINITY_MASK for Level Zero devices.
955+
# Sanitizer tests need to set ZE_AFFINITY_MASK to a single device index
956+
config.ze_affinity_mask = None
957+
for sycl_device in remove_level_zero_suffix(config.sycl_devices):
958+
be, dev = sycl_device.split(":")
959+
if be == "level_zero" and dev.isdigit():
960+
config.ze_affinity_mask = dev
961+
break
962+
951963
for sycl_device in remove_level_zero_suffix(config.sycl_devices):
952964
be, dev = sycl_device.split(":")
953965
config.available_features.add("any-device-is-" + dev)
@@ -1114,6 +1126,13 @@ def get_sycl_ls_verbose(sycl_device, env):
11141126
features.update(device_family)
11151127

11161128
be, dev = sycl_device.split(":")
1129+
if dev.isdigit():
1130+
backend_devices = available_devices.get(be, "gpu")
1131+
if isinstance(backend_devices, tuple):
1132+
# arch-selection is typically used to select gpu device
1133+
dev = "gpu"
1134+
else:
1135+
dev = backend_devices
11171136
features.add(dev.replace("fpga", "accelerator"))
11181137
if "level_zero_v2" in full_name:
11191138
features.add("level_zero_v2_adapter")

0 commit comments

Comments
 (0)