Skip to content

Commit 261f6f1

Browse files
committed
add building compute-runtime UMD in benchmarks jobs
1 parent 023a847 commit 261f6f1

16 files changed

+183
-46
lines changed

.github/workflows/benchmarks-reusable.yml

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ on:
3434
required: false
3535
type: boolean
3636
default: false
37+
compute_runtime_commit:
38+
required: false
39+
type: string
40+
default: ''
3741

3842
permissions:
3943
contents: read
@@ -200,6 +204,7 @@ jobs:
200204
--ur ${{ github.workspace }}/ur_install
201205
--umf ${{ github.workspace }}/umf_build
202206
--adapter ${{ matrix.adapter.str_name }}
207+
--compute-runtime ${{ inputs.compute_runtime_commit }}
203208
${{ inputs.upload_report && '--output-html' || '' }}
204209
${{ inputs.bench_script_params }}
205210

.github/workflows/benchmarks.yml

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ on:
4343
type: string
4444
required: false
4545
default: ''
46+
compute_runtime_commit:
47+
description: 'Compute Runtime commit'
48+
type: string
49+
required: false
50+
default: ''
4651
upload_report:
4752
description: 'Upload HTML report'
4853
type: boolean
@@ -65,4 +70,5 @@ jobs:
6570
sycl_config_params: ${{ inputs.sycl_config_params }}
6671
sycl_repo: ${{ inputs.sycl_repo }}
6772
sycl_commit: ${{ inputs.sycl_commit }}
73+
compute_runtime_commit: ${{ inputs.compute_runtime_commit }}
6874
upload_report: ${{ inputs.upload_report }}

scripts/benchmarks/benches/base.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import shutil
88
from pathlib import Path
99
from .result import Result
10-
from .options import options
10+
from options import options
1111
from utils.utils import download, run
1212
import urllib.request
1313
import tarfile
@@ -28,17 +28,22 @@ def get_adapter_full_path():
2828
f"could not find adapter file {adapter_path} (and in similar lib paths)"
2929

