Skip to content
Open
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
5 changes: 4 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,7 @@ 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 hasattr(config, 'ze_affinity_mask') and config.ze_affinity_mask is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have

# 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

below, is hasattr check needed?

config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask
else:
config.environment["ZE_AFFINITY_MASK"] = "0"
Comment on lines +36 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is else really needed? IIUC, config.ze_affinity_mask would be set for L0 devices, and for CPU this env. variable is meaningless anyway.

5 changes: 4 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,7 @@ 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 hasattr(config, 'ze_affinity_mask') and config.ze_affinity_mask is not None:
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask
else:
config.environment["ZE_AFFINITY_MASK"] = "0"
5 changes: 4 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,7 @@ 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 hasattr(config, 'ze_affinity_mask') and config.ze_affinity_mask is not None:
config.environment["ZE_AFFINITY_MASK"] = config.ze_affinity_mask
else:
config.environment["ZE_AFFINITY_MASK"] = "0"
17 changes: 16 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, it filters devices so we should use :0
device_selector = parsed_dev_name
if "ZE_AFFINITY_MASK" in test.config.environment:
backend, _ = parsed_dev_name.split(":", 1)
device_selector = f"{backend}:0"
Comment on lines +354 to +358
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I recommend this way, having code trying to play nice with existing envvars seems bad


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 Down
20 changes: 15 additions & 5 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import shlex
import shutil

import lit.formats
import lit.util

Comment on lines -12 to -14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated.

from lit.llvm import llvm_config
from lit.llvm.subst import ToolSubst, FindTool

Expand Down Expand Up @@ -917,12 +914,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 +947,16 @@ 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():
if config.ze_affinity_mask is None:
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 @@ -1112,6 +1121,7 @@ def get_sycl_ls_verbose(sycl_device, env):
features.update(sg_size_features)
features.update(architecture_feature)
features.update(device_family)
features.update(aspects)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line? Isn't 1120 enough?


be, dev = sycl_device.split(":")
features.add(dev.replace("fpga", "accelerator"))
Expand Down
Loading