Skip to content

Commit eaaecee

Browse files
[Bench][CI] allow custom Compute Runtime from PRs
1 parent 1b8e108 commit eaaecee

File tree

5 files changed

+90
-27
lines changed

5 files changed

+90
-27
lines changed

.github/workflows/sycl-linux-run-tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ on:
137137
type: string
138138
required: False
139139
default: '0'
140+
benchmark_custom_cr:
141+
description: |
142+
Custom Compute Runtime to use in benchmarks.
143+
type: string
144+
required: False
145+
default: ''
140146

141147
in_workflow_call_mode:
142148
description: |
@@ -369,3 +375,4 @@ jobs:
369375
build_ref: ${{ inputs.repo_ref }}
370376
runner: ${{ inputs.runner }}
371377
gdb_mode: ${{ inputs.benchmark_gdb_mode }}
378+
custom_cr: ${{ inputs.benchmark_custom_cr }}

.github/workflows/sycl-ur-perf-benchmarking.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ on:
9595
- '0'
9696
- '1'
9797
default: '0'
98+
custom_cr:
99+
description: Custom Compute Runtime to use in benchmarks.
100+
type: string
101+
required: false
102+
default: ''
98103

99104
concurrency:
100105
# Cancel a currently running workflow for:
@@ -119,6 +124,7 @@ jobs:
119124
COMMIT_HASH: ${{ inputs.commit_hash }}
120125
PR_NO: ${{ inputs.pr_no }}
121126
SAVE_NAME: ${{ inputs.save_name }}
127+
CUSTOM_CR: ${{ inputs.custom_cr }}
122128
outputs:
123129
benchmark_save_name: ${{ steps.sanitize.outputs.benchmark_save_name }}
124130
build_ref: ${{ steps.sanitize.outputs.build_ref }}
@@ -140,6 +146,10 @@ jobs:
140146
validate_if_nonempty "$SAVE_NAME" '^[A-Za-z][A-Za-z0-9_-]+$' "Bad save name. Use only alphanumerics, dash, underscore, and start with a letter."
141147
validate_if_nonempty "$SAVE_NAME" '^(?![Bb]+aseline$)' "Save name cannot be 'Baseline' nor 'baseline' - it's reserved for nightly."
142148
149+
# Just validate, don't output this var. We pass unquoted string via inputs.custom_cr, as we actually
150+
# quote it within the benchmark's action. Double quoting can produce unexpected issues.
151+
validate_if_nonempty "$CUSTOM_CR" '^[A-Za-z0-9._/-]+$' "Custom Compute Runtime can be either a proper git ref or 'PR_<no.>'."
152+
143153
BENCHMARK_SAVE_NAME=""
144154
BUILD_REF="$GITHUB_REF"
145155
if [ -n "$SAVE_NAME" ]; then
@@ -206,6 +216,7 @@ jobs:
206216
benchmark_preset: ${{ inputs.preset }}
207217
benchmark_exit_on_failure: ${{ inputs.exit_on_failure }}
208218
benchmark_gdb_mode: ${{ inputs.gdb_mode }}
219+
benchmark_custom_cr: ${{ inputs.custom_cr }}
209220
repo_ref: ${{ needs.sanitize_inputs_dispatch.outputs.build_ref }}
210221
toolchain_artifact: ${{ needs.build_sycl_dispatch.outputs.toolchain_artifact }}
211222
toolchain_artifact_filename: ${{ needs.build_sycl_dispatch.outputs.toolchain_artifact_filename }}

devops/actions/run-tests/benchmark/action.yml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ inputs:
4343
runner:
4444
type: string
4545
required: True
46+
# It can be either a tag/branch/commit or a PR_<number>.
47+
# If the latter is given, latest IGC release will be installed from debs.
48+
# This assumes that the PR changes were based on the latest compute_runtime version.
49+
custom_cr:
50+
type: string
51+
required: False
52+
default: ""
4653

