Skip to content
Merged
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
113 changes: 113 additions & 0 deletions .github/workflows/accuracy-embench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Accuracy - EmBench

on:
push:
branches: [main]
paths:
- 'benchmarks/aha-mont64-m2sim/**'
- 'benchmarks/crc32-m2sim/**'
- 'benchmarks/edn-m2sim/**'
- 'benchmarks/huffbench-m2sim/**'
- 'benchmarks/matmult-int-m2sim/**'
- 'benchmarks/statemate-m2sim/**'
- 'benchmarks/primecount-m2sim/**'
- 'benchmarks/embench_test.go'
- 'timing/**'
workflow_dispatch:

concurrency:
group: accuracy-embench-${{ github.ref }}
cancel-in-progress: false

jobs:
embench-accuracy:
name: EmBench Accuracy
runs-on: macos-14
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'

- name: Verify EmBench ELFs
run: |
echo "Checking EmBench ELF files..."
ls -la benchmarks/aha-mont64-m2sim/*.elf 2>/dev/null || echo "aha-mont64 missing"
ls -la benchmarks/crc32-m2sim/*.elf 2>/dev/null || echo "crc32 missing"
ls -la benchmarks/edn-m2sim/*.elf 2>/dev/null || echo "edn missing"
ls -la benchmarks/huffbench-m2sim/*.elf 2>/dev/null || echo "huffbench missing"
ls -la benchmarks/matmult-int-m2sim/*.elf 2>/dev/null || echo "matmult-int missing"
ls -la benchmarks/statemate-m2sim/*.elf 2>/dev/null || echo "statemate missing"
ls -la benchmarks/primecount-m2sim/*.elf 2>/dev/null || echo "primecount missing"

- name: Run EmBench tests
run: |
TESTS=(
TestEmbenchAhaMont64
TestEmbenchCRC32
TestEmbenchEDN
TestEmbenchHuffbench
TestEmbenchMatmultInt
TestEmbenchStatemate
TestEmbenchPrimecount
)

> embench_output.txt
for TEST in "${TESTS[@]}"; do
echo "--- $TEST ---"
go test -v -run "^${TEST}$" -count=1 -timeout 5m ./benchmarks/ 2>&1 | tee -a embench_output.txt || true
done

- name: Extract CPI results
if: always()
run: |
python3 - <<'PYEOF'
import json, re

results = {}
with open("embench_output.txt") as f:
for line in f:
if "CPI=" not in line:
continue
# Try to extract benchmark name and CPI
match = re.search(r'(\w+):\s+.*CPI=([\d.]+)', line)
if match:
name = match.group(1)
cpi = float(match.group(2))
results[name] = {"cpi": cpi}

output = {"benchmarks_run": len(results), "results": results}
with open("embench_results.json", "w") as f:
json.dump(output, f, indent=2)
print(json.dumps(output, indent=2))
PYEOF

- name: Post summary
if: always()
run: |
echo "## EmBench Accuracy Results" >> $GITHUB_STEP_SUMMARY
if [ -f embench_results.json ]; then
python3 -c "
import json
d = json.load(open('embench_results.json'))
print(f'**Benchmarks measured:** {d[\"benchmarks_run\"]}/7')
if d['results']:
print()
print('| Benchmark | CPI |')
print('|-----------|-----|')
for name, r in sorted(d['results'].items()):
print(f'| {name} | {r[\"cpi\"]:.3f} |')
" >> $GITHUB_STEP_SUMMARY
fi

- name: Upload results
if: always()
uses: actions/upload-artifact@v4
with:
name: embench-accuracy
path: |
embench_results.json
embench_output.txt
retention-days: 90
82 changes: 82 additions & 0 deletions .github/workflows/accuracy-microbench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Accuracy - Microbenchmarks

on:
push:
branches: [main]
paths:
- 'benchmarks/**'
- 'timing/**'
- 'emu/**'
workflow_dispatch:

concurrency:
group: accuracy-microbench-${{ github.ref }}
cancel-in-progress: false

jobs:
microbench-accuracy:
name: Microbenchmark Accuracy
runs-on: macos-14
timeout-minutes: 15

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Python dependencies
run: pip install matplotlib numpy scipy

- name: Run microbenchmark CPI tests
run: |
cd benchmarks
echo "=== Running microbenchmark CPI tests ==="

# Without D-cache (ALU, branch, throughput benchmarks)
go test -v -run TestTimingPredictions_CPIBounds -count=1 -timeout 5m ./ 2>&1 | tee micro_no_cache.txt

# With D-cache (memory-latency benchmarks)
go test -v -run TestAccuracyCPI_WithDCache -count=1 -timeout 5m ./ 2>&1 | tee micro_dcache.txt

- name: Generate accuracy report
run: |
python3 benchmarks/native/accuracy_report.py --suite microbench 2>&1 || true
# If the script doesn't support --suite yet, run it and it will
# naturally process microbenchmarks from test output

- name: Post summary
if: always()
run: |
echo "## Microbenchmark Accuracy Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f benchmarks/native/accuracy_results.json ]; then
python3 -c "
import json
d = json.load(open('benchmarks/native/accuracy_results.json'))
print(f\"**Average Error:** {d['summary']['average_error']*100:.1f}%\")
print(f\"**Benchmarks:** {d['summary']['benchmark_count']}\")
" >> $GITHUB_STEP_SUMMARY
else
echo "No results generated." >> $GITHUB_STEP_SUMMARY
fi

- name: Upload results
if: always()
uses: actions/upload-artifact@v4
with:
name: accuracy-microbench
path: |
benchmarks/native/accuracy_report.md
benchmarks/native/accuracy_results.json
benchmarks/native/accuracy_figure.png
benchmarks/native/accuracy_normalized.pdf
retention-days: 90
176 changes: 176 additions & 0 deletions .github/workflows/accuracy-polybench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Accuracy - PolyBench

on:
push:
branches: [main]
paths:
- 'benchmarks/polybench/**'
- 'benchmarks/polybench_test.go'
- 'benchmarks/timing_harness.go'
- 'timing/**'
workflow_dispatch:

concurrency:
group: accuracy-polybench-${{ github.ref }}
cancel-in-progress: false

jobs:
polybench-group-1:
name: PolyBench Group 1 (ATAX, BiCG, Jacobi1D)
runs-on: macos-14
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'

- name: Verify ELFs
run: |
ls -la benchmarks/polybench/atax_m2sim.elf
ls -la benchmarks/polybench/bicg_m2sim.elf
ls -la benchmarks/polybench/jacobi-1d_m2sim.elf

- name: Run tests
run: |
for TEST in TestPolybenchATAX TestPolybenchBiCG TestPolybenchJacobi1D; do
echo "--- $TEST ---"
go test -v -run "^${TEST}$" -count=1 -timeout 8m ./benchmarks/ 2>&1 | tee -a group1_output.txt || true
done

- name: Upload results
if: always()
uses: actions/upload-artifact@v4
with:
name: polybench-group-1
path: group1_output.txt
retention-days: 30

polybench-group-2:
name: PolyBench Group 2 (MVT, GEMM)
runs-on: macos-14
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'

- name: Verify ELFs
run: |
ls -la benchmarks/polybench/mvt_m2sim.elf
ls -la benchmarks/polybench/gemm_m2sim.elf

- name: Run tests
run: |
for TEST in TestPolybenchMVT TestPolybenchGEMM; do
echo "--- $TEST ---"
go test -v -run "^${TEST}$" -count=1 -timeout 8m ./benchmarks/ 2>&1 | tee -a group2_output.txt || true
done

- name: Upload results
if: always()
uses: actions/upload-artifact@v4
with:
name: polybench-group-2
path: group2_output.txt
retention-days: 30

polybench-group-3:
name: PolyBench Group 3 (2MM, 3MM)
runs-on: macos-14
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'

- name: Verify ELFs
run: |
ls -la benchmarks/polybench/2mm_m2sim.elf
ls -la benchmarks/polybench/3mm_m2sim.elf

- name: Run tests
run: |
for TEST in TestPolybench2MM TestPolybench3MM; do
echo "--- $TEST ---"
go test -v -run "^${TEST}$" -count=1 -timeout 8m ./benchmarks/ 2>&1 | tee -a group3_output.txt || true
done

- name: Upload results
if: always()
uses: actions/upload-artifact@v4
with:
name: polybench-group-3
path: group3_output.txt
retention-days: 30

consolidate:
name: Consolidate PolyBench Results
runs-on: ubuntu-latest
needs: [polybench-group-1, polybench-group-2, polybench-group-3]
if: always()
steps:
- uses: actions/checkout@v4

- name: Download results
uses: actions/download-artifact@v4
with:
path: group-results

- name: Extract CPI results
run: |
cat group-results/polybench-group-1/group1_output.txt > combined.txt 2>/dev/null || true
cat group-results/polybench-group-2/group2_output.txt >> combined.txt 2>/dev/null || true
cat group-results/polybench-group-3/group3_output.txt >> combined.txt 2>/dev/null || true

python3 - <<'PYEOF'
import json, re

results = {}
with open("combined.txt") as f:
for line in f:
if "CPI=" not in line:
continue
match = re.search(r'(polybench_\w+):\s+cycles=(\d+),\s+insts=(\d+),\s+CPI=([\d.]+)', line)
if match:
name = match.group(1).replace("polybench_", "")
if name == "jacobi1d":
name = "jacobi-1d"
results[name] = {
"cycles": int(match.group(2)),
"instructions": int(match.group(3)),
"cpi": float(match.group(4)),
}

output = {"benchmarks_run": len(results), "results": results}
with open("polybench_results.json", "w") as f:
json.dump(output, f, indent=2)
print(json.dumps(output, indent=2))
PYEOF

- name: Post summary
if: always()
run: |
echo "## PolyBench Accuracy Results" >> $GITHUB_STEP_SUMMARY
if [ -f polybench_results.json ]; then
python3 -c "
import json
d = json.load(open('polybench_results.json'))
print(f'**Benchmarks measured:** {d[\"benchmarks_run\"]}/7')
if d['results']:
print()
print('| Benchmark | CPI |')
print('|-----------|-----|')
for name, r in sorted(d['results'].items()):
print(f'| {name} | {r[\"cpi\"]:.3f} |')
" >> $GITHUB_STEP_SUMMARY
fi

- name: Upload consolidated results
uses: actions/upload-artifact@v4
with:
name: polybench-consolidated
path: polybench_results.json
retention-days: 90
Loading
Loading