Skip to content

Commit

Permalink
Add Bitwise Xor to Preprocessed Column Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Gali-StarkWare committed Jan 27, 2025
1 parent 2b943c5 commit 956615f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,41 @@ const fn preprocessed_log_sizes() -> [u32; N_PREPROCESSED_COLUMN_SIZES] {
pub enum PreProcessedColumn {
IsFirst(IsFirst),
Seq(Seq),
BitwiseXor(BitwiseXor),
}
impl PreProcessedColumn {
pub fn log_size(&self) -> u32 {
match self {
PreProcessedColumn::IsFirst(column) => column.log_size,
PreProcessedColumn::Seq(column) => column.log_size,
PreProcessedColumn::BitwiseXor(column) => column.column_bits(),
}
}

pub fn id(&self) -> PreProcessedColumnId {
match self {
PreProcessedColumn::IsFirst(column) => column.id(),
PreProcessedColumn::Seq(column) => column.id(),
PreProcessedColumn::BitwiseXor(column) => column.id(),
}
}

/// Generates a column according to the preprocessed column chosen.
pub fn gen_column_simd(&self) -> CircleEvaluation<SimdBackend, BaseField, BitReversedOrder> {
match self {
PreProcessedColumn::IsFirst(column) => column.gen_column_simd(),
PreProcessedColumn::Seq(column) => column.gen_column_simd(),
PreProcessedColumn::BitwiseXor(column) => column.gen_column_simd(),
}
}

/// Returns the values of the column at the given row.
pub fn packed_at(&self, vec_row: usize) -> PackedM31 {
assert!(vec_row < (1 << self.log_size()) / N_LANES);
match self {
PreProcessedColumn::IsFirst(column) => column.packed_at(vec_row),
PreProcessedColumn::Seq(column) => column.packed_at(vec_row),
PreProcessedColumn::BitwiseXor(column) => column.packed_at(vec_row),
}
}
}
Expand All @@ -84,7 +94,6 @@ impl Seq {
}

pub fn packed_at(&self, vec_row: usize) -> PackedM31 {
assert!(vec_row < (1 << self.log_size) / N_LANES);
PackedM31::broadcast(M31::from(vec_row * N_LANES))
+ unsafe { PackedM31::from_simd_unchecked(SIMD_ENUMERATION_0) }
}
Expand Down

0 comments on commit 956615f

Please sign in to comment.