Skip to content

Commit a6f4a18

Browse files
authored
misc: Add benchmark filters to manual perf workflow (#787)
Add a specific_benchmarks workflow input and pass it to parallel_sim.sh. Filter workloads in-memory with case-insensitive substring matching. Keep default behavior unchanged when filter is empty. Change-Id: I7686d05c28aca7234aa9357be4d5bdf05d103236
1 parent 68b5340 commit a6f4a18

File tree

3 files changed

+84
-4
lines changed

3 files changed

+84
-4
lines changed

.github/workflows/gem5-perf-template.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ on:
1616
required: true
1717
type: string
1818
description: "Benchmark type: gcc12-spec06-0.3c, gcc12-spec06-0.8c, gcc12-spec06-1.0c, gcc15-spec06-0.3c, gcc15-spec06-0.8c, gcc15-spec06-1.0c, spec17-1.0c, spec06-rvv-1.0c or spec06int-rvv-0.8c"
19+
specific_benchmarks:
20+
required: false
21+
type: string
22+
default: ""
23+
description: "Comma-separated benchmark filters. Empty means run all workloads in checkpoint list."
1924
vector_type:
2025
required: false
2126
type: string
@@ -171,6 +176,7 @@ jobs:
171176
${{ steps.config.outputs.checkpoint_list }} \
172177
${{ steps.config.outputs.checkpoint_root_node}} \
173178
spec_all \
179+
"${{ inputs.specific_benchmarks }}" \
174180
"${{ inputs.extra_args }}"
175181
- name: Setup gem5_data_proc environment
176182
run: |
@@ -244,6 +250,7 @@ jobs:
244250
echo "branch: ${GITHUB_REF#refs/heads/}" >> "$TARGET_DIR/metadata.txt"
245251
echo "run_number: $RUN_NUMBER" >> "$TARGET_DIR/metadata.txt"
246252
echo "benchmark_type: ${{ inputs.benchmark_type }}" >> "$TARGET_DIR/metadata.txt"
253+
echo "specific_benchmarks: ${{ inputs.specific_benchmarks }}" >> "$TARGET_DIR/metadata.txt"
247254
echo "workflow_run_id: ${{ github.run_id }}" >> "$TARGET_DIR/metadata.txt"
248255
249256
# Auto cleanup: keep only last 200 runs for this benchmark type

.github/workflows/manual-perf.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ on:
2727
- spec17-1.0c
2828
- spec06-rvv-1.0c
2929
- spec06int-rvv-0.8c
30+
specific_benchmarks:
31+
description: 'Specific benchmarks to run (comma-separated, eg. "mcf,gcc"), leave empty to run all'
32+
required: false
33+
type: string
34+
default: ''
3035
vector_type:
3136
description: 'Vector decode strategy (only for rvv benchmarks)'
3237
required: false
@@ -64,6 +69,7 @@ jobs:
6469
with:
6570
config_path: ${{ needs.setup.outputs.config_path }}
6671
benchmark_type: ${{ github.event.inputs.benchmark_type }}
72+
specific_benchmarks: ${{ github.event.inputs.specific_benchmarks }}
6773
vector_type: ${{ github.event.inputs.vector_type }}
6874
pr_sha: ${{ needs.setup.outputs.pr_sha }}
6975
check_result: true

util/xs_scripts/parallel_sim.sh

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
function print_help() {
55
printf "Usage:
6-
bash $0 <config_file_or_script> workload_list.lst checkpoint_top_dir task_tag [extra_gem5_args]
6+
bash $0 <config_file_or_script> workload_list.lst checkpoint_top_dir task_tag [benchmark_filters] [extra_gem5_args]
77
88
Arguments:
99
config_file_or_script: Config file (*.py) or wrapper script (*.sh).
1010
If relative, it is resolved relative to the repo root (gem5_home).
1111
workload_list.lst: List of workloads to run
1212
checkpoint_top_dir: Root directory for checkpoints
1313
task_tag: Tag for this experiment
14+
benchmark_filters: Optional comma-separated benchmark filters, case-insensitive.
15+
Empty means no filter (run all workloads in workload_list).
1416
extra_gem5_args: Optional extra arguments for gem5 (only for .py mode)
1517
1618
Examples:
@@ -20,8 +22,14 @@ Examples:
2022
# New mode (using .py config)
2123
bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp
2224
25+
# New mode with benchmark filters
26+
bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp_subset \"mcf,gcc\"
27+
2328
# New mode with extra args
24-
bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp_nosc \"--disable-mgsc\"
29+
bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp_nosc \"\" \"--disable-mgsc\"
30+
31+
# New mode with filters + extra args
32+
bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp_nosc \"mcf,gcc\" \"--disable-mgsc\"
2533
\n"
2634
exit 1
2735
}
@@ -47,17 +55,28 @@ if [[ "$first_param" == *.sh ]]; then
4755
# Legacy mode: using wrapper script
4856
export use_legacy_mode=true
4957
export arch_script="$first_param"
58+
export benchmark_filters="${5:-}" # Optional 5th parameter in legacy mode
5059
echo "Legacy mode: using script $arch_script"
5160
else
5261
# New mode: using config file directly
5362
export use_legacy_mode=false
5463
export config_file="$first_param"
55-
export extra_gem5_args="${5:-}" # Optional 5th parameter
64+
export benchmark_filters="${5:-}" # Optional 5th parameter (new order)
65+
export extra_gem5_args="${6:-}" # Optional 6th parameter (new order)
66+
# Backward compatibility: if only one optional arg and it looks like gem5 args,
67+
# keep treating it as extra_gem5_args.
68+
if [ "$#" -eq 5 ] && [[ "${5}" == -* ]]; then
69+
export extra_gem5_args="${5}"
70+
export benchmark_filters=""
71+
fi
5672
echo "Config mode: using $config_file"
5773
if [ -n "$extra_gem5_args" ]; then
5874
echo "Extra gem5 args: $extra_gem5_args"
5975
fi
6076
fi
77+
if [ -n "${benchmark_filters//[[:space:],]/}" ]; then
78+
echo "Benchmark filters: $benchmark_filters"
79+
fi
6180

6281
# Note 1: workload list contains the workload name, checkpoint path, and parameters, looks like:
6382
# astar_biglakes_122060000000 astar_biglakes_122060000000_0.244818/0/ 0 0 20 20
@@ -80,6 +99,49 @@ export full_work_dir=$ds/$tag # work dir wheter stats data stored
8099
mkdir -p $full_work_dir
81100
ln -sf $full_work_dir . # optional, you can customize it yourself
82101

102+
declare -a filtered_workloads=()
103+
104+
function apply_benchmark_filter() {
105+
if [ -z "${benchmark_filters//[[:space:],]/}" ]; then
106+
echo "No benchmark filter provided, run all workloads."
107+
return
108+
fi
109+
110+
mapfile -t filtered_workloads < <(awk -v filters="$benchmark_filters" '
111+
BEGIN {
112+
n = split(filters, raw_filters, ",")
113+
valid = 0
114+
for (i = 1; i <= n; i++) {
115+
token = raw_filters[i]
116+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", token)
117+
token = tolower(token)
118+
if (token != "") {
119+
patterns[++valid] = token
120+
}
121+
}
122+
}
123+
/^[[:space:]]*$/ { next }
124+
{
125+
lower_line = tolower($0)
126+
for (i = 1; i <= valid; i++) {
127+
if (index(lower_line, patterns[i]) > 0) {
128+
print $0
129+
next
130+
}
131+
}
132+
}
133+
' "$workload_list")
134+
135+
local selected_count
136+
selected_count="${#filtered_workloads[@]}"
137+
if [ "$selected_count" -eq 0 ]; then
138+
echo "Error: benchmark_filters '$benchmark_filters' matched no workloads in '$workload_list'"
139+
exit 1
140+
fi
141+
142+
echo "Applied benchmark filters: '$benchmark_filters' -> $selected_count workloads selected."
143+
}
144+
83145
check() {
84146
if [ $1 -ne 0 ]; then
85147
echo FAIL
@@ -176,7 +238,12 @@ num_threads=${xsgem5_para_jobs:-63}
176238
function parallel_run() {
177239
# We use gnu parallel to control the parallelism.
178240
# If your server has 32 core and 64 SMT threads, we suggest to run with no more than 32 threads.
179-
cat $workload_list | parallel -a - -j $num_threads arg_wrapper {}
241+
if [ "${#filtered_workloads[@]}" -gt 0 ]; then
242+
printf '%s\n' "${filtered_workloads[@]}" | parallel -a - -j $num_threads arg_wrapper {}
243+
else
244+
cat "$workload_list" | parallel -a - -j $num_threads arg_wrapper {}
245+
fi
180246
}
181247

248+
apply_benchmark_filter
182249
parallel_run

0 commit comments

Comments
 (0)