Skip to content

Commit

Permalink
use par invert
Browse files Browse the repository at this point in the history
  • Loading branch information
kunxian-xia committed Nov 15, 2023
1 parent e837827 commit ee957d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions halo2_proofs/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ where
q
}

pub fn par_invert<F: Field>(values: &mut [F]) {
parallelize(values, |values, _start| {
values.batch_invert();
});
}

/// This simple utility function will parallelize an operation that is to be
/// performed over a mutable slice.
pub(crate) fn parallelize_internal<T: Send, F: Fn(&mut [T], usize) + Send + Sync + Clone>(
Expand Down
8 changes: 3 additions & 5 deletions halo2_proofs/src/plonk/mv_lookup/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use std::{
ops::{Mul, MulAssign},
};

use crate::arithmetic::parallelize_internal;
use crate::arithmetic::{par_invert, parallelize_internal};
use rayon::prelude::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};

#[derive(Debug)]
Expand Down Expand Up @@ -256,8 +256,7 @@ impl<C: CurveAffine> Prepared<C> {
},
);
let inputs_inv_time = start_timer!(|| "batch invert");
// TODO: use parallelized batch invert
input_log_derivatives.iter_mut().batch_invert();
par_invert(input_log_derivatives.as_mut_slice());
end_timer!(inputs_inv_time);

// TODO: remove last blinders from this
Expand All @@ -283,8 +282,7 @@ impl<C: CurveAffine> Prepared<C> {
);

let table_inv_time = start_timer!(|| "table batch invert");
// TODO: use parallelized batch invert
table_log_derivatives.iter_mut().batch_invert();
par_invert(table_log_derivatives.as_mut_slice());
end_timer!(table_inv_time);
end_timer!(table_log_drv_time);

Expand Down

0 comments on commit ee957d8

Please sign in to comment.