Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sycl/test-e2e/AddressSanitizer/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion sycl/test-e2e/MemorySanitizer/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion sycl/test-e2e/ThreadSanitizer/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion sycl/test-e2e/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ... %{ ... %}).
Expand All @@ -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
Expand Down
32 changes: 30 additions & 2 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -948,6 +951,24 @@ 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

# 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)
Expand Down Expand Up @@ -1114,6 +1135,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")
Expand Down
Loading