Skip to content

Commit b625f65

Browse files
committed
generalize benchmark script, add more benchmarks
This patch creates an abstraction for defining benchmarks and then uses it to add 6 more benchmarks from Velocity Bench. The build steps of the individual benchmarks have been moved into the script itself. This is to make the definition of a benchmark self-contained.
1 parent d2b086a commit b625f65

File tree

18 files changed

+828
-241
lines changed

18 files changed

+828
-241
lines changed

.github/scripts/compute_benchmarks.py

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

.github/workflows/benchmarks_compute.yml

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ permissions:
4242
jobs:
4343
e2e-build-hw:
4444
# Run only on upstream; forks will not have the HW
45-
if: github.repository == 'oneapi-src/unified-runtime'
45+
# if: github.repository == 'oneapi-src/unified-runtime'
4646
name: Build SYCL, UR, run Compute Benchmarks
4747
strategy:
4848
matrix:
@@ -88,6 +88,9 @@ jobs:
8888
with:
8989
path: ur-repo
9090

91+
- name: Install pip packages
92+
run: pip install -r ${{github.workspace}}/ur-repo/third_party/requirements.txt
93+
9194
# We need to fetch special ref for proper PR's merge commit. Note, this ref may be absent if the PR is already merged.
9295
- name: Fetch PR's merge commit
9396
if: ${{ inputs.pr_no != 0 }}
@@ -131,44 +134,13 @@ jobs:
131134
- name: Build SYCL
132135
run: cmake --build ${{github.workspace}}/sycl_build -j
133136

134-
- name: Set additional env. vars
135-
run: |
136-
echo "${{github.workspace}}/sycl_build/bin" >> $GITHUB_PATH
137-
echo "LD_LIBRARY_PATH=${{github.workspace}}/sycl_build/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
138-
139-
# Running (newly built) sycl-ls sets up some extra variables
140-
- name: Setup SYCL variables
141-
run: |
142-
which clang++ sycl-ls
143-
SYCL_PI_TRACE=-1 sycl-ls
144-
145-
- name: Checkout Compute Benchmarks
146-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
147-
with:
148-
repository: intel/compute-benchmarks
149-
path: compute-benchmarks-repo
150-
submodules: recursive
151-
152-
- name: Configure Compute Benchmarks
153-
run: >
154-
cmake
155-
-B ${{github.workspace}}/compute-benchmarks-build/
156-
-S ${{github.workspace}}/compute-benchmarks-repo/
157-
-DCMAKE_BUILD_TYPE=Release
158-
-DBUILD_SYCL=ON
159-
-DSYCL_COMPILER_ROOT=${{github.workspace}}/sycl_build
160-
-DALLOW_WARNINGS=ON
161-
162-
- name: Build Compute Benchmarks
163-
run: cmake --build ${{github.workspace}}/compute-benchmarks-build/ -j
164-
165137
- name: Set oneAPI Device Selector
166138
run: |
167139
echo "ONEAPI_DEVICE_SELECTOR=${{ matrix.adapter.str_name }}:${{ matrix.adapter.unit }}" >> $GITHUB_ENV
168140
169-
- name: Run SYCL API Overhead benchmark
141+
- name: Run benchmarks
170142
id: benchmarks
171-
run: ${{ github.workspace }}/ur-repo/.github/scripts/compute_benchmarks.py ${{ github.workspace }}/compute-benchmarks-build/bin/ ${{ inputs.bench_script_params }}
143+
run: numactl -N 0 ${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py ~/bench_workdir ${{github.workspace}}/sycl_build ${{ inputs.bench_script_params }}
172144

173145
- name: Add comment to PR
174146
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -188,7 +160,7 @@ jobs:
188160
const test_status = '${{ steps.benchmarks.outcome }}';
189161
const job_status = '${{ job.status }}';
190162
const params = '${{ inputs.bench_script_params }}';
191-
const body = `Compute Benchmarks ${adapter} run (with params: ${params}):\n${url}\nJob status: ${job_status}. Test status: ${test_status}.\n ${markdown}`;
163+
const body = `Compute Benchmarks ${adapter} run (${params}):\n${url}\nJob status: ${job_status}. Test status: ${test_status}.\n ${markdown}`;
192164
193165
github.rest.issues.createComment({
194166
issue_number: pr_no,

scripts/benchmarks/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Unified Runtime Benchmark Runner
2+
3+
Scripts for running performance tests on SYCL and Unified Runtime.
4+
5+
## Benchmarks
6+
7+
- [Velocity Bench](https://github.com/oneapi-src/Velocity-Bench)
8+
- [Compute Benchmarks](https://github.com/intel/compute-benchmarks/)
9+
10+
## Running
11+
12+
`$ ./main.py ~/benchmarks_workdir/ ~/llvm/build/`
13+
14+
This will download and build everything in `~/benchmarks_workdir/` using the compiler in `~/llvm/build/`, and then run the benchmarks. The results will be stored in `benchmark_results.md`.
15+
16+
The scripts will try to reuse the files stored in `~/benchmarks_workdir/`, but the benchmarks will be rebuilt every time. To avoid that, use `-no-rebuild` option.
17+
18+
## Requirements
19+
20+
### Python
21+
22+
dataclasses-json==0.6.7
23+
24+
### System
25+
26+
libopencv-dev
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
from .base import Benchmark
7+
from .result import Result
8+
from .velocity import VelocityBase, VelocityBench
9+
from utils.utils import run
10+
import re
11+
12+
class SobelFilter(VelocityBase):
13+
def __init__(self, vb: VelocityBench):
14+
super().__init__("sobel_filter", "sobel_filter", vb)
15+
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")
16+
17+
def name(self):
18+
return "Velocity-Bench Sobel Filter"
19+
20+
def unit(self):
21+
return "ms"
22+
23+
def bin_args(self) -> list[str]:
24+
return ["-i", f"{self.data_path}/sobel_filter_data/silverfalls_32Kx32K.png",
25+
"-n", "5"]
26+
27+
def extra_env_vars(self) -> dict:
28+
return {"OPENCV_IO_MAX_IMAGE_PIXELS" : "1677721600"}
29+
30+
def parse_output(self, stdout: str) -> float:
31+
match = re.search(r'sobelfilter - total time for whole calculation: (\d+\.\d+) s', stdout)
32+
if match:
33+
return round(float(match.group(1)) * 1000, 3)
34+
else:
35+
raise ValueError("Failed to parse benchmark output.")
36+

0 commit comments

Comments
 (0)