Skip to content

Commit 90180f4

Browse files
authored
Merge pull request #1902 from pbalcer/benchmark-automation-2
improve benchmarks automation
2 parents c5d2175 + 1ff321c commit 90180f4

File tree

15 files changed

+384
-158
lines changed

15 files changed

+384
-158
lines changed

.github/workflows/benchmarks_compute.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,23 @@ on:
3434
type: string
3535
required: false
3636
default: ''
37+
sycl_repo:
38+
description: 'Compiler repo'
39+
type: string
40+
required: true
41+
default: 'intel/llvm'
42+
sycl_commit:
43+
description: 'Compiler commit'
44+
type: string
45+
required: false
46+
default: ''
3747

3848
permissions:
3949
contents: read
4050
pull-requests: write
4151

4252
jobs:
4353
e2e-build-hw:
44-
# Run only on upstream; forks will not have the HW
45-
# if: github.repository == 'oneapi-src/unified-runtime'
4654
name: Build SYCL, UR, run Compute Benchmarks
4755
strategy:
4856
matrix:
@@ -105,12 +113,19 @@ jobs:
105113
- name: Checkout SYCL
106114
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
107115
with:
108-
repository: intel/llvm
116+
repository: ${{inputs.sycl_repo}}
109117
ref: refs/heads/sycl
110118
path: sycl-repo
111119
fetch-depth: 1
112120
fetch-tags: false
113121

122+
- name: Fetch specific SYCL commit
123+
if: inputs.sycl_commit != ''
124+
working-directory: ./sycl-repo
125+
run: |
126+
git fetch --depth=1 origin ${{ inputs.sycl_commit }}
127+
git checkout ${{ inputs.sycl_commit }}
128+
114129
- name: Set CUDA env vars
115130
if: matrix.adapter.str_name == 'cuda'
116131
run: |

scripts/benchmarks/benches/SobelFilter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
class SobelFilter(VelocityBase):
1313
def __init__(self, vb: VelocityBench):
1414
super().__init__("sobel_filter", "sobel_filter", vb)
15+
16+
def download_deps(self):
1517
self.download_untar("sobel_filter", "https://github.com/oneapi-src/Velocity-Bench/raw/main/sobel_filter/res/sobel_filter_data.tgz?download=", "sobel_filter_data.tgz")
18+
return
1619

1720
def name(self):
1821
return "Velocity-Bench Sobel Filter"

scripts/benchmarks/benches/api_overhead.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

scripts/benchmarks/benches/base.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ def __init__(self, directory):
2020
def run_bench(self, command, env_vars):
2121
return run(command=command, env_vars=env_vars, add_sycl=True, cwd=options.benchmark_cwd).stdout.decode()
2222

23-
def create_build_path(self, name):
24-
build_path = os.path.join(self.directory, name)
25-
26-
if options.rebuild and Path(build_path).exists():
27-
shutil.rmtree(build_path)
28-
29-
Path(build_path).mkdir(parents=True, exist_ok=True)
30-
31-
return build_path
32-
3323
def create_data_path(self, name):
3424
data_path = os.path.join(self.directory, "data", name)
3525

@@ -58,10 +48,13 @@ def name(self):
5848
def unit(self):
5949
raise NotImplementedError()
6050

51+
def lower_is_better(self):
52+
return True
53+
6154
def setup(self):
6255
raise NotImplementedError()
6356

64-
def run(self, env_vars):
57+
def run(self, env_vars) -> Result:
6558
raise NotImplementedError()
6659

6760
def teardown(self):

