mirror of
https://github.com/arnaucube/hyperplonk.git
synced 2026-01-11 16:41:28 +01:00
enabling batch opening and mock tests (#80)
- add mock circuits - add vanilla and jellyfish plonk gates - performance tuning
This commit is contained in:
29
util/src/lib.rs
Normal file
29
util/src/lib.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2022 Espresso Systems (espressosys.com)
|
||||
// This file is part of the Jellyfish library.
|
||||
// You should have received a copy of the MIT License
|
||||
// along with the Jellyfish library. If not, see <https://mit-license.org/>.
|
||||
|
||||
//! Utilities for parallel code.
|
||||
|
||||
/// this function helps with slice iterator creation that optionally use
|
||||
/// `par_iter()` when feature flag `parallel` is on.
|
||||
///
|
||||
/// # Usage
|
||||
/// let v = [1, 2, 3, 4, 5];
|
||||
/// let sum = parallelizable_slice_iter(&v).sum();
|
||||
///
|
||||
/// // the above code is a shorthand for (thus equivalent to)
|
||||
/// #[cfg(feature = "parallel")]
|
||||
/// let sum = v.par_iter().sum();
|
||||
/// #[cfg(not(feature = "parallel"))]
|
||||
/// let sum = v.iter().sum();
|
||||
#[cfg(feature = "parallel")]
|
||||
pub fn parallelizable_slice_iter<T: Sync>(data: &[T]) -> rayon::slice::Iter<T> {
|
||||
use rayon::iter::IntoParallelIterator;
|
||||
data.into_par_iter()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "parallel"))]
|
||||
pub fn parallelizable_slice_iter<T>(data: &[T]) -> core::slice::Iter<T> {
|
||||
data.iter()
|
||||
}
|
||||
Reference in New Issue
Block a user