Skip to content

Commit 890cd32

Browse files
authored
Merge pull request #2281 from oneapi-src/benchmark-improvements
improve benchmark scripts and add a nightly job
2 parents 165c448 + 5a10b70 commit 890cd32

25 files changed

+1182
-433
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Compute Benchmarks Nightly
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Runs at midnight UTC every day
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
nightly:
13+
name: Compute Benchmarks Nightly level-zero
14+
uses: ./.github/workflows/benchmarks-reusable.yml
15+
with:
16+
str_name: 'level_zero'
17+
unit: 'gpu'
18+
pr_no: 0
19+
bench_script_params: '--save baseline'
20+
sycl_config_params: ''
21+
sycl_repo: 'intel/llvm'
22+
sycl_commit: ''
23+
24+
nightly2:
25+
# we need to wait until previous job is done so that the html report
26+
# contains both runs
27+
needs: nightly
28+
name: Compute Benchmarks Nightly level-zero v2
29+
uses: ./.github/workflows/benchmarks-reusable.yml
30+
with:
31+
str_name: 'level_zero_v2'
32+
unit: 'gpu'
33+
pr_no: 0
34+
bench_script_params: '--save baseline-v2'
35+
sycl_config_params: ''
36+
sycl_repo: 'intel/llvm'
37+
sycl_commit: ''
38+
upload_report: true

.github/workflows/benchmarks_compute.yml renamed to .github/workflows/benchmarks-reusable.yml

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,39 @@
1-
name: Compute Benchmarks
1+
name: Benchmarks Reusable
22

