diff --git a/.github/workflows/gem5-ideal-btb-0.3c.yml b/.github/workflows/gem5-ideal-btb-0.3c.yml index 79a9aeea64..03e96e8c79 100644 --- a/.github/workflows/gem5-ideal-btb-0.3c.yml +++ b/.github/workflows/gem5-ideal-btb-0.3c.yml @@ -16,5 +16,5 @@ jobs: perf_test: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_btb.sh - benchmark_type: "spec06-0.3c" \ No newline at end of file + config_path: configs/example/kmhv3.py + benchmark_type: "spec06-0.3c" diff --git a/.github/workflows/gem5-ideal-btb-perf-weekly.yml b/.github/workflows/gem5-ideal-btb-perf-weekly.yml index 0c990b8205..9d2b700b4b 100644 --- a/.github/workflows/gem5-ideal-btb-perf-weekly.yml +++ b/.github/workflows/gem5-ideal-btb-perf-weekly.yml @@ -11,31 +11,24 @@ jobs: align_test_spec06: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_btb.sh + config_path: configs/example/kmhv3.py benchmark_type: "spec06-1.0c" align_test_spec17: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_btb.sh + config_path: configs/example/kmhv3.py benchmark_type: "spec17-1.0c" perf_test_spec06: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_ideal.sh + config_path: configs/example/idealkmhv3.py benchmark_type: "spec06-1.0c" - + perf_test_spec17: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_ideal.sh + config_path: configs/example/idealkmhv3.py benchmark_type: "spec17-1.0c" - - # perf_test_spec06_vector: - # uses: ./.github/workflows/gem5-perf-template.yml - # with: - # script_path: ../kmh_v3_ideal.sh - # benchmark_type: "spec06-rvv-1.0c" - # vector_type: "simple" - # check_result: false \ No newline at end of file + diff --git a/.github/workflows/gem5-ideal-btb-perf.yml b/.github/workflows/gem5-ideal-btb-perf.yml index 473258daab..50e1a200f3 100644 --- a/.github/workflows/gem5-ideal-btb-perf.yml +++ b/.github/workflows/gem5-ideal-btb-perf.yml @@ -18,5 +18,5 @@ jobs: perf_test: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_ideal.sh - benchmark_type: "spec06-0.8c" \ No newline at end of file + config_path: configs/example/idealkmhv3.py + benchmark_type: "spec06-0.8c" diff --git a/.github/workflows/gem5-ideal-rvv-simple-perf.yml b/.github/workflows/gem5-ideal-rvv-simple-perf.yml index 5243ef119f..4c1ff6a4a5 100644 --- a/.github/workflows/gem5-ideal-rvv-simple-perf.yml +++ b/.github/workflows/gem5-ideal-rvv-simple-perf.yml @@ -7,7 +7,7 @@ jobs: perf_test: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_ideal.sh + config_path: configs/example/idealkmhv3.py benchmark_type: "spec06int-rvv-0.8c" vector_type: "simple" - check_result: false # Warning: rvv test will not show the difftest failure \ No newline at end of file + check_result: false # Warning: rvv test will not show the difftest failure diff --git a/.github/workflows/gem5-perf-template.yml b/.github/workflows/gem5-perf-template.yml index 938bc889c5..c64a82b050 100644 --- a/.github/workflows/gem5-perf-template.yml +++ b/.github/workflows/gem5-perf-template.yml @@ -3,9 +3,15 @@ name: gem5 Performance Test Template (Unified) on: workflow_call: inputs: - script_path: + config_path: required: true type: string + description: "gem5 config file path (relative to repo root), e.g. configs/example/idealkmhv3.py" + extra_args: + required: false + type: string + default: "" + description: "Extra arguments for gem5 (e.g., --disable-mgsc). Only works with .py config files." benchmark_type: required: true type: string @@ -116,17 +122,32 @@ jobs: - name: XS-GEM5 - Run performance test # ${{ steps.config.outputs.comment }} + env: + GCBV_REF_SO: "/nfs/home/share/gem5_ci/ref/normal/riscv64-nemu-notama-tvalref-so" + GCB_RESTORER: "" + GEM5_HOME: ${{ github.workspace }} + GEM5_BUILD_TYPE: fast run: | - export GCBV_REF_SO="/nfs/home/share/gem5_ci/ref/normal/riscv64-nemu-notama-tvalref-so" - export GCB_RESTORER="" - export GEM5_HOME=$(pwd) - export GEM5_BUILD_TYPE=fast mkdir -p $GEM5_HOME/util/xs_scripts/test cd $GEM5_HOME/util/xs_scripts/test - bash ../parallel_sim.sh `realpath ${{ inputs.script_path }}` \ + + CONFIG_PATH="${{ inputs.config_path }}" + if [[ "$CONFIG_PATH" == /* ]]; then + echo "Error: config_path must be repo-root-relative, got absolute path: '$CONFIG_PATH'" + exit 1 + fi + if [[ "$CONFIG_PATH" != *.py ]]; then + echo "Error: config_path must be a .py gem5 config file path, got: '$CONFIG_PATH'" + exit 1 + fi + + CONFIG_PATH="$GEM5_HOME/$CONFIG_PATH" + + bash ../parallel_sim.sh "$(realpath "$CONFIG_PATH")" \ ${{ steps.config.outputs.checkpoint_list }} \ ${{ steps.config.outputs.checkpoint_root_node}} \ - spec_all + spec_all \ + "${{ inputs.extra_args }}" - name: Setup gem5_data_proc environment run: | # 使用本地数据处理仓库,避免GitHub网络问题 diff --git a/.github/workflows/gem5-perf.yml b/.github/workflows/gem5-perf.yml index fae1512f46..0a0adf4b2a 100644 --- a/.github/workflows/gem5-perf.yml +++ b/.github/workflows/gem5-perf.yml @@ -15,5 +15,5 @@ jobs: perf_test: uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_6wide.sh - benchmark_type: "spec06-0.8c" \ No newline at end of file + config_path: configs/example/kmhv2.py + benchmark_type: "spec06-0.8c" diff --git a/.github/workflows/manual-perf.yml b/.github/workflows/manual-perf.yml index b3dfb42def..9164a9b51e 100644 --- a/.github/workflows/manual-perf.yml +++ b/.github/workflows/manual-perf.yml @@ -41,27 +41,13 @@ jobs: setup: runs-on: ubuntu-latest outputs: - script_path: ${{ steps.resolve.outputs.script_path }} + config_path: ${{ steps.resolve.outputs.config_path }} pr_sha: ${{ steps.resolve.outputs.pr_sha }} steps: - name: Resolve parameters id: resolve run: | - case "${{ github.event.inputs.configuration }}" in - "kmhv2.py") - echo "script_path=../kmh_6wide.sh" >> $GITHUB_OUTPUT - ;; - "kmhv3.py") - echo "script_path=../kmh_v3_btb.sh" >> $GITHUB_OUTPUT - ;; - "idealkmhv3.py") - echo "script_path=../kmh_v3_ideal.sh" >> $GITHUB_OUTPUT - ;; - *) - echo "Error: unsupported configuration '${{ github.event.inputs.configuration }}'" >&2 - exit 1 - ;; - esac + echo "config_path=configs/example/${{ github.event.inputs.configuration }}" >> $GITHUB_OUTPUT if [ -n "${{ github.event.inputs.branch }}" ]; then echo "pr_sha=${{ github.event.inputs.branch }}" >> $GITHUB_OUTPUT @@ -73,7 +59,7 @@ jobs: needs: setup uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ${{ needs.setup.outputs.script_path }} + config_path: ${{ needs.setup.outputs.config_path }} benchmark_type: ${{ github.event.inputs.benchmark_type }} vector_type: ${{ github.event.inputs.vector_type }} pr_sha: ${{ needs.setup.outputs.pr_sha }} diff --git a/.github/workflows/on-demand-spec.yml b/.github/workflows/on-demand-spec.yml index af2d0e9d30..75c0e2fffd 100644 --- a/.github/workflows/on-demand-spec.yml +++ b/.github/workflows/on-demand-spec.yml @@ -83,7 +83,7 @@ jobs: needs: trigger uses: ./.github/workflows/gem5-perf-template.yml with: - script_path: ../kmh_v3_ideal.sh + config_path: configs/example/idealkmhv3.py benchmark_type: ${{ needs.trigger.outputs.benchmark_type }} vector_type: ${{ needs.trigger.outputs.vector_type }} pr_sha: ${{ needs.trigger.outputs.pr_sha }} diff --git a/util/xs_scripts/parallel_sim.sh b/util/xs_scripts/parallel_sim.sh index 16ee1ad37f..f6166134aa 100644 --- a/util/xs_scripts/parallel_sim.sh +++ b/util/xs_scripts/parallel_sim.sh @@ -1,8 +1,28 @@ +#!/usr/bin/env bash # DO NOT track your local updates in this script! function print_help() { printf "Usage: - bash $0 arch_script.sh workload_list.lst checkpoint_top_dir task_tag\n" + bash $0 workload_list.lst checkpoint_top_dir task_tag [extra_gem5_args] + +Arguments: + config_file_or_script: Config file (*.py) or wrapper script (*.sh). + If relative, it is resolved relative to the repo root (gem5_home). + workload_list.lst: List of workloads to run + checkpoint_top_dir: Root directory for checkpoints + task_tag: Tag for this experiment + extra_gem5_args: Optional extra arguments for gem5 (only for .py mode) + +Examples: + # Legacy mode (using .sh script) + bash $0 kmh_v3_btb.sh workload.lst /cpt/dir my_exp + + # New mode (using .py config) + bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp + + # New mode with extra args + bash $0 configs/example/idealkmhv3.py workload.lst /cpt/dir my_exp_nosc \"--disable-mgsc\" +\n" exit 1 } @@ -13,7 +33,31 @@ fi set -x -export arch_script=`realpath $1` +script_dir=$(dirname -- "$( readlink -f -- "$0"; )") +source "$script_dir/common.sh" + +# Detect if first parameter is a script (.sh) or config file (.py) +first_param="$1" +if [[ "$first_param" != /* ]] && [[ -f "$gem5_home/$first_param" ]]; then + first_param="$gem5_home/$first_param" +fi +export first_param=$(realpath "$first_param") + +if [[ "$first_param" == *.sh ]]; then + # Legacy mode: using wrapper script + export use_legacy_mode=true + export arch_script="$first_param" + echo "Legacy mode: using script $arch_script" +else + # New mode: using config file directly + export use_legacy_mode=false + export config_file="$first_param" + export extra_gem5_args="${5:-}" # Optional 5th parameter + echo "Config mode: using $config_file" + if [ -n "$extra_gem5_args" ]; then + echo "Extra gem5 args: $extra_gem5_args" + fi +fi # Note 1: workload list contains the workload name, checkpoint path, and parameters, looks like: # astar_biglakes_122060000000 astar_biglakes_122060000000_0.244818/0/ 0 0 20 20 @@ -70,9 +114,16 @@ function run() { touch running - script_dir=$(dirname -- "$( readlink -f -- "$0"; )") - bash $arch_script $1 # checkpoint - check $? + if [ "$use_legacy_mode" = true ]; then + # Legacy mode: call wrapper script + bash $arch_script $1 # checkpoint + check $? + else + # New mode: directly call gem5 with config file + # config_file is already an absolute path from realpath + $gem5 "$config_file" --generic-rv-cpt="$1" $extra_gem5_args + check $? + fi rm running touch completed