Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ jobs:
--junit-xml=benchmark_reports/test_results.xml \
--ignore=tests/test_simulator.py

# ── 课题06:DSL 基准套件(硬门禁,xfail 不红灯)+ 报告契约 ───────
- name: Run DSL benchmark suite
run: |
python3.12 -m pytest \
tests/test_dsl_suite.py \
tests/test_suite_report_contract.py \
-v --tb=short

- name: Run assembly-beautifier regressions
run: |
python3.12 -m pytest \
Expand Down Expand Up @@ -227,6 +235,13 @@ jobs:
--output-html benchmark_reports/dsl_bench.html \
--output-md benchmark_reports/dsl_bench.md

# ── 课题06:DSL 基准套件 JSON/MD 报告(同时作为第二道门禁) ───────
- name: DSL benchmark suite report
run: |
python3.12 benchmarks/run_suite.py \
--json benchmark_reports/dsl_suite.json \
--markdown benchmark_reports/dsl_suite.md

# ── 3.3 CNN RISC-V 编译 + 性能估算 ────────────────────────────────
- name: CNN RISC-V compilation & estimation
run: |
Expand Down Expand Up @@ -381,6 +396,11 @@ jobs:
if [ -f benchmark_reports/regalloc_bench.md ]; then
cat benchmark_reports/regalloc_bench.md >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### DSL Benchmark Suite" >> $GITHUB_STEP_SUMMARY
if [ -f benchmark_reports/dsl_suite.md ]; then
cat benchmark_reports/dsl_suite.md >> $GITHUB_STEP_SUMMARY
fi

