Skip to content

Commit 7dacbc8

Browse files
committed
[Benchmark] detect device in benchmarks
and adjust kernel execution time for SubmitKernel to ensure similar total execution time for BMG and PVC.
1 parent f7f049a commit 7dacbc8

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

devops/scripts/benchmarks/benches/compute.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,16 @@ def additional_metadata(self) -> dict[str, BenchmarkMetadata]:
121121
def benchmarks(self) -> list[Benchmark]:
122122
benches = []
123123

124+
# hand-picked value so that total execution time of the benchmark is
125+
# similar on all architectures
126+
long_kernel_exec_time = 200 if "bmg" in options.device_architecture else 20
127+
124128
for runtime in list(RUNTIMES):
125129
# Add SubmitKernel benchmarks using loops
126130
for in_order_queue in [0, 1]:
127131
for measure_completion in [0, 1]:
128132
for use_events in [0, 1]:
129-
for kernel_exec_time in [1, 20]:
133+
for kernel_exec_time in [1, long_kernel_exec_time]:
130134
benches.append(
131135
SubmitKernel(
132136
self,

devops/scripts/benchmarks/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,15 @@ def validate_and_parse_env_args(env_args):
652652

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

655+
try:
656+
options.device_architecture = get_device_architecture(additional_env_vars)
657+
except Exception as e:
658+
options.device_architecture = ""
659+
print(f"Warning: Failed to fetch device architecture: {e}")
660+
print("Defaulting to generic benchmark parameters.")
661+
662+
print(options.device_architecture)
663+
655664
main(
656665
args.benchmark_directory,
657666
additional_env_vars,

devops/scripts/benchmarks/utils/utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import shutil
99
import subprocess
10+
import re
1011

1112
import tarfile
1213
from options import options
@@ -174,3 +175,23 @@ def download(dir, url, file, untar=False, unzip=False, checksum=""):
174175
else:
175176
print(f"{data_file} exists, skipping...")
176177
return data_file
178+
179+
180+
def get_device_architecture(additional_env_vars):
181+
sycl_ls_output = run(
182+
["sycl-ls", "--verbose"], add_sycl=True, env_vars=additional_env_vars
183+
).stdout.decode()
184+
185+
architectures = set()
186+
for line in sycl_ls_output.splitlines():
187+
if re.match(r" *Architecture:", line):
188+
_, architecture = line.strip().split(":", 1)
189+
architectures.add(architecture.strip())
190+
191+
if len(architectures) != 1:
192+
raise ValueError(
193+
f"Expected exactly one device architecture, but found {len(architectures)}: {architectures}."
194+
"Set ONEAPI_DEVICE_SELECTOR=backend:device_id to specify a single device."
195+
)
196+
197+
return architectures.pop()

0 commit comments

Comments
 (0)