|
| 1 | +#!/usr/bin/env bash |
1 | 2 | # DO NOT track your local updates in this script! |
2 | 3 |
|
3 | 4 | function print_help() { |
4 | 5 | printf "Usage: |
5 | | - bash $0 arch_script.sh workload_list.lst checkpoint_top_dir task_tag\n" |
| 6 | + bash $0 <config_file_or_script> workload_list.lst checkpoint_top_dir task_tag [extra_gem5_args] |
| 7 | +
|
| 8 | +Arguments: |
| 9 | + config_file_or_script: Config file (*.py) or wrapper script (*.sh). |
| 10 | + If relative, it is resolved relative to the repo root (gem5_home). |
| 11 | + workload_list.lst: List of workloads to run |
| 12 | + checkpoint_top_dir: Root directory for checkpoints |
| 13 | + task_tag: Tag for this experiment |
| 14 | + extra_gem5_args: Optional extra arguments for gem5 (only for .py mode) |
| 15 | +
|
| 16 | +Examples: |
| 17 | + # Legacy mode (using .sh script) |
| 18 | + bash $0 kmh_v3_btb.sh workload.lst /cpt/dir my_exp |
| 19 | +
|
| 20 | + # New mode (using .py config) |
| 21 | + bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp |
| 22 | +
|
| 23 | + # New mode with extra args |
| 24 | + bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp_nosc \"--disable-mgsc\" |
| 25 | +\n" |
6 | 26 | exit 1 |
7 | 27 | } |
8 | 28 |
|
|
13 | 33 |
|
14 | 34 | set -x |
15 | 35 |
|
16 | | -export arch_script=`realpath $1` |
| 36 | +script_dir=$(dirname -- "$( readlink -f -- "$0"; )") |
| 37 | +source "$script_dir/common.sh" |
| 38 | + |
| 39 | +# Detect if first parameter is a script (.sh) or config file (.py) |
| 40 | +first_param="$1" |
| 41 | +if [[ "$first_param" != /* ]] && [[ -f "$gem5_home/$first_param" ]]; then |
| 42 | + first_param="$gem5_home/$first_param" |
| 43 | +fi |
| 44 | +export first_param=$(realpath "$first_param") |
| 45 | + |
| 46 | +if [[ "$first_param" == *.sh ]]; then |
| 47 | + # Legacy mode: using wrapper script |
| 48 | + export use_legacy_mode=true |
| 49 | + export arch_script="$first_param" |
| 50 | + echo "Legacy mode: using script $arch_script" |
| 51 | +else |
| 52 | + # New mode: using config file directly |
| 53 | + export use_legacy_mode=false |
| 54 | + export config_file="$first_param" |
| 55 | + export extra_gem5_args="${5:-}" # Optional 5th parameter |
| 56 | + echo "Config mode: using $config_file" |
| 57 | + if [ -n "$extra_gem5_args" ]; then |
| 58 | + echo "Extra gem5 args: $extra_gem5_args" |
| 59 | + fi |
| 60 | +fi |
17 | 61 |
|
18 | 62 | # Note 1: workload list contains the workload name, checkpoint path, and parameters, looks like: |
19 | 63 | # astar_biglakes_122060000000 astar_biglakes_122060000000_0.244818/0/ 0 0 20 20 |
@@ -70,9 +114,16 @@ function run() { |
70 | 114 |
|
71 | 115 | touch running |
72 | 116 |
|
73 | | - script_dir=$(dirname -- "$( readlink -f -- "$0"; )") |
74 | | - bash $arch_script $1 # checkpoint |
75 | | - check $? |
| 117 | + if [ "$use_legacy_mode" = true ]; then |
| 118 | + # Legacy mode: call wrapper script |
| 119 | + bash $arch_script $1 # checkpoint |
| 120 | + check $? |
| 121 | + else |
| 122 | + # New mode: directly call gem5 with config file |
| 123 | + # config_file is already an absolute path from realpath |
| 124 | + $gem5 "$config_file" --generic-rv-cpt="$1" $extra_gem5_args |
| 125 | + check $? |
| 126 | + fi |
76 | 127 |
|
77 | 128 | rm running |
78 | 129 | touch completed |
|
0 commit comments