Skip to content

Commit 0857ace

Browse files
authored
ci(frontier_amd): build base and chemistry simulation variants concurrently (2 h walltime overrun) (#1662)
1 parent 9635873 commit 0857ace

3 files changed

Lines changed: 49 additions & 6 deletions

File tree

.github/scripts/submit-slurm-job.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@
33
# Submits a script as a SLURM batch job, then monitors it until completion.
44
# Rerun-safe: cancels stale jobs from previous runs before resubmission.
55
#
6-
# Usage: submit-slurm-job.sh <script.sh> <cpu|gpu> <none|acc|omp> <cluster> [shard]
6+
# Usage: submit-slurm-job.sh <script.sh> <cpu|gpu> <none|acc|omp> <cluster> [shard] [variant]
77

88
set -euo pipefail
99

1010
# Ignore SIGHUP to survive login node session drops
1111
trap '' HUP
1212

1313
usage() {
14-
echo "Usage: $0 <script.sh> <cpu|gpu> <none|acc|omp> <cluster> [shard]"
14+
echo "Usage: $0 <script.sh> <cpu|gpu> <none|acc|omp> <cluster> [shard] [variant]"
1515
}
1616

1717
script_path="${1:-}"
1818
device="${2:-}"
1919
interface="${3:-}"
2020
cluster="${4:-}"
2121
shard="${5:-}"
22+
# Build variant ("base"/"chem"), letting one build job be split into concurrent
23+
# per-variant jobs. Empty = build everything in this job (default).
24+
variant="${6:-}"
2225

2326
if [ -z "$script_path" ] || [ -z "$device" ] || [ -z "$interface" ] || [ -z "$cluster" ]; then
2427
usage
@@ -136,7 +139,12 @@ shard_suffix=""
136139
if [ -n "$shard" ]; then
137140
shard_suffix="-$(echo "$shard" | sed 's|/|-of-|')"
138141
fi
139-
job_slug="$(basename "$script_path" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g')-${device}-${interface}${shard_suffix}"
142+
variant_suffix=""
143+
if [ -n "$variant" ]; then
144+
# Sanitized like the rest of the slug: these become file names in the workspace.
145+
variant_suffix="-$(echo "$variant" | sed 's/[^a-zA-Z0-9]/-/g')"
146+
fi
147+
job_slug="$(basename "$script_path" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g')-${device}-${interface}${shard_suffix}${variant_suffix}"
140148
output_file="$job_slug.out"
141149
id_file="${job_slug}.slurm_job_id"
142150

@@ -187,6 +195,7 @@ job_slug="$job_slug"
187195
job_device="$device"
188196
job_interface="$interface"
189197
job_shard="$shard"
198+
job_variant="$variant"
190199
job_cluster="$cluster"
191200
export GITHUB_EVENT_NAME="$GITHUB_EVENT_NAME"
192201

.github/workflows/common/build.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,20 @@ if [ "$job_cluster" = "phoenix" ]; then
3939
validate_cmd='syscheck_bin=$(find build/install -name syscheck -type f 2>/dev/null | head -1); [ -z "$syscheck_bin" ] || "$syscheck_bin" > /dev/null 2>&1'
4040
fi
4141

42+
# --- Variant selection ---
43+
# The suite needs two simulation binaries: the base one and a chemistry one (the
44+
# mechanism is compiled in). On amdflang each device link is ~1 hour, so building
45+
# both serially exceeds the 2 h walltime. $job_variant lets the caller split them
46+
# into concurrent jobs that write to disjoint staging directories:
47+
# base -> plain targets, what every non-chemistry test runs
48+
# chem -> the chemistry variant only
49+
# Unset builds everything in this job (default for every other cluster).
50+
case "${job_variant:-}" in
51+
base) build_cmd=(./mfc.sh build -j 8 $build_opts) ;;
52+
chem) build_cmd=(./mfc.sh test -v --dry-run -a -j 8 -o Chemistry $build_opts) ;;
53+
"") build_cmd=(./mfc.sh test -v --dry-run -a -j 8 $build_opts) ;;
54+
*) echo "ERROR: unknown job_variant '$job_variant'"; exit 1 ;;
55+
esac
56+
4257
RETRY_VALIDATE_CMD="$validate_cmd" \
43-
retry_build ./mfc.sh test -v --dry-run -a -j 8 $build_opts || exit 1
58+
retry_build "${build_cmd[@]}" || exit 1

.github/workflows/test.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,25 @@ jobs:
431431
run: bash .github/workflows/${{ matrix.cluster }}/build.sh ${{ matrix.device }} ${{ matrix.interface }}
432432

433433
- name: Build
434+
if: ${{ !(matrix.cluster == 'frontier_amd' && matrix.device == 'gpu') }}
434435
run: bash .github/scripts/submit-slurm-job.sh .github/workflows/common/build.sh ${{ matrix.device }} ${{ matrix.interface }} ${{ matrix.cluster }} ${{ matrix.shard }}
435436

437+
- name: Build (concurrent variants)
438+
if: matrix.cluster == 'frontier_amd' && matrix.device == 'gpu'
439+
# The suite needs a base and a chemistry simulation binary, and on amdflang
440+
# each device LTO link is ~1 h -- building both serially overruns the 2 h
441+
# walltime. They touch disjoint staging directories, so submit one SLURM job
442+
# per variant and wait on both (mirrors the case-optimization pre-build).
443+
run: |
444+
pids=""
445+
for v in base chem; do
446+
bash .github/scripts/submit-slurm-job.sh .github/workflows/common/build.sh ${{ matrix.device }} ${{ matrix.interface }} ${{ matrix.cluster }} "${{ matrix.shard }}" "$v" &
447+
pids="$pids $!"
448+
done
449+
rc=0
450+
for p in $pids; do wait "$p" || rc=1; done
451+
exit $rc
452+
436453
- name: Test
437454
run: bash .github/scripts/submit-slurm-job.sh .github/workflows/common/test.sh ${{ matrix.device }} ${{ matrix.interface }} ${{ matrix.cluster }} ${{ matrix.shard }}
438455

@@ -460,7 +477,9 @@ jobs:
460477
- name: Print Logs
461478
if: always()
462479
run: |
463-
for f in ${{ steps.log.outputs.build_slug }}.out ${{ steps.log.outputs.test_slug }}.out; do
480+
# The build slug matches the plain log and, where the build is split per
481+
# variant, the build-...-base/-chem ones.
482+
for f in ${{ steps.log.outputs.build_slug }}*.out ${{ steps.log.outputs.test_slug }}.out; do
464483
[ -f "$f" ] && echo "=== $f ===" && cat "$f"
465484
done
466485
@@ -470,7 +489,7 @@ jobs:
470489
with:
471490
name: logs-${{ strategy.job-index }}-${{ steps.log.outputs.test_slug }}
472491
path: |
473-
${{ steps.log.outputs.build_slug }}.out
492+
${{ steps.log.outputs.build_slug }}*.out
474493
${{ steps.log.outputs.test_slug }}.out
475494
476495
case-optimization:

0 commit comments

Comments
 (0)