Skip to content

[Benchmark] detect device in benchmarks #19327

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

Open
wants to merge 2 commits into
base: sycl
Choose a base branch
from
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
6 changes: 5 additions & 1 deletion devops/scripts/benchmarks/benches/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ def additional_metadata(self) -> dict[str, BenchmarkMetadata]:
def benchmarks(self) -> list[Benchmark]:
benches = []

# hand-picked value so that total execution time of the benchmark is
# similar on all architectures
long_kernel_exec_time = 200 if "bmg" in options.device_architecture else 20

for runtime in list(RUNTIMES):
# Add SubmitKernel benchmarks using loops
for in_order_queue in [0, 1]:
for measure_completion in [0, 1]:
for use_events in [0, 1]:
for kernel_exec_time in [1, 20]:
for kernel_exec_time in [1, long_kernel_exec_time]:
benches.append(
SubmitKernel(
self,
Expand Down
9 changes: 9 additions & 0 deletions devops/scripts/benchmarks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,15 @@ def validate_and_parse_env_args(env_args):

benchmark_filter = re.compile(args.filter) if args.filter else None

try:
options.device_architecture = get_device_architecture(additional_env_vars)
except Exception as e:
options.device_architecture = ""
print(f"Warning: Failed to fetch device architecture: {e}")
print("Defaulting to generic benchmark parameters.")

print(options.device_architecture)

main(
args.benchmark_directory,
additional_env_vars,
Expand Down
1 change: 1 addition & 0 deletions devops/scripts/benchmarks/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Options:
preset: str = "Full"
build_jobs: int = multiprocessing.cpu_count()
exit_on_failure: bool = False
device_architecture: str = ""

# Options intended for CI:
regression_threshold: float = 0.05
Expand Down
21 changes: 21 additions & 0 deletions devops/scripts/benchmarks/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import shutil
import subprocess
import re

import tarfile
from options import options
Expand Down Expand Up @@ -174,3 +175,23 @@ def download(dir, url, file, untar=False, unzip=False, checksum=""):
else:
print(f"{data_file} exists, skipping...")
return data_file


def get_device_architecture(additional_env_vars):
sycl_ls_output = run(
["sycl-ls", "--verbose"], add_sycl=True, env_vars=additional_env_vars
).stdout.decode()

architectures = set()
for line in sycl_ls_output.splitlines():
if re.match(r" *Architecture:", line):
_, architecture = line.strip().split(":", 1)
architectures.add(architecture.strip())

if len(architectures) != 1:
raise ValueError(
f"Expected exactly one device architecture, but found {len(architectures)}: {architectures}."
"Set ONEAPI_DEVICE_SELECTOR=backend:device_id to specify a single device."
)

return architectures.pop()