Skip to content

Commit d215cdc

Browse files
committed
util: support config files in parallel_sim.sh
Previously, running experiments with different configurations required creating separate wrapper scripts (kmh_v3_btb.sh, kmh_v3_ideal.sh, kmh_v3_btb_nosc.sh, etc.). This violates the DRY principle and makes configuration management difficult. Modified `parallel_sim.sh` to auto-detect file type and support both modes: - Legacy mode: Execute .sh wrapper scripts (backward compatible) - New mode: Directly invoke gem5 with .py config files - `util/xs_scripts/parallel_sim.sh`: - Auto-detect .sh vs .py files using file extension - Support optional 5th parameter for extra gem5 arguments - Update help message with examples - Maintain full backward compatibility with existing wrapper scripts - `.github/workflows/gem5-perf-template.yml`: - Add `config_path` parameter (recommended, replaces script_path) - Add `extra_args` parameter for gem5 command-line arguments - Keep `script_path` for backward compatibility - `.github/workflows/gem5-ideal-btb-perf.yml`: - Use `configs/example/idealkmhv3.py` directly - `.github/workflows/gem5-ideal-btb-perf-nosc.yml`: - Use `configs/example/idealkmhv3.py` with `--disable-mgsc` - `.github/workflows/gem5-ideal-btb-perf-weekly.yml`: - Migrate all jobs to use config files directly 1. **DRY compliance**: Configuration logic only in .py files 2. **Flexible parameters**: Support arbitrary gem5 arguments without new scripts 3. **Better traceability**: Experiment logs show full config + arguments 4. **Backward compatible**: Existing wrapper scripts continue to work ```bash bash parallel_sim.sh kmh_v3_btb.sh workload.lst /cpt my_exp bash parallel_sim.sh configs/example/idealkmhv3.py workload.lst /cpt my_exp bash parallel_sim.sh configs/example/idealkmhv3.py workload.lst /cpt my_exp "--disable-mgsc" Change-Id: I4c1f515b3913311fb05c0b9274e103460d349966
1 parent 9750a5a commit d215cdc

File tree

5 files changed

+82
-16
lines changed

5 files changed

+82
-16
lines changed

.github/workflows/gem5-ideal-btb-perf-nosc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ jobs:
1313
perf_test:
1414
uses: ./.github/workflows/gem5-perf-template.yml
1515
with:
16-
script_path: ../kmh_v3_btb_nosc.sh
16+
config_path: configs/example/idealkmhv3.py
17+
extra_args: "--disable-mgsc"
1718
benchmark_type: "spec06-0.8c"

.github/workflows/gem5-ideal-btb-perf-weekly.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ jobs:
1111
perf_test_spec06:
1212
uses: ./.github/workflows/gem5-perf-template.yml
1313
with:
14-
script_path: ../kmh_v3_ideal.sh
14+
config_path: configs/example/idealkmhv3.py
1515
benchmark_type: "spec06-1.0c"
16-
16+
1717
perf_test_spec17:
1818
uses: ./.github/workflows/gem5-perf-template.yml
1919
with:
20-
script_path: ../kmh_v3_ideal.sh
21-
benchmark_type: "spec17-1.0c"
22-
20+
config_path: configs/example/idealkmhv3.py
21+
benchmark_type: "spec17-1.0c"
22+
2323
perf_test_spec06_vector:
2424
uses: ./.github/workflows/gem5-perf-template.yml
2525
with:
26-
script_path: ../kmh_v3_ideal.sh
26+
config_path: configs/example/idealkmhv3.py
2727
benchmark_type: "spec06-rvv-1.0c"
2828
vector_type: "simple"
2929
check_result: false

.github/workflows/gem5-ideal-btb-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
perf_test:
1919
uses: ./.github/workflows/gem5-perf-template.yml
2020
with:
21-
script_path: ../kmh_v3_ideal.sh
21+
config_path: configs/example/idealkmhv3.py
2222
benchmark_type: "spec06-0.8c"

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ name: gem5 Performance Test Template (Unified)
33
on:
44
workflow_call:
55
inputs:
6+
config_path:
7+
required: false
8+
type: string
9+
description: "Config file (.py) or script (.sh) path (relative to util/xs_scripts/)"
610
script_path:
7-
required: true
11+
required: false
812
type: string
13+
description: "DEPRECATED: Use config_path instead. Still supported for backward compatibility."
14+
extra_args:
15+
required: false
16+
type: string
17+
default: ""
18+
description: "Extra arguments for gem5 (e.g., --disable-mgsc). Only works with .py config files."
919
benchmark_type:
1020
required: true
1121
type: string
@@ -123,10 +133,15 @@ jobs:
123133
export GEM5_BUILD_TYPE=fast
124134
mkdir -p $GEM5_HOME/util/xs_scripts/test
125135
cd $GEM5_HOME/util/xs_scripts/test
126-
bash ../parallel_sim.sh `realpath ${{ inputs.script_path }}` \
136+
137+
# Use config_path if provided, otherwise fall back to script_path for backward compatibility
138+
CONFIG_OR_SCRIPT="${{ inputs.config_path || inputs.script_path }}"
139+
140+
bash ../parallel_sim.sh `realpath $CONFIG_OR_SCRIPT` \
127141
${{ steps.config.outputs.checkpoint_list }} \
128142
${{ steps.config.outputs.checkpoint_root_node}} \
129-
spec_all
143+
spec_all \
144+
"${{ inputs.extra_args }}"
130145
- name: Setup gem5_data_proc environment
131146
run: |
132147
# 使用本地数据处理仓库,避免GitHub网络问题

util/xs_scripts/parallel_sim.sh

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22

33
function print_help() {
44
printf "Usage:
5-
bash $0 arch_script.sh workload_list.lst checkpoint_top_dir task_tag\n"
5+
bash $0 <config_file_or_script> workload_list.lst checkpoint_top_dir task_tag [extra_gem5_args]
6+
7+
Arguments:
8+
config_file_or_script: Config file (*.py) or wrapper script (*.sh)
9+
workload_list.lst: List of workloads to run
10+
checkpoint_top_dir: Root directory for checkpoints
11+
task_tag: Tag for this experiment
12+
extra_gem5_args: Optional extra arguments for gem5 (only for .py mode)
13+
14+
Examples:
15+
# Legacy mode (using .sh script)
16+
bash $0 kmh_v3_btb.sh workload.lst /cpt/dir my_exp
17+
18+
# New mode (using .py config)
19+
bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp
20+
21+
# New mode with extra args
22+
bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp_nosc \"--disable-mgsc\"
23+
\n"
624
exit 1
725
}
826

@@ -13,7 +31,32 @@ fi
1331

1432
set -x
1533

16-
export arch_script=`realpath $1`
34+
# Setup gem5 environment (similar to common.sh)
35+
script_dir=$(dirname -- "$( readlink -f -- "$0"; )")
36+
export gem5_home=$(dirname $(dirname $script_dir))
37+
export GEM5_BUILD_TYPE=${GEM5_BUILD_TYPE:-opt}
38+
export gem5=$(realpath $gem5_home/build/RISCV/gem5.$GEM5_BUILD_TYPE)
39+
40+
echo "Using gem5 binary: $gem5"
41+
42+
# Detect if first parameter is a script (.sh) or config file (.py)
43+
export first_param=`realpath $1`
44+
45+
if [[ "$first_param" == *.sh ]]; then
46+
# Legacy mode: using wrapper script
47+
export use_legacy_mode=true
48+
export arch_script="$first_param"
49+
echo "ℹ️ Legacy mode: using script $arch_script"
50+
else
51+
# New mode: using config file directly
52+
export use_legacy_mode=false
53+
export config_file="$first_param"
54+
export extra_gem5_args="${5:-}" # Optional 5th parameter
55+
echo "ℹ️ Config mode: using $config_file"
56+
if [ -n "$extra_gem5_args" ]; then
57+
echo "ℹ️ Extra gem5 args: $extra_gem5_args"
58+
fi
59+
fi
1760

1861
# Note 1: workload list contains the workload name, checkpoint path, and parameters, looks like:
1962
# astar_biglakes_122060000000 astar_biglakes_122060000000_0.244818/0/ 0 0 20 20
@@ -70,9 +113,16 @@ function run() {
70113

71114
touch running
72115

73-
script_dir=$(dirname -- "$( readlink -f -- "$0"; )")
74-
bash $arch_script $1 # checkpoint
75-
check $?
116+
if [ "$use_legacy_mode" = true ]; then
117+
# Legacy mode: call wrapper script
118+
bash $arch_script $1 # checkpoint
119+
check $?
120+
else
121+
# New mode: directly call gem5 with config file
122+
# config_file is already an absolute path from realpath
123+
$gem5 $config_file --generic-rv-cpt=$1 $extra_gem5_args
124+
check $?
125+
fi
76126

77127
rm running
78128
touch completed

0 commit comments

Comments
 (0)