Skip to content

Commit d2610c3

Browse files
committed
add support for benchmark tags
1 parent 6bff3d6 commit d2610c3

File tree

7 files changed

+91
-6
lines changed

7 files changed

+91
-6
lines changed

devops/scripts/benchmarks/benches/base.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,36 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6+
from dataclasses import dataclass
67
import os
78
import shutil
89
from pathlib import Path
9-
from utils.result import BenchmarkMetadata, Result
10+
from utils.result import BenchmarkMetadata, BenchmarkTag, Result
1011
from options import options
1112
from utils.utils import download, run
12-
import urllib.request
13-
import tarfile
1413

14+
benchmark_tags = [BenchmarkTag('sycl', 'Benchmark uses SYCL RT'),
15+
BenchmarkTag('ur', 'Benchmark uses Unified Runtime'),
16+
BenchmarkTag('L0', 'Benchmark uses L0 directly'),
17+
BenchmarkTag('umf', 'Benchmark uses UMF directly'),
18+
BenchmarkTag('micro', 'Microbenchmark focusing on a specific niche'),
19+
BenchmarkTag('application', 'Real application-based performance test'),
20+
BenchmarkTag('proxy', 'Benchmark that tries to implement a real application use-case'),
21+
BenchmarkTag('submit', 'Benchmark tests the kernel submit path'),
22+
BenchmarkTag('math', 'Benchmark tests math compute performance'),
23+
BenchmarkTag('memory', 'Benchmark tests memory transfer performance'),
24+
BenchmarkTag('allocation', 'Benchmark tests memory allocation performance'),
25+
BenchmarkTag('graph', 'Benchmark tests graph performance'),]
26+
27+
def translate_tags(tag_names: list[str]) -> list[BenchmarkTag]:
28+
tags = []
29+
for tag_name in tag_names:
30+
for tag in benchmark_tags:
31+
if tag.name == tag_name:
32+
tags.append(tag)
33+
break
34+
35+
return tags
1536

1637
class Benchmark:
1738
def __init__(self, directory, suite):
@@ -105,15 +126,18 @@ def notes(self) -> str:
105126
def unstable(self) -> str:
106127
return None
107128

129+
def get_tags(self) -> list[str]:
130+
return []
131+
108132
def get_metadata(self) -> BenchmarkMetadata:
109133
return BenchmarkMetadata(
110134
type="benchmark",
111135
description=self.description(),
112136
notes=self.notes(),
113137
unstable=self.unstable(),
138+
tags=translate_tags(self.get_tags())
114139
)
115140

116-
117141
class Suite:
118142
def benchmarks(self) -> list[Benchmark]:
119143
raise NotImplementedError()

devops/scripts/benchmarks/benches/compute.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import csv
88
import io
99
from utils.utils import run, git_clone, create_build_path
10-
from .base import Benchmark, Suite
10+
from .base import Benchmark, Suite, translate_tags
1111
from utils.result import BenchmarkMetadata, Result
1212
from options import options
1313
from enum import Enum
@@ -26,6 +26,13 @@ def runtime_to_name(runtime: RUNTIMES) -> str:
2626
RUNTIMES.UR: "Unified Runtime",
2727
}[runtime]
2828

29+
def runtime_to_tag_name(runtime: RUNTIMES) -> str:
30+
return {
31+
RUNTIMES.SYCL: "sycl",
32+
RUNTIMES.LEVEL_ZERO: "L0",
33+
RUNTIMES.UR: "ur",
34+
}[runtime]
35+
2936

3037
class ComputeBench(Suite):
3138
def __init__(self, directory):
@@ -77,10 +84,12 @@ def additionalMetadata(self) -> dict[str, BenchmarkMetadata]:
7784
"The first layer is the Level Zero API, the second is the Unified Runtime API, and the third is the SYCL API.\n"
7885
"The UR v2 adapter noticeably reduces UR layer overhead, also improving SYCL performance.\n"
7986
"Work is ongoing to reduce the overhead of the SYCL API\n",
87+
tags=translate_tags(['submit', 'micro'])
8088
),
8189
"SinKernelGraph": BenchmarkMetadata(
8290
type="group",
8391
unstable="This benchmark combines both eager and graph execution, and may not be representative of real use cases.",
92+
tags=translate_tags(['submit', 'micro'])
8493
),
8594
}
8695

@@ -265,6 +274,9 @@ def __init__(self, bench, runtime: RUNTIMES, ioq, measure_completion=0):
265274
bench, f"api_overhead_benchmark_{runtime.value}", "SubmitKernel"
266275
)
267276

277+
def get_tags(self):
278+
return ['submit', runtime_to_tag_name(self.runtime), 'micro']
279+
268280
def name(self):
269281
order = "in order" if self.ioq else "out of order"
270282
completion_str = " with measure completion" if self.measure_completion else ""
@@ -327,6 +339,9 @@ def description(self) -> str:
327339
f"{self.destination} memory with {self.size} bytes. Tests immediate execution overheads."
328340
)
329341

342+
def get_tags(self):
343+
return ['memory', 'sycl', 'micro']
344+
330345
def bin_args(self) -> list[str]:
331346
return [
332347
"--iterations=100000",
@@ -357,6 +372,9 @@ def description(self) -> str:
357372
f"{self.source} to {self.destination} with {self.size} bytes, executed 100 times per iteration."
358373
)
359374

