Skip to content

Commit 8c2d6af

Browse files
committed
fix(new-execution): make rv32im hintstore work (#1616)
- make `Rv32HintStoreChip` use the `NewVmChipWrapper` - rename `SingleTraceStep` to `TraceStep` and update it to work for chips whose execution creates multiple trace rows - comment out criterion execute benchmarks for now
1 parent e885ec0 commit 8c2d6af

File tree

30 files changed

+581
-398
lines changed

30 files changed

+581
-398
lines changed

Cargo.lock

Lines changed: 64 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks/execute/Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ tracing-subscriber = { version = "0.3.17", features = ["std", "env-filter"] }
2828

2929
[dev-dependencies]
3030
criterion = { version = "0.5", features = ["html_reports"] }
31+
divan = { version = "0.1.21" }
3132

3233
[features]
3334
default = ["jemalloc"]
@@ -37,12 +38,16 @@ jemalloc-prof = ["openvm-circuit/jemalloc-prof"]
3738
nightly-features = ["openvm-circuit/nightly-features"]
3839
profiling = ["openvm-circuit/function-span", "openvm-transpiler/function-span"]
3940

40-
[[bench]]
41-
name = "fibonacci_execute"
42-
harness = false
41+
# [[bench]]
42+
# name = "fibonacci_execute"
43+
# harness = false
44+
45+
# [[bench]]
46+
# name = "regex_execute"
47+
# harness = false
4348

4449
[[bench]]
45-
name = "regex_execute"
50+
name = "execute"
4651
harness = false
4752

4853
[package.metadata.cargo-shear]
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
use divan;
2+
use eyre::Result;
3+
use openvm_benchmarks_utils::{get_elf_path, get_programs_dir, read_elf_file};
4+
use openvm_circuit::arch::{instructions::exe::VmExe, VmExecutor};
5+
use openvm_rv32im_circuit::Rv32ImConfig;
6+
use openvm_rv32im_transpiler::{
7+
Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension,
8+
};
9+
use openvm_stark_sdk::p3_baby_bear::BabyBear;
10+
use openvm_transpiler::{transpiler::Transpiler, FromElf};
11+
use std::path::PathBuf;
12+
13+
static AVAILABLE_PROGRAMS: &[&str] = &[
14+
"fibonacci_recursive",
15+
"fibonacci_iterative",
16+
"quicksort",
17+
"bubblesort",
18+
// "pairing",
19+
// "keccak256",
20+
// "keccak256_iter",
21+
// "sha256",
22+
// "sha256_iter",
23+
// "revm_transfer",
24+
// "revm_snailtracer",
25+
];
26+
27+
fn main() {
28+
divan::main();
29+
}
30+
31+
/// Run a specific OpenVM program
32+
fn run_program(program: &str) -> Result<()> {
33+
let program_dir = get_programs_dir().join(program);
34+
let elf_path = get_elf_path(&program_dir);
35+
let elf = read_elf_file(&elf_path)?;
36+
37+
let vm_config = Rv32ImConfig::default();
38+
39+
let transpiler = Transpiler::<BabyBear>::default()
40+
.with_extension(Rv32ITranspilerExtension)
41+
.with_extension(Rv32IoTranspilerExtension)
42+
.with_extension(Rv32MTranspilerExtension);
43+
44+
let exe = VmExe::from_elf(elf, transpiler)?;
45+
46+
let executor = VmExecutor::new(vm_config);
47+
executor
48+
.execute_e1(exe, vec![])
49+
.expect("Failed to execute program");
50+
51+
Ok(())
52+
}
53+
54+
#[divan::bench(args = AVAILABLE_PROGRAMS, sample_count=10)]
55+
fn benchmark_execute(program: &str) {
56+
run_program(program).unwrap();
57+
}

benchmarks/execute/benches/fibonacci_execute.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use openvm_rv32im_circuit::Rv32ImConfig;
55
use openvm_rv32im_transpiler::{
66
Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension,
77
};
8-
use openvm_sdk::StdIn;
8+
// TODO(ayush): add this back
9+
// use openvm_sdk::StdIn;
910
use openvm_stark_sdk::p3_baby_bear::BabyBear;
1011
use openvm_transpiler::{transpiler::Transpiler, FromElf};
1112

@@ -28,10 +29,11 @@ fn benchmark_function(c: &mut Criterion) {
2829

2930
group.bench_function("execute", |b| {
3031
b.iter(|| {
31-
let n = 100_000u64;
32-
let mut stdin = StdIn::default();
33-
stdin.write(&n);
34-
executor.execute(exe.clone(), stdin).unwrap();
32+
// TODO(ayush): add this back
33+
// let n = 100_000u64;
34+
// let mut stdin = StdIn::default();
35+
// stdin.write(&n);
36+
executor.execute(exe.clone(), vec![]).unwrap();
3537
})
3638
});
3739

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
2-
use openvm_benchmarks_utils::{build_elf, get_programs_dir};
3-
use openvm_circuit::arch::{instructions::exe::VmExe, VmExecutor};
4-
use openvm_keccak256_circuit::Keccak256Rv32Config;
5-
use openvm_keccak256_transpiler::Keccak256TranspilerExtension;
6-
use openvm_rv32im_transpiler::{
7-
Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension,
8-
};
9-
use openvm_sdk::StdIn;
10-
use openvm_stark_sdk::p3_baby_bear::BabyBear;
11-
use openvm_transpiler::{transpiler::Transpiler, FromElf};
1+
// TODO(ayush): add this back
2+
// use criterion::{black_box, criterion_group, criterion_main, Criterion};
3+
// use openvm_benchmarks_utils::{build_elf, get_programs_dir};
4+
// use openvm_circuit::arch::{instructions::exe::VmExe, VmExecutor};
5+
// use openvm_keccak256_circuit::Keccak256Rv32Config;
6+
// use openvm_keccak256_transpiler::Keccak256TranspilerExtension;
7+
// use openvm_rv32im_transpiler::{
8+
// Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension,
9+
// };
10+
// use openvm_sdk::StdIn;
11+
// use openvm_stark_sdk::p3_baby_bear::BabyBear;
12+
// use openvm_transpiler::{transpiler::Transpiler, FromElf};
1213

13-
fn benchmark_function(c: &mut Criterion) {
14-
let program_dir = get_programs_dir().join("regex");
15-
let elf = build_elf(&program_dir, "release").unwrap();
14+
// fn benchmark_function(c: &mut Criterion) {
15+
// let program_dir = get_programs_dir().join("regex");
16+
// let elf = build_elf(&program_dir, "release").unwrap();
1617

17-
let exe = VmExe::from_elf(
18-
elf,
19-
Transpiler::<BabyBear>::default()
20-
.with_extension(Rv32ITranspilerExtension)
21-
.with_extension(Rv32MTranspilerExtension)
22-
.with_extension(Rv32IoTranspilerExtension)
23-
.with_extension(Keccak256TranspilerExtension),
24-
)
25-
.unwrap();
18+
// let exe = VmExe::from_elf(
19+
// elf,
20+
// Transpiler::<BabyBear>::default()
21+
// .with_extension(Rv32ITranspilerExtension)
22+
// .with_extension(Rv32MTranspilerExtension)
23+
// .with_extension(Rv32IoTranspilerExtension)
24+
// .with_extension(Keccak256TranspilerExtension),
25+
// )
26+
// .unwrap();
2627

27-
let mut group = c.benchmark_group("regex");
28-
group.sample_size(10);
29-
let config = Keccak256Rv32Config::default();
30-
let executor = VmExecutor::<BabyBear, Keccak256Rv32Config>::new(config);
28+
// let mut group = c.benchmark_group("regex");
29+
// group.sample_size(10);
30+
// let config = Keccak256Rv32Config::default();
31+
// let executor = VmExecutor::<BabyBear, Keccak256Rv32Config>::new(config);
3132

32-
let data = include_str!("../../guest/regex/regex_email.txt");
33+
// let data = include_str!("../../guest/regex/regex_email.txt");
3334

34-
let fe_bytes = data.to_owned().into_bytes();
35-
group.bench_function("execute", |b| {
36-
b.iter(|| {
37-
executor
38-
.execute(exe.clone(), black_box(StdIn::from_bytes(&fe_bytes)))
39-
.unwrap();
40-
})
41-
});
35+
// let fe_bytes = data.to_owned().into_bytes();
36+
// group.bench_function("execute", |b| {
37+
// b.iter(|| {
38+
// let input = black_box(Stdin::from_bytes(&fe_bytes));
39+
// executor.execute(exe.clone(), input).unwrap();
40+
// })
41+
// });
4242

43-
group.finish();
44-
}
43+
// group.finish();
44+
// }
4545

46-
criterion_group!(benches, benchmark_function);
47-
criterion_main!(benches);
46+
// criterion_group!(benches, benchmark_function);
47+
// criterion_main!(benches);

crates/vm/src/arch/execution_control.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ where
2626
fn new(chip_complex: &VmChipComplex<F, VC::Executor, VC::Periphery>) -> Self;
2727

2828
/// Determines if execution should stop
29+
// TODO(ayush): rename to should_suspend
2930
fn should_stop(&mut self, chip_complex: &VmChipComplex<F, VC::Executor, VC::Periphery>)
3031
-> bool;
3132

0 commit comments

Comments
 (0)