Skip to content

Commit 2f107bf

Browse files
committed
feat: using p3-maybe-rayon for whir crate
1 parent 6b51692 commit 2f107bf

File tree

15 files changed

+27
-30
lines changed

15 files changed

+27
-30
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/whir/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ clap.workspace = true
1818
ff_ext = { path = "../ff_ext" }
1919
multilinear_extensions = { path = "../multilinear_extensions" }
2020
p3.workspace = true
21+
p3-maybe-rayon.workspace = true
2122
rand = "0.8"
2223
rand_chacha = "0.3"
2324
rayon = { workspace = true, optional = true }
@@ -42,6 +43,6 @@ nightly-features = [
4243
"transcript/nightly-features",
4344
"witness/nightly-features",
4445
]
45-
parallel = ["dep:rayon"]
46+
parallel = ["p3-maybe-rayon/parallel","dep:rayon"]
4647
print-trace = ["tracing/log"]
4748
rayon = ["dep:rayon"]

crates/whir/src/crypto/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use p3::{
55
Dimensions,
66
dense::{DenseMatrix, RowMajorMatrix},
77
},
8+
maybe_rayon::prelude::*,
89
};
9-
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
1010
use serde::{Deserialize, Serialize, de::DeserializeOwned};
1111
use transcript::Transcript;
1212

crates/whir/src/ntt/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ mod wavelet;
99

1010
use self::matrix::MatrixMut;
1111

12+
#[cfg(feature = "parallel")]
13+
use p3::maybe_rayon::prelude::*;
1214
use p3::{
1315
dft::{Radix2DitParallel, TwoAdicSubgroupDft},
1416
field::TwoAdicField,
1517
matrix::Matrix,
1618
};
17-
#[cfg(feature = "parallel")]
18-
use rayon::prelude::*;
1919
use tracing::instrument;
2020
use witness::{InstancePaddingStrategy, RowMajorMatrix};
2121

crates/whir/src/ntt/transpose.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ use crate::ntt::matrix_skip::MatrixMutSkip;
33
use super::{super::utils::is_power_of_two, MatrixMut, utils::workload_size};
44
use std::mem::swap;
55

6-
use p3::matrix::{Matrix, dense::RowMajorMatrix};
7-
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator};
6+
use p3::{
7+
matrix::{Matrix, dense::RowMajorMatrix},
8+
maybe_rayon::prelude::*,
9+
};
810
#[cfg(feature = "parallel")]
911
use rayon::join;
1012
use sumcheck::macros::{entered_span, exit_span};

crates/whir/src/ntt/wavelet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use p3::field::Field;
33
use std::cmp::max;
44

55
#[cfg(feature = "parallel")]
6-
use rayon::prelude::*;
6+
use p3::maybe_rayon::prelude::*;
77

88
/// Fast Wavelet Transform.
99
///

crates/whir/src/sumcheck/prover_batched.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::proof::SumcheckPolynomial;
22
use crate::sumcheck::prover_single::SumcheckSingle;
33
use ff_ext::ExtensionField;
4-
use p3::{field::Field, util::log2_strict_usize};
4+
use p3::{field::Field, maybe_rayon::prelude::*, util::log2_strict_usize};
55
#[cfg(feature = "parallel")]
6-
use rayon::{join, prelude::*};
6+
use rayon::join;
77

88
pub struct SumcheckBatched<F: ExtensionField> {
99
// The evaluation on each p and eq

crates/whir/src/sumcheck/prover_single.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::proof::SumcheckPolynomial;
22

33
use ff_ext::ExtensionField;
4-
use p3::util::log2_strict_usize;
4+
use p3::{maybe_rayon::prelude::*, util::log2_strict_usize};
55
#[cfg(feature = "parallel")]
6-
use rayon::{join, prelude::*};
6+
use rayon::join;
77

88
pub struct SumcheckSingle<E: ExtensionField> {
99
// The evaluation of p
@@ -261,12 +261,10 @@ mod tests {
261261

262262
let eval = MultilinearExtension::from_evaluations_ext_vec(2, polynomial.clone())
263263
.evaluate(&eval_point);
264-
let mut prover = SumcheckSingle::new(
265-
polynomial,
266-
&[eval_point],
267-
&[E::from_canonical_u64(1)],
268-
&[eval],
269-
);
264+
let mut prover =
265+
SumcheckSingle::new(polynomial, &[eval_point], &[E::from_canonical_u64(1)], &[
266+
eval,
267+
]);
270268

271269
let poly_1 = prover.compute_sumcheck_polynomial();
272270

crates/whir/src/utils.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ use multilinear_extensions::mle::FieldType;
44
use p3::{
55
field::Field,
66
matrix::{Matrix, dense::RowMajorMatrix},
7-
};
8-
use rayon::{
9-
iter::ParallelIterator,
10-
slice::{ParallelSlice, ParallelSliceMut},
7+
maybe_rayon::prelude::*,
118
};
129
use std::collections::BTreeSet;
1310
use sumcheck::macros::{entered_span, exit_span};

crates/whir/src/whir/batch/committer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use sumcheck::macros::{entered_span, exit_span};
1919
use transcript::{BasicTranscript, Transcript};
2020

2121
#[cfg(feature = "parallel")]
22-
use rayon::prelude::*;
22+
use p3::maybe_rayon::prelude::*;
2323

2424
#[derive(Debug)]
2525
pub struct Witnesses<E: ExtensionField> {

0 commit comments

Comments
 (0)