33
on:
4-
# Can be triggered via manual "dispatch" (from workflow view in GitHub Actions tab)
5-
workflow_dispatch:
6-
# acceptable input for adapter-specific runs
4+
workflow_call:
75
inputs:
86
str_name:
9-
description: Formatted adapter name
10-
type: choice
117
required: true
12-
default: 'level_zero'
13-
options:
14-
- level_zero
15-
- level_zero_v2
8+
type: string
169
unit:
17-
description: Test unit (cpu/gpu)
18-
type: choice
1910
required: true
20-
default: 'gpu'
21-
options:
22-
- cpu
23-
- gpu
11+
type: string
2412
pr_no:
25-
description: PR number (if 0, it'll run on the main)
26-
type: number
2713
required: true
28-
bench_script_params:
29-
description: Parameters passed to script executing benchmark
14+
# even though this is a number, this is a workaround for issues with
15+
# reusable workflow calls that result in "Unexpected value '0'" error.
3016
type: string
17+
bench_script_params:
3118
required: false
19+
type: string
3220
default: ''
3321
sycl_config_params:
34-
description: Extra params for SYCL configuration
35-
type: string
3622
required: false
23+
type: string
3724
default: ''
3825
sycl_repo:
39-
description: 'Compiler repo'
40-
type: string
4126
required: true
27+
type: string
4228
default: 'intel/llvm'
4329
sycl_commit:
44-
description: 'Compiler commit'
45-
type: string
4630
required: false
31+
type: string
4732
default: ''
33+
upload_report:
34+
required: false
35+
type: boolean
36+
default: false
4837

4938
permissions:
5039
contents: read
@@ -56,19 +45,17 @@ jobs:
5645
strategy:
5746
matrix:
5847
adapter: [
59-
{str_name: "${{inputs.str_name}}",
60-
sycl_config: "${{inputs.sycl_config_params}}",
61-
unit: "${{inputs.unit}}"
48+
{str_name: "${{ inputs.str_name }}",
49+
sycl_config: "${{ inputs.sycl_config_params }}",
50+
unit: "${{ inputs.unit }}"
6251
}
6352
]
6453
build_type: [Release]
6554
compiler: [{c: clang, cxx: clang++}]
6655

67-
runs-on: "${{inputs.str_name}}_PERF"
56+
runs-on: "${{ inputs.str_name }}_PERF"
6857

6958
steps:
70-
# Workspace on self-hosted runners is not cleaned automatically.
71-
# We have to delete the files created outside of using actions.
7259
- name: Cleanup self-hosted workspace
7360
if: always()
7461
run: |
@@ -99,7 +86,8 @@ jobs:
9986
path: ur-repo
10087

10188
- name: Install pip packages
102-
run: pip install -r ${{github.workspace}}/ur-repo/third_party/requirements.txt
89+
run: |
90+
pip install --force-reinstall -r ${{github.workspace}}/ur-repo/third_party/benchmark_requirements.txt
10391
10492
# We need to fetch special ref for proper PR's merge commit. Note, this ref may be absent if the PR is already merged.
10593
- name: Fetch PR's merge commit
@@ -169,13 +157,15 @@ jobs:
169157
run: cmake --install ${{github.workspace}}/ur_build
170158

171159
- name: Run benchmarks
160+
working-directory: ${{ github.workspace }}/ur-repo/
172161
id: benchmarks
173162
run: >
174-
numactl -N 0 ${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py
175-
~/bench_workdir
176-
${{github.workspace}}/sycl_build
177-
${{github.workspace}}/ur_install
178-
${{ matrix.adapter.str_name }}
163+
${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py
164+
~/bench_workdir
165+
--sycl ${{ github.workspace }}/sycl_build
166+
--ur ${{ github.workspace }}/ur_install
167+
--adapter ${{ matrix.adapter.str_name }}
168+
${{ inputs.upload_report && '--output-html' || '' }}
179169
${{ inputs.bench_script_params }}
180170
181171
- name: Add comment to PR
@@ -204,3 +194,10 @@ jobs:
204194
repo: context.repo.repo,
205195
body: body
206196
})
197+
198+
- name: Upload HTML report
199+
if: ${{ always() && inputs.upload_report }}
200+
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
201+
with:
202+
path: ${{ github.workspace }}/ur-repo/benchmark_results.html
203+
key: benchmark-results-${{ matrix.adapter.str_name }}-${{ github.run_id }}

.github/workflows/benchmarks.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Compute Benchmarks
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
str_name:
7+
description: Formatted adapter name
8+
type: choice
9+
required: true
10+
default: 'level_zero'
11+
options:
12+
- level_zero
13+
- level_zero_v2
14+
unit:
15+
description: Test unit (cpu/gpu)
16+
type: choice
17+
required: true
18+
default: 'gpu'
19+
options:
20+
- cpu
21+
- gpu
22+
pr_no:
23+
description: PR number (if 0, it'll run on the main)
24+
type: number
25+
required: true
26+
bench_script_params:
27+
description: Parameters passed to script executing benchmark
28+
type: string
29+
required: false
30+
default: ''
31+
sycl_config_params:
32+
description: Extra params for SYCL configuration
33+
type: string
34+
required: false
35+
default: ''
36+
sycl_repo:
37+
description: 'Compiler repo'
38+
type: string
39+
required: true
40+
default: 'intel/llvm'
41+
sycl_commit:
42+
description: 'Compiler commit'
43+
type: string
44+
required: false
45+
default: ''
46+
upload_report:
47+
description: 'Upload HTML report'
48+
type: boolean
49+
required: false
50+
default: false
51+
52+
permissions:
53+
contents: read
54+
pull-requests: write
55+
56+
jobs:
57+
manual:
58+
name: Compute Benchmarks
59+
uses: ./.github/workflows/benchmarks-reusable.yml
60+
with:
61+
str_name: ${{ inputs.str_name }}
62+
unit: ${{ inputs.unit }}
63+
pr_no: ${{ inputs.pr_no }}
64+
bench_script_params: ${{ inputs.bench_script_params }}
65+
sycl_config_params: ${{ inputs.sycl_config_params }}
66+
sycl_repo: ${{ inputs.sycl_repo }}
67+
sycl_commit: ${{ inputs.sycl_commit }}
68+
upload_report: ${{ inputs.upload_report }}

.github/workflows/docs.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,23 @@ jobs:
4545

4646
- name: Build Documentation
4747
working-directory: ${{github.workspace}}/scripts
48-
run: python3 run.py --core
48+
run: |
49+
python3 run.py --core
50+
mkdir -p ${{ github.workspace }}/ur-repo/
51+
mkdir -p ${{github.workspace}}/docs/html
52+
53+
- name: Download benchmark HTML
54+
id: download-bench-html
55+
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
56+
with:
57+
path: ${{ github.workspace }}/ur-repo/benchmark_results.html
58+
key: benchmark-results-
59+
60+
- name: Move benchmark HTML
61+
# exact or partial cache hit
62+
if: steps.download-bench-html.outputs.cache-hit != ''
63+
run: |
64+
mv ${{ github.workspace }}/ur-repo/benchmark_results.html ${{ github.workspace }}/docs/html/
4965
5066
- name: Upload artifact
5167
uses: actions/upload-pages-artifact@0252fc4ba7626f0298f0cf00902a25c6afc77fa8 # v3.0.0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/oneapi-src/unified-runtime/badge)](https://securityscorecards.dev/viewer/?uri=github.com/oneapi-src/unified-runtime)
99
[![Trivy](https://github.com/oneapi-src/unified-runtime/actions/workflows/trivy.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/trivy.yml)
1010
[![Deploy documentation to Pages](https://github.com/oneapi-src/unified-runtime/actions/workflows/docs.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/docs.yml)
11+
[![Compute Benchmarks Nightly](https://github.com/oneapi-src/unified-runtime/actions/workflows/benchmarks-nightly.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/benchmarks-nightly.yml)
1112

1213
<!-- TODO: add general description and purpose of the project -->
1314

scripts/benchmarks/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ By default, the benchmark results are not stored. To store them, use the option
3737

3838
To compare a benchmark run with a previously stored result, use the option `--compare <name>`. You can compare with more than one result.
3939

40-
If no `--compare` option is specified, the benchmark run is compared against a previously stored `baseline`. This baseline is **not** automatically updated. To update it, use the `--save baseline` option.
41-
The recommended way of updating the baseline is running the benchmarking
42-
job on main after a merge of relevant changes.
40+
If no `--compare` option is specified, the benchmark run is compared against a previously stored `baseline`.
41+
42+
Baseline, as well as baseline-v2 (for the level-zero adapter v2) is updated automatically during a nightly job. The results
43+
are stored [here](https://oneapi-src.github.io/unified-runtime/benchmark_results.html).
4344

4445
## Requirements
4546

scripts/benchmarks/benches/SobelFilter.py

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

scripts/benchmarks/benches/base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ def __init__(self, directory):
2020
def get_adapter_full_path():
2121
for libs_dir_name in ['lib', 'lib64']:
2222
adapter_path = os.path.join(
23-
options.ur_dir, libs_dir_name, f"libur_adapter_{options.ur_adapter_name}.so")
23+
options.ur, libs_dir_name, f"libur_adapter_{options.ur_adapter}.so")
2424
if os.path.isfile(adapter_path):
2525
return adapter_path
2626
assert False, \
2727
f"could not find adapter file {adapter_path} (and in similar lib paths)"
2828

2929
def run_bench(self, command, env_vars):
3030
env_vars_with_forced_adapter = env_vars.copy()
31-
env_vars_with_forced_adapter.update(
32-
{'UR_ADAPTERS_FORCE_LOAD': Benchmark.get_adapter_full_path()})
31+
if options.ur is not None:
32+
env_vars_with_forced_adapter.update(
33+
{'UR_ADAPTERS_FORCE_LOAD': Benchmark.get_adapter_full_path()})
34+
3335
return run(
3436
command=command,
3537
env_vars=env_vars_with_forced_adapter,
@@ -76,3 +78,10 @@ def run(self, env_vars) -> list[Result]:
7678

7779
def teardown(self):
7880
raise NotImplementedError()
81+
82+
class Suite:
83+
def benchmarks(self) -> list[Benchmark]:
84+
raise NotImplementedError()
85+
86+
def setup(self):
87+
return

scripts/benchmarks/benches/bitcracker.py

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

0 commit comments

Comments
 (0)