# ═════════════════════════════════════════════════════════════════════════
# GitHub Pages 部署 (仅 main 分支)
Expand Down
15 changes: 15 additions & 0 deletions benchmarks/cases/001_simple_add.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "Basic addition of two vectors",
"category": "arith",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
2.0,
4.0,
6.0,
8.0
],
"max_instructions": 3
}
15 changes: 15 additions & 0 deletions benchmarks/cases/002_simple_mul.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "Element-wise multiplication of two vectors",
"category": "arith",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
1.0,
4.0,
9.0,
16.0
],
"max_instructions": 3
}
15 changes: 15 additions & 0 deletions benchmarks/cases/003_sub_div.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "Chained subtraction and division",
"category": "arith",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
0.0,
0.0,
0.0,
0.0
],
"max_instructions": 4
}
15 changes: 15 additions & 0 deletions benchmarks/cases/004_relu.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "ReLU activation function",
"category": "nn",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
1.0,
2.0,
3.0,
4.0
],
"max_instructions": 3
}
15 changes: 15 additions & 0 deletions benchmarks/cases/005_gelu.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "GELU activation function",
"category": "nn",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
0.841192,
1.954598,
2.996363,
3.99993
],
"max_instructions": 5
}
15 changes: 15 additions & 0 deletions benchmarks/cases/006_softmax.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "Softmax activation on a vector",
"category": "nn",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
0.0320586,
0.08714432,
0.23688282,
0.64391428
],
"max_instructions": 3
}
10 changes: 10 additions & 0 deletions benchmarks/cases/007_matmul.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"schema_version": 1,
"description": "Matrix multiplication (2x2 matrices)",
"category": "nn",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": 30.0,
"max_instructions": 3
}
10 changes: 10 additions & 0 deletions benchmarks/cases/008_dot.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"schema_version": 1,
"description": "Dot product of two length-4 vectors",
"category": "nn",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": 30.0,
"max_instructions": 3
}
22 changes: 22 additions & 0 deletions benchmarks/cases/009_maxpool.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"schema_version": 1,
"description": "1D MaxPool with kernel=2, stride=2",
"category": "nn",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
2.0,
4.0
],
"max_instructions": 9,
"xfail": {
"stages": [
"assemble",
"budget"
],
"reason": "C1 backend/regalloc: the linear-scan emitter keeps the branch target in the instruction comment and emits no operand, so assemble_to_binary fails; greedy path encodes the same branch. first bad line: bnez a1 # .Lmp_gt_1",
"owner": "backend/regalloc",
"strict": false
}
}
15 changes: 15 additions & 0 deletions benchmarks/cases/010_exp_neg.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "Chained exponentiation and negation",
"category": "arith",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
-2.71828183,
-7.3890561,
-20.08553692,
-54.59815003
],
"max_instructions": 5
}
15 changes: 15 additions & 0 deletions benchmarks/cases/011_multi_op_chain.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "Multi-operation chain with three arithmetic ops",
"category": "complex",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
0.0,
0.0,
0.0,
0.0
],
"max_instructions": 5
}
15 changes: 15 additions & 0 deletions benchmarks/cases/012_nn_pipeline.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema_version": 1,
"description": "Typical NN layer: matmul + bias + relu",
"category": "nn",
"flow": "linear",
"oracle": "interpreter",
"inputs": {},
"expected_return": [
31.0,
32.0,
33.0,
34.0
],
"max_instructions": 5
}
27 changes: 27 additions & 0 deletions benchmarks/cases/013_for_sum.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"schema_version": 1,
"description": "For-loop accumulation (sum)",
"category": "control",
"flow": "control",
"oracle": "execution",
"inputs": {
"x": 1,
"acc": 0
},
"input_registers": {
"x": "a0",
"acc": "a1"
},
"expected_return": 4,
"max_instructions": 9,
"xfail": {
"stages": [
"assemble",
"budget",
"semantic"
],
"reason": "C1 backend/regalloc: the linear-scan emitter keeps the branch target in the instruction comment and emits no operand, so assemble_to_binary fails; greedy path encodes the same branch. first bad line: bge a3, 4 # .Lloop_exit_3",
"owner": "backend/regalloc",
"strict": false
}
}
29 changes: 29 additions & 0 deletions benchmarks/cases/014_for_dot.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"schema_version": 1,
"description": "Dot product simulated with for-loop",
"category": "control",
"flow": "control",
"oracle": "execution",
"inputs": {
"a": 2,
"b": 3,
"acc": 0
},
"input_registers": {
"a": "a0",
"b": "a1",
"acc": "a2"
},
"expected_return": 24,
"max_instructions": 9,
"xfail": {
"stages": [
"assemble",
"budget",
"semantic"
],
"reason": "C1 backend/regalloc: the linear-scan emitter keeps the branch target in the instruction comment and emits no operand, so assemble_to_binary fails; greedy path encodes the same branch. first bad line: bge a3, 4 # .Lloop_exit_3",
"owner": "backend/regalloc",
"strict": false
}
}
27 changes: 27 additions & 0 deletions benchmarks/cases/015_for_relu.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"schema_version": 1,
"description": "ReLU activation inside a for-loop",
"category": "control",
"flow": "control",
"oracle": "execution",
"inputs": {
"x": 1,
"y": 0
},
"input_registers": {
"x": "a0",
"y": "a1"
},
"expected_return": 4,
"max_instructions": 10,
"xfail": {
"stages": [
"assemble",
"budget",
"semantic"
],
"reason": "C1 backend/regalloc: the linear-scan emitter keeps the branch target in the instruction comment and emits no operand, so assemble_to_binary fails; greedy path encodes the same branch. first bad line: bge a3, 4 # .Lloop_exit_3",
"owner": "backend/regalloc",
"strict": false
}
}
27 changes: 27 additions & 0 deletions benchmarks/cases/016_if_simple.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"schema_version": 1,
"description": "If-else branching (extended DSL parser required)",
"category": "control",
"flow": "control",
"oracle": "execution",
"inputs": {
"a": 4,
"b": 1
},
"input_registers": {
"a": "a0",
"b": "a1"
},
"expected_return": 5,
"max_instructions": 8,
"xfail": {
"stages": [
"assemble",
"budget",
"semantic"
],
"reason": "C1 backend/regalloc: the linear-scan emitter keeps the branch target in the instruction comment and emits no operand, so assemble_to_binary fails; greedy path encodes the same branch. first bad line: bnez a1 # if_then1",
"owner": "backend/regalloc",
"strict": false
}
}
1 change: 1 addition & 0 deletions benchmarks/cases/017_while_sum.dsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Sum with while loop (extended parser)
while (i < 10):
acc = add(acc, x)
i = add(i, 1)
endwhile
return acc
29 changes: 29 additions & 0 deletions benchmarks/cases/017_while_sum.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"schema_version": 1,
"description": "While-loop accumulation (extended DSL parser required)",
"category": "control",
"flow": "control",
"oracle": "execution",
"inputs": {
"i": 0,
"x": 1,
"acc": 0
},
"input_registers": {
"i": "a0",
"x": "a1",
"acc": "a2"
},
"expected_return": 10,
"max_instructions": 9,
"xfail": {
"stages": [
"assemble",
"budget",
"semantic"
],
"reason": "C1 backend/regalloc: the linear-scan emitter keeps the branch target in the instruction comment and emits no operand, so assemble_to_binary fails; greedy path encodes the same branch. first bad line: j # while_hdr1",
"owner": "backend/regalloc",
"strict": false
}
}
Loading
Loading