@@ -22,34 +22,16 @@ case "$cluster" in
2222 * ) echo " ERROR: Unknown cluster '$cluster '" ; exit 1 ;;
2323esac
2424
25- # Optional sharding (format "i/N", e.g. "1/2"), set by submit-slurm-job.sh's
26- # [shard] argument via $job_shard: shard i builds every Nth case of the sorted
27- # case list. Unset = build all cases in one job (default; other clusters).
25+ # Benchmark list + optional sharding ("i/N", e.g. "1/3", set by
26+ # submit-slurm-job.sh's [shard] argument via $job_shard): shard i builds every
27+ # Nth case of the shared list. Unset = build all cases in one job (default;
28+ # other clusters). The list is the single source of truth shared with
29+ # run_case_optimization.sh so pre-built binaries and run cases never drift.
30+ source .github/scripts/case-optimization-benchmarks.sh
31+ caseopt_parse_shard
2832shard=" ${job_shard:- } "
29- if [ -n " $shard " ]; then
30- # Validate full shape: must be exactly "digits/digits" — one slash with
31- # non-empty, purely numeric, non-leading-zero parts on both sides.
32- # Split first, then validate each part independently so that inputs like
33- # "1/" "/2" "//" "1/2/3" "a/b" "12" are all caught before any arithmetic.
34- shard_idx=" ${shard%%/* } "
35- shard_count=" ${shard##*/ } "
36- # Reject if no slash (idx and count are equal and equal to the whole string)
37- case " $shard_idx " in
38- ' ' |* [!0-9]* |0* ) echo " ERROR: bad shard '$shard ' (expected i/N)" ; exit 1 ;;
39- esac
40- case " $shard_count " in
41- ' ' |* [!0-9]* |0* ) echo " ERROR: bad shard '$shard ' (expected i/N)" ; exit 1 ;;
42- esac
43- # Confirm the string is exactly "idx/count" — catches "12" (no slash) and
44- # "1/2/3" (extra slash, where idx=1 and count=2/3 would have failed above,
45- # but this is an extra safety net).
46- if [ " $shard " != " $shard_idx /$shard_count " ]; then
47- echo " ERROR: bad shard '$shard ' (expected i/N)" ; exit 1
48- fi
49- if [ " $shard_idx " -lt 1 ] || [ " $shard_idx " -gt " $shard_count " ]; then
50- echo " ERROR: bad shard '$shard ' (expected i/N with 1 <= i <= N)" ; exit 1
51- fi
52- fi
33+ shard_idx=" $caseopt_shard_idx "
34+ shard_count=" $caseopt_shard_count "
5335
5436# Phoenix starts fresh (no prior dep build); other clusters pre-build deps via
5537# build.sh first, so we must preserve them and only clean MFC target staging.
@@ -60,8 +42,8 @@ if [ "$cluster" = "phoenix" ]; then
6042 source .github/scripts/clean-build.sh
6143 clean_build
6244elif [ -z " $shard " ]; then
63- find build/staging -maxdepth 1 -regex ' .*/[0-9a-f]+ ' -type d -exec rm -rf {} + 2> /dev/null || true
64- find build/install -maxdepth 1 -regex ' .*/[0-9a-f]+ ' -type d -exec rm -rf {} + 2> /dev/null || true
45+ find build/staging -maxdepth 1 -regex ' .*/\(gpu-acc\|gpu-mp\|cpu\)-.* ' -type d -exec rm -rf {} + 2> /dev/null || true
46+ find build/install -maxdepth 1 -regex ' .*/\(gpu-acc\|gpu-mp\|cpu\)-.* ' -type d -exec rm -rf {} + 2> /dev/null || true
6547fi
6648
6749. ./mfc.sh load -c " $flag " -m g
8062if [ -n " $shard " ] && [ " $shard_count " -gt 1 ]; then
8163 shared_marker_done=" build/.prebuild-shared-targets-done"
8264 shared_marker_failed=" build/.prebuild-shared-targets-failed"
83- set -- benchmarks/* /case.py
84- first_case=" $1 "
65+ first_case=" ${benchmarks[0]} "
8566 if [ " $shard_idx " -eq 1 ]; then
8667 # Remove both markers at the start so reruns and manual invocations
8768 # never observe stale state from a prior run.
@@ -110,11 +91,9 @@ if [ -n "$shard" ] && [ "$shard_count" -gt 1 ]; then
11091fi
11192
11293idx=0
113- for case in benchmarks/ * /case.py ; do
94+ for case in " ${ benchmarks[@]} " ; do
11495 idx=$(( idx + 1 ))
115- if [ -n " $shard " ] && [ $(( (idx - 1 ) % shard_count)) -ne $(( shard_idx - 1 )) ]; then
116- continue
117- fi
96+ caseopt_case_in_shard " $idx " || continue
11897 echo " === Pre-building: $case ==="
11998 ./mfc.sh run " $case " --case-optimization $gpu_opts -j 8 --dry-run
12099done
0 commit comments