Skip to content

Commit

Permalink
parralelize ret (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohad-starkware authored Dec 10, 2024
1 parent 3e2a64a commit bd162f3
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 93 deletions.
1 change: 1 addition & 0 deletions stwo_cairo_prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions stwo_cairo_prover/crates/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "stwo_cairo_prover"
version = "0.1.0"
edition = "2021"

[features]
parallel = ["rayon"]

[dependencies]
bytemuck.workspace = true
cairo-lang-casm.workspace = true
Expand All @@ -17,6 +20,7 @@ thiserror.workspace = true
tracing.workspace = true
paste.workspace = true
prover_types = { path = "../prover_types" }
rayon = { version = "1.10.0", optional = true }

[dev-dependencies]
cairo-lang-casm.workspace = true
Expand Down
25 changes: 25 additions & 0 deletions stwo_cairo_prover/crates/prover/src/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use std::array;
use std::cell::UnsafeCell;

use prover_types::simd::N_LANES;
use stwo_prover::core::backend::simd::column::BaseColumn;
use stwo_prover::core::backend::simd::conversion::Pack;
use stwo_prover::core::backend::Column;

pub mod add_ap_opcode_is_imm_f_op1_base_fp_f;
pub mod add_ap_opcode_is_imm_f_op1_base_fp_t;
Expand Down Expand Up @@ -47,3 +52,23 @@ pub fn pack_values<T: Pack>(values: &[T]) -> Vec<T::SimdType> {
.map(|c| T::pack(*c))
.collect()
}

// TODO(Ohad): move to another file.
struct ThreadSafeTrace<const N: usize> {
data: [UnsafeCell<BaseColumn>; N],
}

unsafe impl<const N: usize> Send for ThreadSafeTrace<N> {}
unsafe impl<const N: usize> Sync for ThreadSafeTrace<N> {}

impl<const N: usize> ThreadSafeTrace<N> {
fn new(rows: usize) -> Self {
Self {
data: array::from_fn(|_| UnsafeCell::new(unsafe { BaseColumn::uninitialized(rows) })),
}
}

pub fn inner(self) -> [BaseColumn; N] {
self.data.map(|c| c.into_inner())
}
}
Loading

0 comments on commit bd162f3

Please sign in to comment.