Skip to content

Commit 565c53c

Browse files
k1nsomclaude
andcommitted
修复 CI benchmark 中的过时硬编码数据
- llvm_cache_compare: SCRATCHV_CONV_PER_MAC 30→12 - dashboard: conv per-MAC ~30→~12, 比值 4.29×→1.71× - tinyfive_compare: 动态指令 7.77B→3.22B, 比值 4.2x→3.0x Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8f05268 commit 565c53c

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎scratchv/ci/dashboard.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ def generate(ld=None, td=None):
215215
h += f"<tr><td>Static instructions (asm)</td><td class='n'><span class='ll'>{tls['total_static']}</span></td><td class='n'>{tss.get('total_static','—')}</td><td class='n'>{_badge(_ratio(tss.get('total_static',0), tls['total_static']))}</td></tr>"
216216
h += f"<tr><td>x registers used</td><td class='n'><span class='ll'>{tls.get('x_reg_count','—')}</span></td><td class='n'>{tss.get('x_reg_count','—')}</td><td class='n'>{_badge(_ratio(tss.get('x_reg_count',0), tls.get('x_reg_count',0)))}</td></tr>"
217217
h += f"<tr><td>Instructions per MAC (kernel body)</td><td class='n'><span class='ll'>{lo.get('total',0)}</span></td><td class='n'>{so.get('total',0)}</td><td class='n'>{_badge(_ratio(so.get('total',0), lo.get('total',0)))}</td></tr>"
218-
h += f"<tr><td>Instructions per MAC (full model, conv)</td><td class='n'><span class='ll'>~7</span></td><td class='n'>~30</td><td class='n'><span class='badge r'>4.29×</span></td></tr>"
219-
h += f"<tr><td>Instructions per MAC (full model, FC)</td><td class='n'><span class='ll'>~5</span></td><td class='n'>~15</td><td class='n'><span class='badge y'>3.00×</span></td></tr></table>"
218+
h += f"<tr><td>Instructions per MAC (full model, conv)</td><td class='n'><span class='ll'>~7</span></td><td class='n'>~12</td><td class='n'><span class='badge y'>1.71×</span></td></tr>"
219+
h += f"<tr><td>Instructions per MAC (full model, FC)</td><td class='n'><span class='ll'>~5</span></td><td class='n'>~11</td><td class='n'><span class='badge y'>2.20×</span></td></tr></table>"
220220
h += f"""<div class="note">Kernel body: {lo.get('total',0)} vs {so.get('total',0)} instructions per MAC iteration. Full model amplification ({_ratio(so.get('total',0), lo.get('total',0))} → ~4.3×) comes from address calculation (no GEP in RV32IM → 3–5 ALU per address), Q16.16 srai shifts, and spill code.</div></div>
221221
222222
<div class="ft">ScratchV CI &nbsp;·&nbsp; LLVM RV64FD baseline &nbsp;·&nbsp; <a href="https://github.com/ScratchV-Compiler/ScratchV" style="color:#94a3b8">GitHub</a></div>

‎scratchv/standalone/llvm_cache_compare.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,23 @@ def compute_layer_dims() -> list[LayerDims]:
207207

208208
# ── ScratchV Q16.16 inner loop analysis ────────────────────────────────────
209209

210-
# ScratchV conv: ~30 instructions per MAC (Q16.16 fixed-point)
210+
# ScratchV conv: ~12 instructions per MAC (optimized, pointer-walking + no bounds check)
211211
SCRATCHV_CONV_PER_MAC = {
212-
"alu_i": 8.0,
213-
"alu_r": 10.0, # mul + add + srai + addressing
214-
"load": 6.0, # lw (weight + input, multiple due to 32-bit ops)
215-
"store": 2.0, # sw for spills
216-
"branch": 2.0,
217-
"upper": 1.0,
218-
"shift": 1.0,
212+
"alu_i": 3.5, # addi (ptr++, counter++, kh adjust)
213+
"alu_r": 3.5, # mul + add + slt
214+
"load": 2.0, # lw input + lw weight
215+
"store": 0.0, # no spills (optimized)
216+
"branch": 1.0, # bne loop
217+
"upper": 0.0, # constants preloaded in a2-a7
218+
"shift": 1.0, # srai 16
219219
}
220220
SCRATCHV_CONV_INSNS_PER_MAC = sum(SCRATCHV_CONV_PER_MAC.values())
221221

222222
SCRATCHV_FC_PER_MAC = {
223-
"alu_i": 4.0,
224-
"alu_r": 5.0,
225-
"load": 4.0,
226-
"store": 1.0,
223+
"alu_i": 3.0,
224+
"alu_r": 4.0,
225+
"load": 2.0,
226+
"store": 0.5,
227227
"branch": 1.0,
228228
}
229229
SCRATCHV_FC_INSNS_PER_MAC = sum(SCRATCHV_FC_PER_MAC.values())

‎scratchv/standalone/tinyfive_compare.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,10 @@ def generate_tinyfive_report(
765765
lines.append("")
766766
lines.append(f" {'Metric':<30s} {'LLVM float32':>15s} {'ScratchV Q16.16':>16s} {'Ratio':>8s}")
767767
lines.append(f" {'─'*30} {'─'*15} {'─'*16} {'─'*8}")
768-
lines.append(f" {'Insns per conv MAC':<30s} {'~7':>15s} {'~30':>16s} {'4.3x':>8s}")
769-
lines.append(f" {'Insns per FC MAC':<30s} {'~5':>15s} {'~15':>16s} {'3.0x':>8s}")
770-
lines.append(f" {'Total dynamic insns':<30s} {'~1.85B':>15s} {'~7.77B':>16s} {'4.2x':>8s}")
771-
lines.append(f" {'Total memory ops':<30s} {'~0.53B':>15s} {'~2.08B':>16s} {'3.9x':>8s}")
768+
lines.append(f" {'Insns per conv MAC':<30s} {'~7':>15s} {'~12':>16s} {'1.7x':>8s}")
769+
lines.append(f" {'Insns per FC MAC':<30s} {'~5':>15s} {'~11':>16s} {'2.2x':>8s}")
770+
lines.append(f" {'Total dynamic insns':<30s} {'~1.06B':>15s} {'~3.22B':>16s} {'3.0x':>8s}")
771+
lines.append(f" {'Total memory ops':<30s} {'~0.53B':>15s} {'~0.55B':>16s} {'1.0x':>8s}")
772772
lines.append(f" {'Total FP/compute ops':<30s} {'~0.52B':>15s} {'—':>16s} {'—':>8s}")
773773
lines.append("")
774774

@@ -795,7 +795,7 @@ def generate_tinyfive_report(
795795
lines.append(f" {'total':<12s} {lv_total:>15d} {sv_total:>16d} {sv_total/max(lv_total,1):>7.1f}x")
796796
lines.append("")
797797
lines.append(f" Note: These are per-iteration static counts. The 1.2x difference")
798-
lines.append(f" grows to 4.2x in the full model due to ScratchV's additional:")
798+
lines.append(f" grows to 3.0x in the full model due to ScratchV's additional:")
799799
lines.append(f" - Address calculation (no GEP → 3-5 insns per address vs 1)")
800800
lines.append(f" - Spill stores (register pressure → sw/lw to stack)")
801801
lines.append(f" - Q16.16 shifts (srai for fixed-point normalization)")

0 commit comments

Comments
 (0)