forked from MFlowCode/MFC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprebuild-case-optimization.sh
More file actions
executable file
·46 lines (38 loc) · 1.61 KB
/
prebuild-case-optimization.sh
File metadata and controls
executable file
·46 lines (38 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Pre-builds all benchmark cases with --case-optimization using --dry-run so
# binaries are cached before the GPU run job. No simulation is executed.
# Can run in two modes:
# 1. Direct (Frontier login nodes): pass cluster/device/interface as args
# 2. Inside SLURM (Phoenix/frontier_amd): uses $job_device/$job_interface
# Usage: bash prebuild-case-optimization.sh [<cluster> <device> <interface>]
set -e
# Support both positional args (direct invocation) and env vars (SLURM)
cluster="${1:-${job_cluster:-phoenix}}"
job_device="${2:-$job_device}"
job_interface="${3:-$job_interface}"
# Derive module flag from cluster name
case "$cluster" in
phoenix) flag="p" ;;
frontier) flag="f" ;;
frontier_amd) flag="famd" ;;
*) echo "ERROR: Unknown cluster '$cluster'"; exit 1 ;;
esac
# Phoenix starts fresh (no prior dep build); other clusters pre-build deps via
# build.sh first, so we must preserve them and only clean MFC target staging.
if [ "$cluster" = "phoenix" ]; then
source .github/scripts/clean-build.sh
clean_build
else
find build/staging -maxdepth 1 -regex '.*/[0-9a-f]+' -type d -exec rm -rf {} + 2>/dev/null || true
find build/install -maxdepth 1 -regex '.*/[0-9a-f]+' -type d -exec rm -rf {} + 2>/dev/null || true
fi
. ./mfc.sh load -c "$flag" -m g
case "$job_interface" in
acc) gpu_opts="--gpu acc" ;;
omp) gpu_opts="--gpu mp" ;;
*) echo "ERROR: prebuild requires gpu interface (acc or omp)"; exit 1 ;;
esac
for case in benchmarks/*/case.py; do
echo "=== Pre-building: $case ==="
./mfc.sh run "$case" --case-optimization $gpu_opts -j 8 --dry-run
done