Skip to content

Commit 504ca01

Browse files
Merge pull request #1060 from EuphoricThinking/benchmark_p9_11_workflow_review1
add a workflow for running UMF benchmarks
2 parents e31c856 + ccb2156 commit 504ca01

File tree

6 files changed

+202
-181
lines changed

6 files changed

+202
-181
lines changed

.github/workflows/benchmarks.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Compute Benchmarks
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
pr_no:
7+
description: PR number (if 0, it'll run on the main)
8+
type: number
9+
bench_script_params:
10+
description: Parameters passed to script executing benchmark
11+
type: string
12+
required: false
13+
default: ''
14+
upload_report:
15+
description: 'Upload HTML report'
16+
type: boolean
17+
required: false
18+
default: false
19+
20+
permissions:
21+
contents: read
22+
pull-requests: write
23+
24+
jobs:
25+
manual:
26+
name: Compute Benchmarks
27+
uses: ./.github/workflows/reusable_benchmarks.yml
28+
with:
29+
pr_no: ${{ inputs.pr_no }}
30+
bench_script_params: ${{ inputs.bench_script_params }}
31+
upload_report: ${{ inputs.upload_report }}

.github/workflows/nightly.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,13 @@ jobs:
194194
# Beside the 2 LTS Ubuntu, we also test this on the latest Ubuntu - to be updated
195195
# every 6 months, so we verify the latest version of packages (compilers, etc.).
196196
os: "['ubuntu-22.04', 'ubuntu-24.04', 'ubuntu-24.10']"
197+
198+
Benchmarks:
199+
uses: ./.github/workflows/reusable_benchmarks.yml
200+
permissions:
201+
contents: read
202+
pull-requests: write
203+
with:
204+
pr_no: '0'
205+
bench_script_params: ''
206+
upload_report: true

.github/workflows/performance.yml

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

.github/workflows/pr_push.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ jobs:
5454
uses: ./.github/workflows/reusable_qemu.yml
5555
with:
5656
short_run: true
57-
Benchmarks:
58-
needs: [Build]
59-
uses: ./.github/workflows/reusable_benchmarks.yml
6057
ProxyLib:
6158
needs: [Build]
6259
uses: ./.github/workflows/reusable_proxy_lib.yml
Lines changed: 146 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,163 @@
11
# Executes benchmarks implemented in this repository
2+
# using scripts for benchmark results visualisation,
3+
# which are downloaded from Unified Runtime repository.
24
name: Benchmarks
35

4-
on: workflow_call
6+
on:
7+
workflow_call:
8+
inputs:
9+
pr_no:
10+
# even though this is a number, this is a workaround for issues with
11+
# reusable workflow calls that result in "Unexpected value '0'" error.
12+
type: string
13+
default: '0'
14+
bench_script_params:
15+
required: false
16+
type: string
17+
default: ''
18+
upload_report:
19+
required: false
20+
type: boolean
21+
default: false
522

623
permissions:
724
contents: read
25+
pull-requests: write
826

927
env:
10-
BUILD_DIR : "${{github.workspace}}/build"
11-
INSTL_DIR : "${{github.workspace}}/../install-dir"
28+
UMF_DIR: "${{github.workspace}}/umf-repo"
29+
BUILD_DIR : "${{github.workspace}}/umf-repo/build"
1230

1331
jobs:
1432
benchmarks:
1533
name: Benchmarks
16-
env:
17-
VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows"
1834
strategy:
1935
matrix:
20-
os: ['ubuntu-latest', 'windows-latest']
21-
include:
22-
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command to determine the build type
23-
- os: ubuntu-latest
24-
extra_build_option: '-DCMAKE_BUILD_TYPE=Release'
36+
os: ['ubuntu-latest']
2537
runs-on: ${{matrix.os}}
2638

2739
steps:
28-
- name: Checkout
29-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
30-
with:
31-
fetch-depth: 0
32-
33-
- name: Install apt packages
34-
if: matrix.os == 'ubuntu-latest'
35-
run: |
36-
sudo apt-get update
37-
sudo apt-get install -y cmake libhwloc-dev libnuma-dev libtbb-dev
38-
39-
- name: Initialize vcpkg
40-
if: matrix.os == 'windows-latest'
41-
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
42-
with:
43-
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
44-
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
45-
vcpkgJsonGlob: '**/vcpkg.json'
46-
47-
- name: Install vcpkg packages
48-
if: matrix.os == 'windows-latest'
49-
run: vcpkg install
50-
shell: pwsh # Specifies PowerShell as the shell for running the script.
51-
52-
- name: Configure build
53-
run: >
54-
cmake
55-
-B ${{env.BUILD_DIR}}
56-
${{matrix.extra_build_option}}
57-
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
58-
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
59-
-DUMF_BUILD_SHARED_LIBRARY=ON
60-
-DUMF_BUILD_BENCHMARKS=ON
61-
-DUMF_BUILD_BENCHMARKS_MT=ON
62-
-DUMF_BUILD_TESTS=OFF
63-
-DUMF_FORMAT_CODE_STYLE=OFF
64-
-DUMF_DEVELOPER_MODE=OFF
65-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
66-
-DUMF_BUILD_CUDA_PROVIDER=ON
67-
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
68-
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
69-
70-
- name: Build UMF on Linux
71-
if: matrix.os == 'ubuntu-latest'
72-
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
73-
74-
- name: Build UMF on Windows
75-
if: matrix.os == 'windows-latest'
76-
run: cmake --build ${{env.BUILD_DIR}} --config Release -j $Env:NUMBER_OF_PROCESSORS
77-
78-
- name: Run benchmarks
79-
working-directory: ${{env.BUILD_DIR}}
80-
run: ctest -V --test-dir benchmark -C Release
40+
# Workspace on self-hosted runners is not cleaned automatically.
41+
# We have to delete the files created outside of using actions.
42+
- name: Cleanup self-hosted workspace
43+
if: always()
44+
run: |
45+
ls -la ./
46+
rm -rf ./* || true
47+
48+
- name: Add comment to PR
49+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
50+
if: ${{ always() && inputs.pr_no != 0 }}
51+
with:
52+
script: |
53+
const pr_no = '${{ inputs.pr_no }}';
54+
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
55+
const params = '${{ inputs.bench_script_params }}';
56+
const body = `Compute Benchmarks run (with params: ${params}):\n${url}`;
57+
58+
github.rest.issues.createComment({
59+
issue_number: pr_no,
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
body: body
63+
})
64+
65+
- name: Checkout UMF
66+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
67+
with:
68+
path: ${{env.UMF_DIR}}
69+
fetch-depth: 0
70+
71+
# We need to fetch special ref for proper PR's merge commit. Note, this ref may be absent if the PR is already merged.
72+
- name: Fetch PR's merge commit
73+
if: ${{ inputs.pr_no != 0 }}
74+
working-directory: ${{env.UMF_DIR}}
75+
env:
76+
PR_NO: ${{ inputs.pr_no }}
77+
run: |
78+
git fetch -- https://github.com/${{github.repository}} +refs/pull/${PR_NO}/*:refs/remotes/origin/pr/${PR_NO}/*
79+
git checkout origin/pr/${PR_NO}/merge
80+
git rev-parse origin/pr/${PR_NO}/merge
81+
82+
- name: Install apt packages
83+
run: |
84+
sudo apt-get update
85+
sudo apt-get install -y cmake libhwloc-dev libnuma-dev libtbb-dev
86+
87+
- name: Configure build
88+
run: >
89+
cmake
90+
-S ${{env.UMF_DIR}}
91+
-B ${{env.BUILD_DIR}}
92+
-DCMAKE_BUILD_TYPE=Release
93+
-DUMF_BUILD_SHARED_LIBRARY=ON
94+
-DUMF_BUILD_BENCHMARKS=ON
95+
-DUMF_BUILD_BENCHMARKS_MT=ON
96+
-DUMF_BUILD_TESTS=OFF
97+
-DUMF_FORMAT_CODE_STYLE=OFF
98+
-DUMF_DEVELOPER_MODE=OFF
99+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
100+
-DUMF_BUILD_CUDA_PROVIDER=ON
101+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
102+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
103+
-DUMF_BUILD_EXAMPLES=OFF
104+
105+
- name: Build UMF
106+
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
107+
108+
# We are going to clone Unified Runtime repository in order to run
109+
# the most up-to-date UR scripts for benchmark data visualisation
110+
- name: Checkout UR
111+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
112+
with:
113+
repository: oneapi-src/unified-runtime
114+
path: ur-repo
115+
fetch-depth: 1
116+
fetch-tags: false
117+
118+
- name: Install pip packages for benchmarking scripts from UR
119+
run: |
120+
pip install --force-reinstall -r ${{github.workspace}}/ur-repo/third_party/benchmark_requirements.txt
121+
122+
- name: Run dedicated for UMF benchmarking scripts from UR
123+
id: benchmarks
124+
working-directory: ${{env.BUILD_DIR}}
125+
run: >
126+
${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py
127+
~/bench_workdir
128+
--umf ${{env.BUILD_DIR}}
129+
${{ inputs.upload_report && '--output-html' || '' }}
130+
${{ inputs.bench_script_params }}
131+
132+
- name: Add comment to PR
133+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
134+
if: ${{ always() && inputs.pr_no != 0 }}
135+
with:
136+
script: |
137+
let markdown = ""
138+
try {
139+
const fs = require('fs');
140+
markdown = fs.readFileSync('${{env.BUILD_DIR}}/benchmark_results.md', 'utf8');
141+
} catch(err) {
142+
}
143+
144+
const pr_no = '${{ inputs.pr_no }}';
145+
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
146+
const test_status = '${{ steps.benchmarks.outcome }}';
147+
const job_status = '${{ job.status }}';
148+
const params = '${{ inputs.bench_script_params }}';
149+
const body = `Compute Benchmarks run (${params}):\n${url}\nJob status: ${job_status}. Test status: ${test_status}.\n ${markdown}`;
150+
151+
github.rest.issues.createComment({
152+
issue_number: pr_no,
153+
owner: context.repo.owner,
154+
repo: context.repo.repo,
155+
body: body
156+
})
157+
158+
- name: Upload HTML report
159+
if: ${{ always() && inputs.upload_report }}
160+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
161+
with:
162+
path: ${{env.BUILD_DIR}}/benchmark_results.html
163+
key: benchmark-results-${{ github.run_id }}

0 commit comments

Comments
 (0)