Skip to content

Commit

Permalink
Revert "Parallelize calls to prover functions (#2176)" (#2188)
Browse files Browse the repository at this point in the history
This reverts commit d980c68 from
#2176
  • Loading branch information
leonardoalt authored Dec 3, 2024
1 parent d2e110f commit f11cf21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
31 changes: 6 additions & 25 deletions executor/src/witgen/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use powdr_ast::analyzed::PolynomialType;
use powdr_ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference, PolyID};

use powdr_number::{DegreeType, FieldElement};
use rayon::iter::{ParallelBridge, ParallelIterator};

use crate::witgen::affine_expression::AlgebraicVariable;
use crate::witgen::data_structures::mutable_state::MutableState;
Expand Down Expand Up @@ -221,7 +220,7 @@ impl<'a, 'c, T: FieldElement, Q: QueryCallback<T>> Processor<'a, 'c, T, Q> {
}

pub fn process_queries(&mut self, row_index: usize) -> Result<bool, EvalError<T>> {
let query_processor = QueryProcessor::new(
let mut query_processor = QueryProcessor::new(
self.fixed_data,
self.mutable_state.query_callback(),
self.size,
Expand All @@ -239,33 +238,15 @@ impl<'a, 'c, T: FieldElement, Q: QueryCallback<T>> Processor<'a, 'c, T, Q> {
);
let mut updates = EvalValue::complete(vec![]);

self.parts
.prover_functions
.iter()
.enumerate()
// Run all prover functions in parallel
.par_bridge()
.filter_map(|(i, fun)| {
if !self.processed_prover_functions.has_run(row_index, i) {
query_processor
.process_prover_function(&row_pair, fun)
.map(|result| Some((result, i)))
.transpose()
} else {
// Skip already processed functions
None
}
})
// Fail if any of the prover functions failed
.collect::<Result<Vec<_>, EvalError<T>>>()?
// Combine results
.into_iter()
.for_each(|(r, i)| {
for (i, fun) in self.parts.prover_functions.iter().enumerate() {
if !self.processed_prover_functions.has_run(row_index, i) {
let r = query_processor.process_prover_function(&row_pair, fun)?;
if r.is_complete() {
updates.combine(r);
self.processed_prover_functions.mark_as_run(row_index, i);
}
});
}
}

for poly_id in &self.prover_query_witnesses {
if let Some(r) = query_processor.process_query(&row_pair, poly_id) {
Expand Down
12 changes: 6 additions & 6 deletions executor/src/witgen/query_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ impl<'a, 'b, T: FieldElement, QueryCallback: super::QueryCallback<T>>
}
}

pub fn process_prover_function(
&self,
rows: &RowPair<'_, 'a, T>,
pub fn process_prover_function<'c>(
&'c mut self,
rows: &'c RowPair<'c, 'a, T>,
fun: &'a Expression,
) -> EvalResult<'a, T> {
let arguments = vec![Arc::new(Value::Integer(BigInt::from(u64::from(
Expand Down Expand Up @@ -77,7 +77,7 @@ impl<'a, 'b, T: FieldElement, QueryCallback: super::QueryCallback<T>>
/// Panics if the column does not have a query attached.
/// @returns None if the value for that column is already known.
pub fn process_query(
&self,
&mut self,
rows: &RowPair<'_, 'a, T>,
poly_id: &PolyID,
) -> Option<EvalResult<'a, T>> {
Expand All @@ -91,7 +91,7 @@ impl<'a, 'b, T: FieldElement, QueryCallback: super::QueryCallback<T>>
}

fn process_witness_query(
&self,
&mut self,
query: &'a Expression,
poly: &'a AlgebraicReference,
rows: &RowPair<'_, 'a, T>,
Expand Down Expand Up @@ -129,7 +129,7 @@ impl<'a, 'b, T: FieldElement, QueryCallback: super::QueryCallback<T>>
}

fn interpolate_query(
&self,
&mut self,
query: &'a Expression,
rows: &RowPair<'_, 'a, T>,
) -> Result<String, EvalError> {
Expand Down

0 comments on commit f11cf21

Please sign in to comment.