name: mgsc-table-probe description: 分析香山 MGSC/SC 在前端微测试上的效果。适用于以下场景:(1) 用 off/l_only/g_only/i_only/full 等 A/B profile 批量运行 mgsc_test;(2) 比较不同 profile 下的 topMispredictsByBranch.csv 和 stats.txt;(3) 使用 bp.db 里的 MGSCTRACE 将每个分支的收益/损失归因到具体 SC 表;(4) 决定如何为 Global 或 IMLI 表设计新的测试。
MGSC 表探测
概览
运行标准化的 SC 表 A/B 实验,并产出分支级别的归因结果:
summary.csv:case 级别的off与各 profile 的 delta 汇总。branch_delta.csv:分支级别的误预测 delta,以及 SC 修复/伤害与表贡献比例。report.md:便于人工快速阅读的排序报告。
这个 skill 的目标是快速迭代 SC 测试质量,而不是做完整的性能调优。
快速开始
- 对所有
mgsc_test二进制执行 probe:
python3 .codex/skills/mgsc-table-probe/scripts/mgsc_table_probe.py \
--outdir debug/sc_table_probe \
--profiles off,l_only,g_only,i_only,full \
--max-workers 4
- 快速检查单个 case:
python3 .codex/skills/mgsc-table-probe/scripts/mgsc_table_probe.py \
--outdir debug/sc_table_probe_smoke \
--tests fp_sc_alias_pair \
--profiles off,g_only,i_only \
--max-workers 1
- 仅重建报告(不重新运行 gem5):
python3 .codex/skills/mgsc-table-probe/scripts/mgsc_table_probe.py \
--outdir debug/sc_table_probe \
--profiles off,l_only,g_only,i_only,full \
--skip-run
工作流
- 基线 + 单表隔离 profile
- 始终包含
off。 - 在检查
full之前,先加入单表 profile(如g_only、i_only)。
- 快速筛选有价值的测试
- 在
summary.csv中,优先关注满足condMiss_delta < 0且mgsc_net_use > 0的 case。
- 筛选有价值的分支
- 在
branch_delta.csv中,优先关注满足以下条件的行:delta_misp < 0focus_decisive_ratio较高focus_agree_fix_ratio较高
- 决定下一步微测试方向
- 如果
g_only很少带来改善,且focus_decisive_ratio(g)很低,说明 global-history 模式较弱。 - 如果
i_only从未带来帮助,说明循环/迭代相位信号暴露得还不够。 - 可以参考
references/test-patterns.md里的模式来编写下一个测试。
输出
debug/sc_table_probe/summary.csvdebug/sc_table_probe/branch_delta.csvdebug/sc_table_probe/report.mddebug/sc_table_probe/report.json
关键参数
--profiles:从off,l_only,g_only,i_only,full中选择。--tests:逗号分隔的测试名(不带后缀),例如fp_sc_alias_pair,imli_iter。--extra-param:透传额外的 gem5--param。--copy-cpt-to-tmp:避免路径访问问题。--skip-run:仅生成报告,不执行运行。
注意事项
- 除非你明确要评估交互效应,否则在做 SC 子表归因时应保持
microtage关闭。 - 不同 profile 之间必须使用同一组 checkpoint,否则 delta 无效。
- 做 branch PC 映射时,使用 mgsc_test 构建目录下的
*-riscv64-xs.txt反汇编文件。
参考资料
- 关于面向 G/IMLI 的微测试模式,参见
references/test-patterns.md。