4754
runs:
4855
# composite actions don't make use of 'name', so copy-paste steps' names as a comment in the first line of each step
@@ -164,6 +171,17 @@ runs:
164171
165172
BENCHMARK_RESULTS_REPO_PATH="$(realpath ./llvm-ci-perf-results)"
166173
echo "BENCHMARK_RESULTS_REPO_PATH=$BENCHMARK_RESULTS_REPO_PATH" >> $GITHUB_OUTPUT
174+
175+
CR_BUILD_REF=""
176+
if [ -n "${{ inputs.custom_cr }}" ] && [[ "${{ inputs.custom_cr }}" == PR_* ]]; then
177+
pr_no="$(echo "${{ inputs.custom_cr }}" | sed 's/PR_//')"
178+
CR_BUILD_REF="refs/pull/$pr_no/head"
179+
echo "Using custom compute runtime ref: ${CR_BUILD_REF}"
180+
elif [ -n "${{ inputs.custom_cr }}" ]; then
181+
CR_BUILD_REF="${{ inputs.custom_cr }}"
182+
echo "Using custom compute runtime ref: ${CR_BUILD_REF}"
183+
fi
184+
echo "CR_BUILD_REF=$CR_BUILD_REF" >> $GITHUB_OUTPUT
167185
- name: Checkout results repo
168186
uses: actions/checkout@v5
169187
with:
@@ -221,18 +239,10 @@ runs:
221239
shell: bash
222240
env:
223241
RUNNER_TAG: ${{ inputs.runner }}
242+
GITHUB_TOKEN: ${{ github.token }}
243+
CR_BUILD_REF: ${{ steps.establish_outputs.outputs.CR_BUILD_REF }}
224244
run: |
225245
# Install dependencies
226-
227-
echo "::group::use_compute_runtime_tag_cache"
228-
229-
# Cache the compute_runtime version from dependencies.json, but perform a
230-
# check with L0 version before using it: This value is not guaranteed to
231-
# accurately reflect the current compute_runtime version used, as the
232-
# docker images are built nightly.
233-
export COMPUTE_RUNTIME_TAG_CACHE="$(cat ./devops/dependencies.json | jq -r .linux.compute_runtime.github_tag)"
234-
235-
echo "::endgroup::"
236246
echo "::group::install_perf"
237247
238248
# Install perf in version matching the host kernel.
@@ -248,6 +258,38 @@ runs:
248258
sudo apt-get update
249259
sudo apt-get install -y linux-tools-$(uname -r)
250260
261+
echo "::endgroup::"
262+
echo "::group::install_igc"
263+
264+
# If a custom compute_runtime tag is provided and it points to a PR,
265+
# install latest IGC release from debs.
266+
echo "CR_BUILD_REF='${CR_BUILD_REF}'"
267+
if [[ "${CR_BUILD_REF}" != "" ]] && [[ "${CR_BUILD_REF}" == refs/pull/* ]]; then
268+
# Find latest IGC release, download debs, and install them
269+
curl --request GET \
270+
--url https://api.github.com/repos/intel/intel-graphics-compiler/releases/latest \
271+
--header "Authorization: Bearer ${GITHUB_TOKEN}" \
272+
--header "X-GitHub-Api-Version: 2022-11-28" > latest_igc_release.json
273+
274+
IGC_CORE_DEB_URL=$(cat latest_igc_release.json | jq -r '.assets[] | select(.name | test("intel-igc-core-[0-9]+.*amd64.deb")) | .browser_download_url')
275+
IGC_CORE_DEVEL_DEB_URL=$(cat latest_igc_release.json | jq -r '.assets[] | select(.name | test("intel-igc-core-devel_[0-9]+.*amd64.deb")) | .browser_download_url')
276+
echo "IGC_CORE_DEB_URL=$IGC_CORE_DEB_URL"
277+
echo "IGC_CORE_DEVEL_DEB_URL=$IGC_CORE_DEVEL_DEB_URL"
278+
279+
mkdir neo_debs || true
280+
cd neo_debs
281+
wget -q "$IGC_CORE_DEB_URL"
282+
wget -q "$IGC_CORE_DEVEL_DEB_URL"
283+
sudo dpkg -i --force-all *.deb
284+
cd ..
285+
elif [[ "${CR_BUILD_REF}" == "" ]]; then
286+
# Cache the compute_runtime version from dependencies.json, but perform a
287+
# check with L0 version before using it: This value is not guaranteed to
288+
# accurately reflect the current compute_runtime version used, as the
289+
# docker images are built nightly.
290+
export COMPUTE_RUNTIME_TAG_CACHE="$(cat ./devops/dependencies.json | jq -r .linux.compute_runtime.github_tag)"
291+
fi
292+
251293
echo "::endgroup::"
252294
echo "::group::install_python_deps"
253295
@@ -272,6 +314,7 @@ runs:
272314
BENCH_WORKDIR: ${{ steps.establish_outputs.outputs.BENCH_WORKDIR }}
273315
BENCHMARK_RESULTS_REPO_PATH: ${{ steps.establish_outputs.outputs.BENCHMARK_RESULTS_REPO_PATH }}
274316
LLVM_BENCHMARKS_USE_GDB: ${{ inputs.gdb_mode }}
317+
CR_BUILD_REF: ${{ steps.establish_outputs.outputs.CR_BUILD_REF }}
275318
run: |
276319
# Build and run benchmarks
277320
@@ -298,6 +341,7 @@ runs:
298341
--timestamp-override "$SAVE_TIMESTAMP" \
299342
--detect-version sycl,compute_runtime \
300343
--produce-github-summary \
344+
${{ env.CR_BUILD_REF != '' && format('--compute-runtime {0}', env.CR_BUILD_REF) || '' }} \
301345
${{ inputs.exit_on_failure == 'true' && '--exit-on-failure --iterations 1' || '' }}
302346
# TODO: add back: "--flamegraph inclusive" once works properly
303347

devops/scripts/benchmarks/git_project.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2025 Intel Corporation
1+
# Copyright (C) 2025-2026 Intel Corporation
22
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -120,54 +120,55 @@ def _can_shallow_clone_ref(self, ref: str) -> bool:
120120
if output:
121121
# Found the ref as a branch or tag
122122
log.debug(
123-
f"Ref {ref} found as branch/tag via ls-remote, can shallow clone"
123+
f"Ref '{ref}' found as branch/tag via ls-remote, can shallow clone"
124124
)
125125
return True
126126
else:
127-
# Not found as branch/tag, likely a SHA commit
127+
# Not found as branch/tag, likely a SHA commit or a special ref
128128
log.debug(
129-
f"Ref {ref} not found as branch/tag via ls-remote, likely SHA commit"
129+
f"Ref '{ref}' not found as branch/tag via ls-remote, likely SHA commit or a special ref"
130130
)
131131
return False
132132
except Exception as e:
133133
log.debug(
134-
f"Could not check ref {ref} via ls-remote: {e}, assuming SHA commit"
134+
f"Could not check ref '{ref}' via ls-remote: {e}, assuming SHA commit"
135135
)
136136
return False
137137

138138
def _git_clone(self) -> None:
139139
"""Clone the git repository."""
140140
try:
141-
log.debug(f"Cloning {self._url} into {self.src_dir} at commit {self._ref}")
142-
git_clone_cmd = f"git clone --recursive {self._url} {self.src_dir}"
141+
log.debug(f"Cloning {self._url} into {self.src_dir} at ref {self._ref}")
142+
git_clone_cmd = f"git clone --recursive --depth 1 {self._url} {self.src_dir}"
143143
if self._shallow_clone:
144144
if self._can_shallow_clone_ref(self._ref):
145145
# Shallow clone for branches and tags only
146146
git_clone_cmd = f"git clone --recursive --depth 1 --branch {self._ref} {self._url} {self.src_dir}"
147147
else:
148-
log.debug(f"Cannot shallow clone SHA {self._ref}, using full clone")
148+
log.debug(f"Cannot shallow clone ref '{self._ref}', clone default branch")
149149

150150
run(git_clone_cmd)
151-
run(f"git checkout {self._ref}", cwd=self.src_dir)
152-
log.debug(f"Cloned {self._url} into {self.src_dir} at commit {self._ref}")
151+
run(f"git fetch {self._url} {self._ref}", cwd=self.src_dir)
152+
run(f"git checkout FETCH_HEAD", cwd=self.src_dir)
153+
log.debug(f"Cloned {self._url} into {self.src_dir} at ref {self._ref}")
153154
except Exception as e:
154155
log.error(f"Failed to clone repository {self._url}: {e}")
155156
raise
156157

157158
def _git_fetch(self) -> None:
158-
"""Fetch the latest changes from the remote repository."""
159+
"""Fetch the ref from the remote repository."""
159160
try:
160-
log.debug(f"Fetching latest changes for {self._url} in {self.src_dir}")
161-
run("git fetch", cwd=self.src_dir)
161+
log.debug(f"Fetching ref '{self._ref}' for {self._url} in {self.src_dir}")
162162
run("git reset --hard", cwd=self.src_dir)
163-
run(f"git checkout {self._ref}", cwd=self.src_dir)
164-
log.debug(f"Fetched latest changes for {self._url} in {self.src_dir}")
163+
run(f"git fetch {self._url} {self._ref}", cwd=self.src_dir)
164+
run(f"git checkout FETCH_HEAD", cwd=self.src_dir)
165+
log.debug(f"Fetched changes for {self._url} in {self.src_dir}")
165166
except Exception as e:
166167
log.error(f"Failed to fetch updates for repository {self._url}: {e}")
167168
raise
168169

169170
def _setup_repo(self) -> bool:
170-
"""Clone a git repository into a specified directory at a specific commit.
171+
"""Clone a git repository into a specified directory at a specific ref.
171172
Returns:
172173
bool: True if the repository was cloned or updated, False if it was already up-to-date.
173174
"""

devops/scripts/benchmarks/history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def git_info_from_path(path: Path) -> (str, str):
171171
if options.build_compute_runtime:
172172
compute_runtime = options.compute_runtime_tag
173173
elif options.detect_versions.compute_runtime:
174-
log.info("Auto-detecting compute_runtime version...")
174+
log.info(f"Auto-detecting compute_runtime version...")
175175
detect_res = DetectVersion.instance()
176176
compute_runtime = detect_res.get_compute_runtime_ver()
177177
if detect_res.get_compute_runtime_ver_cached() is None:

0 commit comments

Comments
 (0)