Skip to content

Commit ae8f3d6

Browse files
committed
libm: Run benchmarks on aarch64 as well as x86-64
1 parent 11cf244 commit ae8f3d6

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

.github/workflows/main.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,16 @@ jobs:
195195

196196
benchmarks:
197197
name: Benchmarks
198-
runs-on: ubuntu-24.04
199198
timeout-minutes: 20
199+
strategy:
200+
fail-fast: false
201+
matrix:
202+
include:
203+
- target: aarch64-unknown-linux-gnu
204+
os: ubuntu-24.04-arm
205+
- target: x86_64-unknown-linux-gnu
206+
os: ubuntu-24.04
207+
runs-on: ${{ matrix.os }}
200208
steps:
201209
- uses: actions/checkout@master
202210
with:
@@ -215,12 +223,14 @@ jobs:
215223
cargo binstall -y iai-callgrind-runner --version "$iai_version"
216224
sudo apt-get install valgrind
217225
- uses: Swatinem/rust-cache@v2
226+
with:
227+
key: ${{ matrix.target }}
218228

219229
- name: Run icount benchmarks
220230
env:
221231
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222232
PR_NUMBER: ${{ github.event.pull_request.number }}
223-
run: ./ci/bench-icount.sh
233+
run: ./ci/bench-icount.sh ${{ matrix.target }}
224234

225235
- name: Upload the benchmark baseline
226236
uses: actions/upload-artifact@v4

ci/bench-icount.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22

33
set -eux
44

5+
target="${1:-}"
6+
7+
if [ -z "$target" ]; then
8+
host_target=$(rustc -vV | awk '/^host/ { print $2 }')
9+
echo "Defaulted to host target $host_target"
10+
target="$host_target"
11+
fi
12+
513
iai_home="iai-home"
614

15+
# Use the arch as a tag to disambiguate artifacts
16+
tag="$(echo "$target" | cut -d'-' -f1)"
17+
718
# Download the baseline from master
8-
./ci/ci-util.py locate-baseline --download --extract
19+
./ci/ci-util.py locate-baseline --download --extract --tag "$tag"
920

1021
# Run benchmarks once
1122
function run_icount_benchmarks() {
@@ -44,6 +55,7 @@ function run_icount_benchmarks() {
4455
# If this is for a pull request, ignore regressions if specified.
4556
./ci/ci-util.py check-regressions --home "$iai_home" --allow-pr-override "$PR_NUMBER"
4657
else
58+
# Disregard regressions after merge
4759
./ci/ci-util.py check-regressions --home "$iai_home" || true
4860
fi
4961
}
@@ -53,6 +65,6 @@ run_icount_benchmarks --features force-soft-floats -- --save-baseline=softfloat
5365
run_icount_benchmarks -- --save-baseline=hardfloat
5466

5567
# Name and tar the new baseline
56-
name="baseline-icount-$(date -u +'%Y%m%d%H%M')-${GITHUB_SHA:0:12}"
68+
name="baseline-icount-$tag-$(date -u +'%Y%m%d%H%M')-${GITHUB_SHA:0:12}"
5769
echo "BASELINE_NAME=$name" >>"$GITHUB_ENV"
5870
tar cJf "$name.tar.xz" "$iai_home"

ci/ci-util.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
Calculate a matrix of which functions had source change, print that as
2929
a JSON object.
3030
31-
locate-baseline [--download] [--extract]
31+
locate-baseline [--download] [--extract] [--tag TAG]
3232
Locate the most recent benchmark baseline available in CI and, if flags
3333
specify, download and extract it. Never exits with nonzero status if
3434
downloading fails.
3535
36+
`--tag` can be specified to look for artifacts with a specific tag, such as
37+
for a specific architecture.
38+
3639
Note that `--extract` will overwrite files in `iai-home`.
3740
3841
check-regressions [--home iai-home] [--allow-pr-override pr_number]
@@ -50,7 +53,7 @@
5053
GIT = ["git", "-C", REPO_ROOT]
5154
DEFAULT_BRANCH = "master"
5255
WORKFLOW_NAME = "CI" # Workflow that generates the benchmark artifacts
53-
ARTIFACT_GLOB = "baseline-icount*"
56+
ARTIFACT_PREFIX = "baseline-icount*"
5457
# Place this in a PR body to skip regression checks (must be at the start of a line).
5558
REGRESSION_DIRECTIVE = "ci: allow-regressions"
5659
# Place this in a PR body to skip extensive tests
@@ -278,13 +281,17 @@ def locate_baseline(flags: list[str]) -> None:
278281

279282
download = False
280283
extract = False
284+
tag = ""
281285

282286
while len(flags) > 0:
283287
match flags[0]:
284288
case "--download":
285289
download = True
286290
case "--extract":
287291
extract = True
292+
case "--tag":
293+
tag = flags[1]
294+
flags = flags[1:]
288295
case _:
289296
eprint(USAGE)
290297
exit(1)
@@ -333,8 +340,10 @@ def locate_baseline(flags: list[str]) -> None:
333340
eprint("skipping download step")
334341
return
335342

343+
artifact_glob = f"{ARTIFACT_PREFIX}{f"-{tag}" if tag else ""}*"
344+
336345
sp.run(
337-
["gh", "run", "download", str(job_id), f"--pattern={ARTIFACT_GLOB}"],
346+
["gh", "run", "download", str(job_id), f"--pattern={artifact_glob}"],
338347
check=False,
339348
)
340349

@@ -344,7 +353,7 @@ def locate_baseline(flags: list[str]) -> None:
344353

345354
# Find the baseline with the most recent timestamp. GH downloads the files to e.g.
346355
# `some-dirname/some-dirname.tar.xz`, so just glob the whole thing together.
347-
candidate_baselines = glob(f"{ARTIFACT_GLOB}/{ARTIFACT_GLOB}")
356+
candidate_baselines = glob(f"{artifact_glob}/{artifact_glob}")
348357
if len(candidate_baselines) == 0:
349358
eprint("no possible baseline directories found")
350359
return

0 commit comments

Comments
 (0)