Skip to content
Merged
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
22 changes: 21 additions & 1 deletion sycl/test-e2e/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ def get_extra_env(sycl_devices):
# so that device might still be accessible to some of the tests yet
# we won't set the environment variable below for such scenario.
extra_env = []

# Include ZE_AFFINITY_MASK if set by lit.local.cfg (e.g., for sanitizer tests)
if "ZE_AFFINITY_MASK" in test.config.environment:
extra_env.append(
"ZE_AFFINITY_MASK={}".format(
test.config.environment["ZE_AFFINITY_MASK"]
)
)

if "level_zero:gpu" in sycl_devices and litConfig.params.get("ur_l0_debug"):
extra_env.append("UR_L0_DEBUG={}".format(test.config.ur_l0_debug))

Expand Down Expand Up @@ -342,8 +351,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 +368,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
30 changes: 28 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,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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -1146,6 +1165,13 @@ def get_sycl_ls_verbose(sycl_device, env):
else:
config.intel_driver_ver[full_name] = {}

# When running with a single device, merge device-specific features into global
# available_features so that %if conditionals work correctly, even if device is not :gpu or :cpu
if len(config.sycl_devices) == 1:
single_device = list(config.sycl_dev_features.keys())[0]
device_features = config.sycl_dev_features[single_device]
config.available_features.update(device_features)

if lit_config.params.get("compatibility_testing", "False") != "False":
config.substitutions.append(("%clangxx", " true "))
config.substitutions.append(("%clang", " true "))
Expand Down
Loading