Skip to content

[SYCL][E2E] Add lit feature to check if multi-device emulation is supported #17700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: (level_zero || opencl) && linux && gpu
// REQUIRES: (level_zero || opencl) && linux && gpu && multi-device-emulation

// RUN: %{build} -o %t.out
// RUN: rm -rf %t/cache_dir
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/KernelCompiler/opencl_multi_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// REQUIRES: (opencl || level_zero) && ocloc
// REQUIRES: (opencl || level_zero) && ocloc && multi-device-emulation
// UNSUPPORTED: accelerator
// UNSUPPORTED-INTENDED: while accelerator is AoT only, this cannot run there.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: gpu && linux && (opencl || level_zero)
// REQUIRES: gpu && linux && (opencl || level_zero) && multi-device-emulation

// Test to check that we can create input kernel bundle and call build twice for
// overlapping set of devices and execute the kernel on each device.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: gpu && linux && (opencl || level_zero)
// REQUIRES: gpu && linux && (opencl || level_zero) && multi-device-emulation

// RUN: %{build} -o %t.out
// RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=3 %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: ocloc && gpu && linux && target-spir
// REQUIRES: ocloc && gpu && linux && target-spir && multi-device-emulation

// Test to check several use cases for multi-device kernel bundles.
// Test covers AOT and JIT cases. Kernel is using some math functions to enforce
Expand Down
34 changes: 34 additions & 0 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,37 @@ def remove_level_zero_suffix(devices):
# discovered already.
config.sycl_dev_features = {}


# Function to check if multi-device-emulation feature is available
def check_multi_device_emulation(device):
try:
with test_env():
cmd = "{} {}".format(config.run_launcher or "", sycl_ls)
mod_env = os.environ.copy()
mod_env["ONEAPI_DEVICE_SELECTOR"] = device
sp = subprocess.run(
cmd, env=mod_env, text=True, shell=True, capture_output=True
)
sp.check_returncode()
regular_device_count = sum(
1 for line in sp.stdout.splitlines() if line.startswith("[")
)
mod_env["NEOReadDebugKeys"] = "1"
mod_env["CreateMultipleRootDevices"] = str(regular_device_count * 2)
sp = subprocess.run(
cmd, env=mod_env, text=True, shell=True, capture_output=True
)
sp.check_returncode()
emulated_device_count = sum(
1 for line in sp.stdout.splitlines() if line.startswith("[")
)
if emulated_device_count == regular_device_count * 2:
return True
return False
except Exception as e:
return False


# Version of the driver for a given device. Empty for non-Intel devices.
config.intel_driver_ver = {}
for full_name, sycl_device in zip(
Expand Down Expand Up @@ -910,6 +941,9 @@ def remove_level_zero_suffix(devices):
# Add corresponding target feature
target = config.backend_to_target[be]
features.add(target)
if sycl_device == "opencl:gpu" or sycl_device == "level_zero:gpu":
if check_multi_device_emulation(sycl_device):
features.add("multi-device-emulation")

if be == "hip":
if not config.amd_arch:
Expand Down