Skip to content

Commit f12ef02

Browse files
authored
[Benchmark] detect device in benchmarks (#19327)
and adjust kernel execution time for SubmitKernel to ensure similar total execution time for BMG and PVC. If there is more than one device on the platform, a warning is printed and the architecture is not set (which means be will default to some generic benchmark arguments). This can be extended in future - e.g. we could allow passing a specific architecture to scripts, similarly as llvm-lit supports `sycl_devices`.
1 parent 6cd1236 commit f12ef02

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

devops/scripts/benchmarks/benches/compute.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,22 @@ 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_lernel_exec_time_ioq = 20
127+
long_kernel_exec_time_ooo = 200 if "bmg" in options.device_architecture else 20
128+
124129
for runtime in list(RUNTIMES):
125130
# Add SubmitKernel benchmarks using loops
126131
for in_order_queue in [0, 1]:
127132
for measure_completion in [0, 1]:
128133
for use_events in [0, 1]:
129-
for kernel_exec_time in [1, 20]:
134+
long_kernel_exec_time = (
135+
long_lernel_exec_time_ioq
136+
if in_order_queue
137+
else long_kernel_exec_time_ooo
138+
)
139+
for kernel_exec_time in [1, long_kernel_exec_time]:
130140
benches.append(
131141
SubmitKernel(
132142
self,

devops/scripts/benchmarks/main.py

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

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

694+
try:
695+
options.device_architecture = get_device_architecture(additional_env_vars)
696+
except Exception as e:
697+
options.device_architecture = ""
698+
log.warning(f"Failed to fetch device architecture: {e}")
699+
log.warning("Defaulting to generic benchmark parameters.")
700+
701+
log.info(f"Selected device architecture: {options.device_architecture}")
702+
694703
main(
695704
args.benchmark_directory,
696705
additional_env_vars,

devops/scripts/benchmarks/utils/utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import os
88
import shutil
99
import subprocess
10+
import re
11+
1012
import tarfile
1113
import hashlib
1214
from pathlib import Path
@@ -175,3 +177,23 @@ def download(dir, url, file, untar=False, unzip=False, checksum=""):
175177
else:
176178
log.debug(f"{data_file} exists, skipping...")
177179
return data_file
180+
181+
182+
def get_device_architecture(additional_env_vars):
183+
sycl_ls_output = run(
184+
["sycl-ls", "--verbose"], add_sycl=True, env_vars=additional_env_vars
185+
).stdout.decode()
186+
187+
architectures = set()
188+
for line in sycl_ls_output.splitlines():
189+
if re.match(r" *Architecture:", line):
190+
_, architecture = line.strip().split(":", 1)
191+
architectures.add(architecture.strip())
192+
193+
if len(architectures) != 1:
194+
raise ValueError(
195+
f"Expected exactly one device architecture, but found {len(architectures)}: {architectures}."
196+
"Set ONEAPI_DEVICE_SELECTOR=backend:device_id to specify a single device."
197+
)
198+
199+
return architectures.pop()

devops/scripts/benchmarks/utils/validate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import re
22

3+
34
class Validate:
45
"""Static class containing methods for validating various fields"""
56

0 commit comments

Comments
 (0)