375+
def get_tags(self):
376+
return ['memory', 'sycl', 'micro']
377+
360378
def bin_args(self) -> list[str]:
361379
return [
362380
"--iterations=10000",
@@ -384,6 +402,9 @@ def description(self) -> str:
384402
f"{self.destination} with {self.size} bytes per operation."
385403
)
386404

405+
def get_tags(self):
406+
return ['memory', 'sycl', 'micro']
407+
387408
def bin_args(self) -> list[str]:
388409
return [
389410
"--iterations=10000",
@@ -413,6 +434,9 @@ def description(self) -> str:
413434
def lower_is_better(self):
414435
return False
415436

437+
def get_tags(self):
438+
return ['memory', 'sycl', 'micro']
439+
416440
def bin_args(self) -> list[str]:
417441
return [
418442
"--iterations=10000",
@@ -439,6 +463,9 @@ def description(self) -> str:
439463
"using SYCL."
440464
)
441465

466+
def get_tags(self):
467+
return ['math', 'sycl', 'micro']
468+
442469
def bin_args(self) -> list[str]:
443470
return [
444471
"--iterations=1000",
@@ -485,6 +512,9 @@ def description(self) -> str:
485512
f"from {src_type} to {dst_type} memory {events} events."
486513
)
487514

515+
def get_tags(self):
516+
return ['memory', 'ur', 'micro']
517+
488518
def bin_args(self) -> list[str]:
489519
return [
490520
"--Ioq=1",
@@ -525,6 +555,9 @@ def name(self):
525555
def unstable(self) -> str:
526556
return "This benchmark combines both eager and graph execution, and may not be representative of real use cases."
527557

558+
def get_tags(self):
559+
return ['graph', runtime_to_tag_name(self.runtime), 'proxy', 'submit', 'memory']
560+
528561
def bin_args(self) -> list[str]:
529562
return [
530563
"--iterations=10000",
@@ -557,6 +590,9 @@ def description(self) -> str:
557590
def name(self):
558591
return f"graph_api_benchmark_{self.runtime.value} SubmitGraph numKernels:{self.numKernels} ioq {self.inOrderQueue} measureCompletion {self.measureCompletionTime}"
559592

593+
def get_tags(self):
594+
return ['graph', runtime_to_tag_name(self.runtime), 'micro', 'submit']
595+
560596
def bin_args(self) -> list[str]:
561597
return [
562598
"--iterations=10000",
@@ -584,6 +620,9 @@ def description(self) -> str:
584620
def name(self):
585621
return f"ulls_benchmark_{self.runtime.value} EmptyKernel wgc:{self.wgc}, wgs:{self.wgs}"
586622

623+
def get_tags(self):
624+
return [runtime_to_tag_name(self.runtime), 'micro']
625+
587626
def bin_args(self) -> list[str]:
588627
return [
589628
"--iterations=10000",
@@ -622,6 +661,9 @@ def description(self) -> str:
622661
def name(self):
623662
return f"ulls_benchmark_{self.runtime.value} KernelSwitch count {self.count} kernelTime {self.kernelTime}"
624663

664+
def get_tags(self):
665+
return [runtime_to_tag_name(self.runtime), 'micro']
666+
625667
def bin_args(self) -> list[str]:
626668
return [
627669
"--iterations=1000",

devops/scripts/benchmarks/benches/llamacpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ def description(self) -> str:
101101
"quantized model and leverages SYCL with oneDNN for acceleration."
102102
)
103103

104+
def get_tags(self):
105+
return ['sycl', 'application']
106+
104107
def lower_is_better(self):
105108
return False
106109

devops/scripts/benchmarks/benches/syclbench.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def bin_args(self) -> list[str]:
112112
def extra_env_vars(self) -> dict:
113113
return {}
114114

115+
def get_tags(self):
116+
return ['sycl', 'micro']
117+
115118
def setup(self):
116119
self.benchmark_bin = os.path.join(
117120
self.directory, "sycl-bench-build", self.bench_name

devops/scripts/benchmarks/benches/umf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def setup(self):
7474

7575
self.benchmark_bin = os.path.join(options.umf, "benchmark", self.bench_name)
7676

77+
def get_tags(self):
78+
return ['umf', 'allocation']
79+
7780
def run(self, env_vars) -> list[Result]:
7881
command = [
7982
f"{self.benchmark_bin}",

devops/scripts/benchmarks/benches/velocity.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def parse_output(self, stdout: str) -> float:
118118
def description(self) -> str:
119119
return ""
120120

121+
def get_tags(self):
122+
return ['sycl', 'application']
123+
121124
def run(self, env_vars) -> list[Result]:
122125
env_vars.update(self.extra_env_vars())
123126

devops/scripts/benchmarks/utils/result.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class Result:
2727
name: str = ""
2828
lower_is_better: bool = True
2929
suite: str = "Unknown"
30-
description: str = "No description provided."
3130

3231

3332
@dataclass_json
@@ -44,10 +43,18 @@ class BenchmarkRun:
4443
)
4544

4645

46+
@dataclass_json
47+
@dataclass
48+
class BenchmarkTag:
49+
name: str
50+
description: str = ""
51+
52+
4753
@dataclass_json
4854
@dataclass
4955
class BenchmarkMetadata:
5056
type: str = "benchmark" # or 'group'
5157
description: Optional[str] = None
5258
notes: Optional[str] = None
5359
unstable: Optional[str] = None
60+
tags: list[BenchmarkTag] = field(default_factory=list)

0 commit comments

Comments
 (0)