-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the benchmark I used for measuring the witness generation JIT in #2242.
- Loading branch information
1 parent
d5c8a1e
commit 64ce967
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use ::powdr_pipeline::Pipeline; | ||
use powdr_number::GoldilocksField; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
type T = GoldilocksField; | ||
|
||
fn jit_witgen_benchmark(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("jit-witgen-benchmark"); | ||
group.sample_size(10); | ||
|
||
// Poseidon benchmark | ||
let mut pipeline = | ||
Pipeline::<T>::default().from_file("../test_data/std/poseidon_benchmark.asm".into()); | ||
pipeline.compute_optimized_pil().unwrap(); | ||
pipeline.compute_fixed_cols().unwrap(); | ||
|
||
group.bench_function("jit_witgen_benchmark", |b| { | ||
b.iter(|| pipeline.clone().compute_witness().unwrap()) | ||
}); | ||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches_jit_witgen, jit_witgen_benchmark); | ||
criterion_main!(benches_jit_witgen); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::machines::hash::poseidon_gl::PoseidonGL; | ||
|
||
// 2^17 rows -> ~2^16 Poseidon hashes | ||
machine Main with degree: 131072 { | ||
reg pc[@pc]; | ||
reg X0[<=]; | ||
reg X1[<=]; | ||
reg X2[<=]; | ||
reg X3[<=]; | ||
reg X4[<=]; | ||
reg A; | ||
reg B; | ||
reg C; | ||
reg D; | ||
|
||
// 2^16 Poseidon hashes -> 2^21 rows in Poseidon machine | ||
PoseidonGL poseidon(2097152, 2097152); | ||
|
||
instr jmp l: label { pc' = l } | ||
|
||
// Hash some constants (except the first element, to trick the loop detection) | ||
instr poseidon X4 -> X0, X1, X2, X3 | ||
link ~> (X0, X1, X2, X3) = poseidon.poseidon_permutation(X4, 235763497586, 9827635653498, 112870, 289273673480943876, 230295874986745876, 6254867324987, 2087, 0, 0, 0, 0); | ||
|
||
function main { | ||
|
||
loop: | ||
A, B, C, D <== poseidon(A); | ||
jmp loop; | ||
|
||
return; | ||
} | ||
} |