3030
def run_bench(self, command, env_vars, ld_library=[], add_sycl=True):
31-
env_vars_with_forced_adapter = env_vars.copy()
31+
env_vars = env_vars.copy()
3232
if options.ur is not None:
33-
env_vars_with_forced_adapter.update(
33+
env_vars.update(
3434
{'UR_ADAPTERS_FORCE_LOAD': Benchmark.get_adapter_full_path()})
3535

36+
env_vars.update(options.extra_env_vars)
37+
38+
ld_libraries = options.extra_ld_libraries.copy()
39+
ld_libraries.extend(ld_library)
40+
3641
return run(
3742
command=command,
38-
env_vars=env_vars_with_forced_adapter,
43+
env_vars=env_vars,
3944
add_sycl=add_sycl,
4045
cwd=options.benchmark_cwd,
41-
ld_library=ld_library
46+
ld_library=ld_libraries
4247
).stdout.decode()
4348

4449
def create_data_path(self, name, skip_data_dir = False):

scripts/benchmarks/benches/compute.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from utils.utils import run, git_clone, create_build_path
1010
from .base import Benchmark, Suite
1111
from .result import Result
12-
from .options import options
12+
from options import options
1313

1414
class ComputeBench(Suite):
1515
def __init__(self, directory):
@@ -22,7 +22,7 @@ def setup(self):
2222
if options.sycl is None:
2323
return
2424

25-
repo_path = git_clone(self.directory, "compute-benchmarks-repo", "https://github.com/intel/compute-benchmarks.git", "df38bc342641d7e83fbb4fe764a23d21d734e07b")
25+
repo_path = git_clone(self.directory, "compute-benchmarks-repo", "https://github.com/intel/compute-benchmarks.git", "d13e5b4d8dd3d28926a74ab7f67f78c10f708a01")
2626
build_path = create_build_path(self.directory, 'compute-benchmarks-build')
2727

2828
configure_command = [

scripts/benchmarks/benches/llamacpp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .base import Benchmark, Suite
1111
from .result import Result
1212
from utils.utils import run, create_build_path
13-
from .options import options
13+
from options import options
1414
from .oneapi import get_oneapi
1515
import os
1616

scripts/benchmarks/benches/oneapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from pathlib import Path
77
from utils.utils import download, run
8-
from .options import options
8+
from options import options
99
import os
1010

1111
class OneAPI:

scripts/benchmarks/benches/syclbench.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from utils.utils import run, git_clone, create_build_path
1010
from .base import Benchmark, Suite
1111
from .result import Result
12-
from .options import options
12+
from options import options
1313

1414
class SyclBench(Suite):
1515
def __init__(self, directory):

scripts/benchmarks/benches/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .base import Benchmark, Suite
99
from .result import Result
1010
from utils.utils import run, create_build_path
11-
from .options import options
11+
from options import options
1212
import os
1313

1414
class TestSuite(Suite):

scripts/benchmarks/benches/umf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .base import Benchmark, Suite
99
from .result import Result
1010
from utils.utils import run, create_build_path
11-
from .options import options
11+
from options import options
1212
from .oneapi import get_oneapi
1313
import os
1414
import csv

scripts/benchmarks/benches/velocity.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .base import Benchmark, Suite
1010
from .result import Result
1111
from utils.utils import run, create_build_path
12-
from .options import options
12+
from options import options
1313
from .oneapi import get_oneapi
1414
import shutil
1515

@@ -54,7 +54,6 @@ def __init__(self, name: str, bin_name: str, vb: VelocityBench, unit: str):
5454
self.bench_name = name
5555
self.bin_name = bin_name
5656
self.unit = unit
57-
self.code_path = os.path.join(self.vb.repo_path, self.bench_name, 'SYCL')
5857

5958
def download_deps(self):
6059
return
@@ -66,6 +65,7 @@ def ld_libraries(self) -> list[str]:
6665
return []
6766

6867
def setup(self):
68+
self.code_path = os.path.join(self.vb.repo_path, self.bench_name, 'SYCL')
6969
self.download_deps()
7070
self.benchmark_bin = os.path.join(self.directory, self.bench_name, self.bin_name)
7171

@@ -130,12 +130,13 @@ def parse_output(self, stdout: str) -> float:
130130
class Bitcracker(VelocityBase):
131131
def __init__(self, vb: VelocityBench):
132132
super().__init__("bitcracker", "bitcracker", vb, "s")
133-
self.data_path = os.path.join(vb.repo_path, "bitcracker", "hash_pass")
134133

135134
def name(self):
136135
return "Velocity-Bench Bitcracker"
137136

138137
def bin_args(self) -> list[str]:
138+
self.data_path = os.path.join(self.vb.repo_path, "bitcracker", "hash_pass")
139+
139140
return ["-f", f"{self.data_path}/img_win8_user_hash.txt",
140141
"-d", f"{self.data_path}/user_passwords_60000.txt",
141142
"-b", "60000"]
@@ -175,7 +176,6 @@ def parse_output(self, stdout: str) -> float:
175176
class QuickSilver(VelocityBase):
176177
def __init__(self, vb: VelocityBench):
177178
super().__init__("QuickSilver", "qs", vb, "MMS/CTT")
178-
self.data_path = os.path.join(vb.repo_path, "QuickSilver", "Examples", "AllScattering")
179179

180180
def run(self, env_vars) -> list[Result]:
181181
# TODO: fix the crash in QuickSilver when UR_L0_USE_IMMEDIATE_COMMANDLISTS=0
@@ -191,6 +191,8 @@ def lower_is_better(self):
191191
return False
192192

193193
def bin_args(self) -> list[str]:
194+
self.data_path = os.path.join(self.vb.repo_path, "QuickSilver", "Examples", "AllScattering")
195+
194196
return ["-i", f"{self.data_path}/scatteringOnly.inp"]
195197

196198
def extra_env_vars(self) -> dict:
@@ -266,20 +268,20 @@ def parse_output(self, stdout: str) -> float:
266268

267269
class DLCifar(VelocityBase):
268270
def __init__(self, vb: VelocityBench):
269-
self.oneapi = get_oneapi()
270271
super().__init__("dl-cifar", "dl-cifar_sycl", vb, "s")
271272

272273
def ld_libraries(self):
273-
return self.oneapi.ld_libraries()
274+
return get_oneapi().ld_libraries()
274275

275276
def download_deps(self):
276277
# TODO: dl-cifar hardcodes the path to this dataset as "../../datasets/cifar-10-binary"...
277278
self.download("datasets", "https://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz", "cifar-10-binary.tar.gz", untar=True, skip_data_dir=True)
278279
return
279280

280281
def extra_cmake_args(self):
282+
oneapi = get_oneapi()
281283
return [
282-
f"-DCMAKE_CXX_FLAGS=-O3 -fsycl -ffast-math -I{self.oneapi.dnn_include()} -I{self.oneapi.mkl_include()} -L{self.oneapi.dnn_lib()} -L{self.oneapi.mkl_lib()}"
284+
f"-DCMAKE_CXX_FLAGS=-O3 -fsycl -ffast-math -I{oneapi.dnn_include()} -I{oneapi.mkl_include()} -L{oneapi.dnn_lib()} -L{oneapi.mkl_lib()}"
283285
]
284286

285287
def name(self):
@@ -294,11 +296,10 @@ def parse_output(self, stdout: str) -> float:
294296

295297
class DLMnist(VelocityBase):
296298
def __init__(self, vb: VelocityBench):
297-
self.oneapi = get_oneapi()
298299
super().__init__("dl-mnist", "dl-mnist-sycl", vb, "s")
299300

300301
def ld_libraries(self):
301-
return self.oneapi.ld_libraries()
302+
return get_oneapi().ld_libraries()
302303

303304
def download_deps(self):
304305
# TODO: dl-mnist hardcodes the path to this dataset as "../../datasets/"...
@@ -308,8 +309,9 @@ def download_deps(self):
308309
self.download("datasets", "https://raw.githubusercontent.com/fgnt/mnist/master/t10k-labels-idx1-ubyte.gz", "t10k-labels.idx1-ubyte.gz", unzip=True, skip_data_dir=True)
309310

310311
def extra_cmake_args(self):
312+
oneapi = get_oneapi()
311313
return [
312-
f"-DCMAKE_CXX_FLAGS=-O3 -fsycl -ffast-math -I{self.oneapi.dnn_include()} -I{self.oneapi.mkl_include()} -L{self.oneapi.dnn_lib()} -L{self.oneapi.mkl_lib()}"
314+
f"-DCMAKE_CXX_FLAGS=-O3 -fsycl -ffast-math -I{oneapi.dnn_include()} -I{oneapi.mkl_include()} -L{oneapi.dnn_lib()} -L{oneapi.mkl_lib()}"
313315
]
314316

315317
def name(self):
@@ -337,15 +339,15 @@ def parse_output(self, stdout: str) -> float:
337339

338340
class SVM(VelocityBase):
339341
def __init__(self, vb: VelocityBench):
340-
self.oneapi = get_oneapi()
341342
super().__init__("svm", "svm_sycl", vb, "s")
342343

343344
def ld_libraries(self):
344-
return self.oneapi.ld_libraries()
345+
return get_oneapi().ld_libraries()
345346

346347
def extra_cmake_args(self):
348+
oneapi = get_oneapi()
347349
return [
348-
f"-DCMAKE_CXX_FLAGS=-O3 -fsycl -ffast-math -I{self.oneapi.dnn_include()} -I{self.oneapi.mkl_include()} -L{self.oneapi.dnn_lib()} -L{self.oneapi.mkl_lib()}"
350+
f"-DCMAKE_CXX_FLAGS=-O3 -fsycl -ffast-math -I{oneapi.dnn_include()} -I{oneapi.mkl_include()} -L{oneapi.dnn_lib()} -L{oneapi.mkl_lib()}"
349351
]
350352

351353
def name(self):

scripts/benchmarks/history.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import json
88
from pathlib import Path
99
from benches.result import Result, BenchmarkRun
10-
from benches.options import Compare, options
10+
from options import Compare, options
1111
from datetime import datetime, timezone
1212
from utils.utils import run;
1313

scripts/benchmarks/main.py

+24-17
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
from benches.llamacpp import *
1212
from benches.umf import *
1313
from benches.test import TestSuite
14-
from benches.options import Compare, options
14+
from options import Compare, options
1515
from output_markdown import generate_markdown
1616
from output_html import generate_html
1717
from history import BenchmarkHistory
18-
from utils.utils import prepare_workdir;
18+
from utils.utils import prepare_workdir
19+
from utils.compute_runtime import *
1920

2021
import argparse
2122
import re
@@ -117,6 +118,13 @@ def process_results(results: dict[str, list[Result]], stddev_threshold_override)
117118
def main(directory, additional_env_vars, save_name, compare_names, filter):
118119
prepare_workdir(directory, INTERNAL_WORKDIR_VERSION)
119120

121+
if options.build_compute_runtime:
122+
print(f"Setting up Compute Runtime {options.compute_runtime_tag}")
123+
cr = get_compute_runtime()
124+
print("Compute Runtime setup complete.")
125+
options.extra_ld_libraries.extend(cr.ld_libraries())
126+
options.extra_env_vars.update(cr.env_vars())
127+
120128
suites = [
121129
ComputeBench(directory),
122130
VelocityBench(directory),
@@ -129,15 +137,15 @@ def main(directory, additional_env_vars, save_name, compare_names, filter):
129137
benchmarks = []
130138

131139
for s in suites:
132-
print(f"Setting up {type(s).__name__}")
133-
s.setup()
134-
print(f"{type(s).__name__} setup complete.")
135-
136-
for s in suites:
137-
benchmarks += s.benchmarks()
140+
suite_benchmarks = s.benchmarks()
141+
if filter:
142+
suite_benchmarks = [benchmark for benchmark in suite_benchmarks if filter.search(benchmark.name())]
138143

139-
if filter:
140-
benchmarks = [benchmark for benchmark in benchmarks if filter.search(benchmark.name())]
144+
if suite_benchmarks:
145+
print(f"Setting up {type(s).__name__}")
146+
s.setup()
147+
print(f"{type(s).__name__} setup complete.")
148+
benchmarks += suite_benchmarks
141149

142150
for b in benchmarks:
143151
print(b.name())
@@ -241,7 +249,7 @@ def validate_and_parse_env_args(env_args):
241249
parser.add_argument("--save", type=str, help='Save the results for comparison under a specified name.')
242250
parser.add_argument("--compare", type=str, help='Compare results against previously saved data.', action="append", default=["baseline"])
243251
parser.add_argument("--iterations", type=int, help='Number of times to run each benchmark to select a median value.', default=options.iterations)
244-
parser.add_argument("--stddev-threshold", type=float, help='If stddev % is above this threshold, rerun all iterations', default=options.stddev_threshold)
252+
parser.add_argument("--stddev-threshold", type=float, help='If stddev pct is above this threshold, rerun all iterations', default=options.stddev_threshold)
245253
parser.add_argument("--timeout", type=int, help='Timeout for individual benchmarks in seconds.', default=options.timeout)
246254
parser.add_argument("--filter", type=str, help='Regex pattern to filter benchmarks by name.', default=None)
247255
parser.add_argument("--epsilon", type=float, help='Threshold to consider change of performance significant', default=options.epsilon)
@@ -252,12 +260,8 @@ def validate_and_parse_env_args(env_args):
252260
parser.add_argument("--output-html", help='Create HTML output', action="store_true", default=False)
253261
parser.add_argument("--output-markdown", help='Create Markdown output', action="store_true", default=True)
254262
parser.add_argument("--dry-run", help='Do not run any actual benchmarks', action="store_true", default=False)
255-
parser.add_argument(
256-
"--iterations-stddev",
257-
type=int,
258-
help="Max number of iterations of the loop calculating stddev after completed benchmark runs",
259-
default=options.iterations_stddev,
260-
)
263+
parser.add_argument("--compute-runtime", nargs='?', const=options.compute_runtime_tag, help="Fetch and build compute runtime")
264+
parser.add_argument("--iterations-stddev", type=int, help="Max number of iterations of the loop calculating stddev after completed benchmark runs", default=options.iterations_stddev)
261265

262266
args = parser.parse_args()
263267
additional_env_vars = validate_and_parse_env_args(args.env)
@@ -279,6 +283,9 @@ def validate_and_parse_env_args(env_args):
279283
options.dry_run = args.dry_run
280284
options.umf = args.umf
281285
options.iterations_stddev = args.iterations_stddev
286+
if args.compute_runtime is not None:
287+
options.build_compute_runtime = True
288+
options.compute_runtime_tag = args.compute_runtime
282289

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

scripts/benchmarks/benches/options.py renamed to scripts/benchmarks/options.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dataclasses import dataclass
1+
from dataclasses import dataclass, field
22
from enum import Enum
33

44
class Compare(Enum):
@@ -27,6 +27,10 @@ class Options:
2727
stddev_threshold: float = 0.02
2828
epsilon: float = 0.02
2929
iterations_stddev: int = 5
30+
build_compute_runtime: bool = False
31+
extra_ld_libraries: list[str] = field(default_factory=list)
32+
extra_env_vars: dict = field(default_factory=dict)
33+
compute_runtime_tag: str = 'c1ed0334d65f6ce86d7273fe4137d1d4a5b5fa7c'
3034

3135
options = Options()
3236

scripts/benchmarks/output_markdown.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import collections, re
77
from benches.result import Result
8-
from benches.options import options
8+
from options import options
99
import math
1010

1111
class OutputLine:

0 commit comments

Comments
 (0)