From ee957d8fe67e1b803481e7cc84813f5c9c949eec Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Wed, 15 Nov 2023 19:21:48 +0800 Subject: [PATCH] use par invert --- halo2_proofs/src/arithmetic.rs | 6 ++++++ halo2_proofs/src/plonk/mv_lookup/prover.rs | 8 +++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/halo2_proofs/src/arithmetic.rs b/halo2_proofs/src/arithmetic.rs index e820e80f06..fa8c801aee 100644 --- a/halo2_proofs/src/arithmetic.rs +++ b/halo2_proofs/src/arithmetic.rs @@ -532,6 +532,12 @@ where q } +pub fn par_invert(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( diff --git a/halo2_proofs/src/plonk/mv_lookup/prover.rs b/halo2_proofs/src/plonk/mv_lookup/prover.rs index 59e11878a3..defe88b192 100644 --- a/halo2_proofs/src/plonk/mv_lookup/prover.rs +++ b/halo2_proofs/src/plonk/mv_lookup/prover.rs @@ -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)] @@ -256,8 +256,7 @@ impl Prepared { }, ); 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 @@ -283,8 +282,7 @@ impl Prepared { ); 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);