scripts/benchmarks/benches/compute.py

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
3+
# See LICENSE.TXT
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
import os
7+
import csv
8+
import io
9+
from utils.utils import run, git_clone, create_build_path
10+
from .base import Benchmark
11+
from .result import Result
12+
from .options import options
13+
14+
class ComputeBench:
15+
def __init__(self, directory):
16+
self.directory = directory
17+
self.built = False
18+
return
19+
20+
def setup(self):
21+
if self.built:
22+
return
23+
24+
repo_path = git_clone(self.directory, "compute-benchmarks-repo", "https://github.com/intel/compute-benchmarks.git", "0f758021dce9ba32341a503739b69db057433c59")
25+
build_path = create_build_path(self.directory, 'compute-benchmarks-build')
26+
27+
configure_command = [
28+
"cmake",
29+
f"-B {build_path}",
30+
f"-S {repo_path}",
31+
f"-DCMAKE_BUILD_TYPE=Release",
32+
f"-DBUILD_SYCL=ON",
33+
f"-DSYCL_COMPILER_ROOT={options.sycl}",
34+
f"-DALLOW_WARNINGS=ON"
35+
]
36+
run(configure_command, add_sycl=True)
37+
38+
run(f"cmake --build {build_path} -j", add_sycl=True)
39+
40+
self.built = True
41+
self.bins = os.path.join(build_path, 'bin')
42+
43+
class ComputeBenchmark(Benchmark):
44+
def __init__(self, bench, name, test):
45+
self.bench = bench
46+
self.bench_name = name
47+
self.test = test
48+
super().__init__(bench.directory)
49+
50+
def bin_args(self) -> list[str]:
51+
return []
52+
53+
def extra_env_vars(self) -> dict:
54+
return {}
55+
56+
def unit(self):
57+
return "μs"
58+
59+
def setup(self):
60+
self.bench.setup()
61+
self.benchmark_bin = os.path.join(self.bench.bins, self.bench_name)
62+
63+
def run(self, env_vars) -> Result:
64+
command = [
65+
f"{self.benchmark_bin}",
66+
f"--test={self.test}",
67+
"--csv",
68+
"--noHeaders"
69+
]
70+
71+
command += self.bin_args()
72+
env_vars.update(self.extra_env_vars())
73+
74+
result = self.run_bench(command, env_vars)
75+
(label, mean) = self.parse_output(result)
76+
return Result(label=label, value=mean, command=command, env=env_vars, stdout=result)
77+
78+
def parse_output(self, output):
79+
csv_file = io.StringIO(output)
80+
reader = csv.reader(csv_file)
81+
next(reader, None)
82+
data_row = next(reader, None)
83+
if data_row is None:
84+
raise ValueError("Benchmark output does not contain data.")
85+
try:
86+
label = data_row[0]
87+
mean = float(data_row[1])
88+
return (label, mean)
89+
except (ValueError, IndexError) as e:
90+
raise ValueError(f"Error parsing output: {e}")
91+
92+
def teardown(self):
93+
return
94+
95+
class SubmitKernelSYCL(ComputeBenchmark):
96+
def __init__(self, bench, ioq):
97+
self.ioq = ioq
98+
super().__init__(bench, "api_overhead_benchmark_sycl", "SubmitKernel")
99+
100+
def name(self):
101+
order = "in order" if self.ioq else "out of order"
102+
return f"api_overhead_benchmark_sycl SubmitKernel {order}"
103+
104+
def bin_args(self) -> list[str]:
105+
return [
106+
f"--Ioq={self.ioq}",
107+
"--DiscardEvents=0",
108+
"--MeasureCompletion=0",
109+
"--iterations=100000",
110+
"--Profiling=0",
111+
"--NumKernels=10",
112+
"--KernelExecTime=1"
113+
]
114+
115+
class ExecImmediateCopyQueue(ComputeBenchmark):
116+
def __init__(self, bench, ioq, isCopyOnly, source, destination, size):
117+
self.ioq = ioq
118+
self.isCopyOnly = isCopyOnly
119+
self.source = source
120+
self.destination = destination
121+
self.size = size
122+
super().__init__(bench, "api_overhead_benchmark_sycl", "ExecImmediateCopyQueue")
123+
124+
def name(self):
125+
order = "in order" if self.ioq else "out of order"
126+
return f"api_overhead_benchmark_sycl ExecImmediateCopyQueue {order} from {self.source} to {self.destination}, size {self.size}"
127+
128+
def bin_args(self) -> list[str]:
129+
return [
130+
"--iterations=100000",
131+
f"--ioq={self.ioq}",
132+
f"--IsCopyOnly={self.isCopyOnly}",
133+
"--MeasureCompletionTime=0",
134+
f"--src={self.destination}",
135+
f"--dst={self.destination}",
136+
f"--size={self.size}"
137+
]
138+
139+
class QueueInOrderMemcpy(ComputeBenchmark):
140+
def __init__(self, bench, isCopyOnly, source, destination, size):
141+
self.isCopyOnly = isCopyOnly
142+
self.source = source
143+
self.destination = destination
144+
self.size = size
145+
super().__init__(bench, "memory_benchmark_sycl", "QueueInOrderMemcpy")
146+
147+
def name(self):
148+
return f"memory_benchmark_sycl QueueInOrderMemcpy from {self.source} to {self.destination}, size {self.size}"
149+
150+
def bin_args(self) -> list[str]:
151+
return [
152+
"--iterations=10000",
153+
f"--IsCopyOnly={self.isCopyOnly}",
154+
f"--sourcePlacement={self.source}",
155+
f"--destinationPlacement={self.destination}",
156+
f"--size={self.size}",
157+
"--count=100"
158+
]
159+
160+
class QueueMemcpy(ComputeBenchmark):
161+
def __init__(self, bench, source, destination, size):
162+
self.source = source
163+
self.destination = destination
164+
self.size = size
165+
super().__init__(bench, "memory_benchmark_sycl", "QueueMemcpy")
166+
167+
def name(self):
168+
return f"memory_benchmark_sycl QueueMemcpy from {self.source} to {self.destination}, size {self.size}"
169+
170+
def bin_args(self) -> list[str]:
171+
return [
172+
"--iterations=10000",
173+
f"--sourcePlacement={self.source}",
174+
f"--destinationPlacement={self.destination}",
175+
f"--size={self.size}",
176+
]
177+
178+
class StreamMemory(ComputeBenchmark):
179+
def __init__(self, bench, type, size, placement):
180+
self.type = type
181+
self.size = size
182+
self.placement = placement
183+
super().__init__(bench, "memory_benchmark_sycl", "StreamMemory")
184+
185+
def name(self):
186+
return f"memory_benchmark_sycl StreamMemory, placement {self.placement}, type {self.type}, size {self.size}"
187+
188+
def bin_args(self) -> list[str]:
189+
return [
190+
"--iterations=10000",
191+
f"--type={self.type}",
192+
f"--size={self.size}",
193+
f"--memoryPlacement={self.placement}",
194+
"--useEvents=0",
195+
"--contents=Zeros",
196+
]
197+
198+
class VectorSum(ComputeBenchmark):
199+
def __init__(self, bench):
200+
super().__init__(bench, "miscellaneous_benchmark_sycl", "VectorSum")
201+
202+
def name(self):
203+
return f"miscellaneous_benchmark_sycl VectorSum"
204+
205+
def bin_args(self) -> list[str]:
206+
return [
207+
"--iterations=1000",
208+
"--numberOfElementsX=512",
209+
"--numberOfElementsY=256",
210+
"--numberOfElementsZ=256",
211+
]
212+

0 commit comments

Comments
 (0)