-
Notifications
You must be signed in to change notification settings - Fork 790
[UR][Benchmarks] Support for Unitrace for all benchmarks #19320
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
base: sycl
Are you sure you want to change the base?
Changes from all commits
4d32fe5
72d8108
d653883
5834aa9
d8f6b2b
01c1c1a
be36447
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from options import options | ||
from utils.utils import download, run | ||
from abc import ABC, abstractmethod | ||
import utils.unitrace as unitrace | ||
|
||
benchmark_tags = [ | ||
BenchmarkTag("SYCL", "Benchmark uses SYCL runtime"), | ||
|
@@ -70,7 +71,7 @@ def teardown(self): | |
pass | ||
|
||
@abstractmethod | ||
def run(self, env_vars) -> list[Result]: | ||
def run(self, env_vars, unitrace_timestamp: str = None) -> list[Result]: | ||
pass | ||
|
||
@staticmethod | ||
|
@@ -86,7 +87,14 @@ def get_adapter_full_path(): | |
), f"could not find adapter file {adapter_path} (and in similar lib paths)" | ||
|
||
def run_bench( | ||
self, command, env_vars, ld_library=[], add_sycl=True, use_stdout=True | ||
self, | ||
command, | ||
env_vars, | ||
ld_library=[], | ||
add_sycl=True, | ||
use_stdout=True, | ||
unitrace_timestamp: str = None, | ||
extra_unitrace_opt=[], | ||
): | ||
env_vars = env_vars.copy() | ||
if options.ur is not None: | ||
|
@@ -99,13 +107,28 @@ def run_bench( | |
ld_libraries = options.extra_ld_libraries.copy() | ||
ld_libraries.extend(ld_library) | ||
|
||
result = run( | ||
command=command, | ||
env_vars=env_vars, | ||
add_sycl=add_sycl, | ||
cwd=options.benchmark_cwd, | ||
ld_library=ld_libraries, | ||
) | ||
if unitrace_timestamp is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unintuitive that passing a unitrace timestamp triggers unitracing. Please, consider making a unitrace class and passing a |
||
bench_dir, unitrace_output, command = unitrace.unitrace_prepare( | ||
self.name(), unitrace_timestamp, command, extra_unitrace_opt | ||
) | ||
|
||
try: | ||
result = run( | ||
command=command, | ||
env_vars=env_vars, | ||
add_sycl=add_sycl, | ||
cwd=options.benchmark_cwd, | ||
ld_library=ld_libraries, | ||
) | ||
except subprocess.CalledProcessError as e: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if unitrace_timestamp is not None: | ||
unitrace.unitrace_cleanup(options.benchmark_cwd, unitrace_output) | ||
raise | ||
|
||
if unitrace_timestamp is not None: | ||
unitrace.handle_unitrace_output( | ||
bench_dir, unitrace_output, unitrace_timestamp | ||
) | ||
|
||
if use_stdout: | ||
return result.stdout.decode() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
from utils.utils import git_clone, run, create_build_path | ||
from utils.result import Result | ||
from utils.oneapi import get_oneapi | ||
from .benchdnn_list import get_bench_dnn_list | ||
from .benchdnn_list import get_bench_dnn_list, unitrace_exclusion_list | ||
|
||
|
||
class OneDnnBench(Suite): | ||
|
@@ -129,7 +129,7 @@ def setup(self): | |
if not self.bench_bin.exists(): | ||
raise FileNotFoundError(f"Benchmark binary not found: {self.bench_bin}") | ||
|
||
def run(self, env_vars): | ||
def run(self, env_vars, unitrace_timestamp: str = None) -> list[Result]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add a dict type as a type hint to |
||
command = [ | ||
str(self.bench_bin), | ||
*self.bench_args.split(), | ||
|
@@ -142,12 +142,21 @@ def run(self, env_vars): | |
env_vars = dict(env_vars) if env_vars else {} | ||
env_vars["ONEAPI_DEVICE_SELECTOR"] = "level_zero:*" | ||
|
||
if self.name() in unitrace_exclusion_list: | ||
if options.verbose: | ||
print( | ||
f"[{self.name()}] Skipping benchmark due to unitrace exclusion list." | ||
) | ||
unitrace_timestamp = None | ||
|
||
output = self.run_bench( | ||
command, | ||
env_vars, | ||
add_sycl=True, | ||
ld_library=ld_library, | ||
use_stdout=True, | ||
unitrace_timestamp=unitrace_timestamp, | ||
extra_unitrace_opt=["--chrome-dnn-logging"], | ||
) | ||
result_value = self._extract_time(output) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,6 +224,71 @@ def parse_unit_type(compute_unit): | |
|
||
|
||
class ComputeBenchmark(Benchmark): | ||
|
||
# list of benchmarks to exclude from unitrace due to SIGSEGV, SIGABRT or timeouts | ||
unitrace_exclusion_list = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should just let things fail. If unitrace is failing, it's an urgent bug that needs to be fixed. |
||
"api_overhead_benchmark_l0 SubmitKernel in order not using events KernelExecTime=20", | ||
"api_overhead_benchmark_l0 SubmitKernel in order not using events", | ||
"api_overhead_benchmark_l0 SubmitKernel in order with measure completion not using events KernelExecTime=20", | ||
"api_overhead_benchmark_l0 SubmitKernel in order with measure completion not using events", | ||
"api_overhead_benchmark_sycl SubmitKernel in order not using events KernelExecTime=20", | ||
"api_overhead_benchmark_sycl SubmitKernel in order not using events", | ||
"api_overhead_benchmark_sycl SubmitKernel in order with measure completion not using events KernelExecTime=20", | ||
"api_overhead_benchmark_sycl SubmitKernel in order with measure completion not using events", | ||
"api_overhead_benchmark_syclpreview SubmitKernel in order not using events KernelExecTime=20", | ||
"api_overhead_benchmark_syclpreview SubmitKernel in order not using events", | ||
"api_overhead_benchmark_syclpreview SubmitKernel in order with measure completion not using events KernelExecTime=20", | ||
"api_overhead_benchmark_syclpreview SubmitKernel in order with measure completion not using events", | ||
"api_overhead_benchmark_ur SubmitKernel in order not using events KernelExecTime=20", | ||
"api_overhead_benchmark_ur SubmitKernel in order not using events", | ||
"api_overhead_benchmark_ur SubmitKernel in order with measure completion not using events KernelExecTime=20", | ||
"api_overhead_benchmark_ur SubmitKernel in order with measure completion not using events", | ||
"api_overhead_benchmark_ur SubmitKernel out of order not using events KernelExecTime=20", | ||
"api_overhead_benchmark_ur SubmitKernel out of order not using events", | ||
"api_overhead_benchmark_ur SubmitKernel out of order with measure completion not using events KernelExecTime=20", | ||
"api_overhead_benchmark_ur SubmitKernel out of order with measure completion not using events", | ||
"graph_api_benchmark_l0 SinKernelGraph graphs:0, numKernels:5", | ||
"graph_api_benchmark_l0 SinKernelGraph graphs:0, numKernels:100", | ||
"graph_api_benchmark_l0 SinKernelGraph graphs:1, numKernels:5", | ||
"graph_api_benchmark_l0 SinKernelGraph graphs:1, numKernels:100", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:10 ioq 0 measureCompletion 0", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:10 ioq 0 measureCompletion 1", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:10 ioq 1 measureCompletion 0", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:10 ioq 1 measureCompletion 1", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:32 ioq 0 measureCompletion 0", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:32 ioq 0 measureCompletion 1", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:32 ioq 1 measureCompletion 0", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:32 ioq 1 measureCompletion 1", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:4 ioq 0 measureCompletion 0", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:4 ioq 0 measureCompletion 1", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:4 ioq 1 measureCompletion 0", | ||
"graph_api_benchmark_l0 SubmitGraph numKernels:4 ioq 1 measureCompletion 1", | ||
"graph_api_benchmark_sycl FinalizeGraph rebuildGraphEveryIter:0 graphStructure:Gromacs", | ||
"graph_api_benchmark_sycl FinalizeGraph rebuildGraphEveryIter:0 graphStructure:Llama", | ||
"graph_api_benchmark_sycl FinalizeGraph rebuildGraphEveryIter:1 graphStructure:Gromacs", | ||
"graph_api_benchmark_sycl FinalizeGraph rebuildGraphEveryIter:1 graphStructure:Llama", | ||
"graph_api_benchmark_ur SinKernelGraph graphs:0, numKernels:100", | ||
"graph_api_benchmark_ur SinKernelGraph graphs:0, numKernels:5", | ||
"graph_api_benchmark_ur SinKernelGraph graphs:1, numKernels:100", | ||
"graph_api_benchmark_ur SinKernelGraph graphs:1, numKernels:5", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:4 ioq 1 measureCompletion 0", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:4 ioq 1 measureCompletion 1", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:10 ioq 0 measureCompletion 0", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:10 ioq 0 measureCompletion 1", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:32 ioq 0 measureCompletion 0", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:32 ioq 0 measureCompletion 1", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:32 ioq 1 measureCompletion 0", | ||
"graph_api_benchmark_ur SubmitGraph numKernels:32 ioq 1 measureCompletion 1", | ||
"multithread_benchmark_ur MemcpyExecute opsPerThread:400, numThreads:1, allocSize:102400 srcUSM:1 dstUSM:1", | ||
"multithread_benchmark_ur MemcpyExecute opsPerThread:400, numThreads:1, allocSize:102400 srcUSM:0 dstUSM:1", | ||
"multithread_benchmark_ur MemcpyExecute opsPerThread:100, numThreads:4, allocSize:102400 srcUSM:1 dstUSM:1 without events", | ||
"multithread_benchmark_ur MemcpyExecute opsPerThread:100, numThreads:4, allocSize:102400 srcUSM:1 dstUSM:1 without events without copy offload", | ||
"multithread_benchmark_ur MemcpyExecute opsPerThread:4096, numThreads:4, allocSize:1024 srcUSM:0 dstUSM:1 without events", | ||
"multithread_benchmark_ur MemcpyExecute opsPerThread:4096, numThreads:4, allocSize:1024 srcUSM:0 dstUSM:1 without events with barrier", | ||
"memory_benchmark_sycl StreamMemory, placement Device, type Triad, size 10240", | ||
"miscellaneous_benchmark_sycl VectorSum", | ||
] | ||
|
||
def __init__(self, bench, name, test, runtime: RUNTIMES = None): | ||
super().__init__(bench.directory, bench) | ||
self.bench = bench | ||
|
@@ -280,7 +345,7 @@ def explicit_group(self): | |
def description(self) -> str: | ||
return "" | ||
|
||
def run(self, env_vars) -> list[Result]: | ||
def run(self, env_vars, unitrace_timestamp: str = None) -> list[Result]: | ||
command = [ | ||
f"{self.benchmark_bin}", | ||
f"--test={self.test}", | ||
|
@@ -291,7 +356,12 @@ def run(self, env_vars) -> list[Result]: | |
command += self.bin_args() | ||
env_vars.update(self.extra_env_vars()) | ||
|
||
result = self.run_bench(command, env_vars) | ||
if self.name() in self.unitrace_exclusion_list: | ||
unitrace_timestamp = None | ||
|
||
result = self.run_bench( | ||
command, env_vars, unitrace_timestamp=unitrace_timestamp | ||
) | ||
parsed_results = self.parse_output(result) | ||
ret = [] | ||
for label, median, stddev, unit in parsed_results: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,7 @@ def git_info_from_path(path: Path) -> (str, str): | |
compute_runtime=compute_runtime, | ||
) | ||
|
||
def save(self, save_name, results: list[Result], to_file=True): | ||
def save(self, save_name, timestamp, results: list[Result], to_file=True): | ||
benchmark_data = self.create_run(save_name, results) | ||
self.runs.append(benchmark_data) | ||
|
||
|
@@ -161,11 +161,12 @@ def save(self, save_name, results: list[Result], to_file=True): | |
os.makedirs(results_dir, exist_ok=True) | ||
|
||
# Use formatted timestamp for the filename | ||
timestamp = ( | ||
datetime.now(tz=timezone.utc).strftime("%Y%m%d_%H%M%S") | ||
if options.timestamp_override is None | ||
else options.timestamp_override | ||
) | ||
if timestamp is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like the timestamp is unconditionally created in the main() method, so this one is not needed? |
||
timestamp = ( | ||
datetime.now(tz=timezone.utc).strftime("%Y%m%d_%H%M%S") | ||
if options.timestamp_override is None | ||
else options.timestamp_override | ||
) | ||
file_path = Path(os.path.join(results_dir, f"{save_name}_{timestamp}.json")) | ||
with file_path.open("w") as file: | ||
json.dump(serialized, file, indent=4) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ | |
benchmarkRuns = []; | ||
|
||
defaultCompareNames = []; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Avoid mutable default arguments like
extra_unitrace_opt=[]
; useNone
and set to an empty list inside the function to prevent unintended sharing.Copilot uses AI. Check for mistakes.