mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-06 15:53:10 +00:00
Fix some warnings (#94)
This commit is contained in:
parent
c678c55452
commit
83a1430038
@ -1,3 +1,4 @@
|
||||
use std::convert::TryInto;
|
||||
use std::thread;
|
||||
use std::time::Instant;
|
||||
|
||||
@ -15,15 +16,12 @@ fn main() {
|
||||
const THREADS: usize = 12;
|
||||
const LDE_BITS: i32 = 3;
|
||||
const W: usize = 12;
|
||||
const HASHES_PER_POLY: usize = 1 << (13 + LDE_BITS) / 6;
|
||||
const HASHES_PER_POLY: usize = 1 << ((13 + LDE_BITS) / 6);
|
||||
|
||||
let threads = (0..THREADS)
|
||||
.map(|_i| {
|
||||
thread::spawn(move || {
|
||||
let mut x = [F::ZERO; W];
|
||||
for i in 0..W {
|
||||
x[i] = F::from_canonical_u64((i as u64) * 123456 + 789);
|
||||
}
|
||||
let mut x: [F; W] = F::rand_vec(W).try_into().unwrap();
|
||||
|
||||
let hashes_per_thread = HASHES_PER_POLY * PROVER_POLYS / THREADS;
|
||||
let start = Instant::now();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use std::convert::TryInto;
|
||||
use std::thread;
|
||||
use std::time::Instant;
|
||||
|
||||
@ -19,10 +20,7 @@ fn main() {
|
||||
let threads = (0..THREADS)
|
||||
.map(|_i| {
|
||||
thread::spawn(move || {
|
||||
let mut x = [F::ZERO; W];
|
||||
for i in 0..W {
|
||||
x[i] = F::from_canonical_u64((i as u64) * 123456 + 789);
|
||||
}
|
||||
let mut x: [F; W] = F::rand_vec(W).try_into().unwrap();
|
||||
|
||||
let hashes_per_thread = HASHES_PER_POLY * PROVER_POLYS / THREADS;
|
||||
let start = Instant::now();
|
||||
|
||||
@ -250,9 +250,9 @@ fn fft_unrolled<F: Field>(input: Vec<F>, r_orig: usize, root_table: FftRootTable
|
||||
// NB: Grouping statements as is done in the main loop below
|
||||
// does not seem to help here (worse by a few millis).
|
||||
let omega_0 = root_table[0][0];
|
||||
let tmp_0 = omega_0 * values[k + 2 + 0];
|
||||
values[k + 2 + 0] = values[k + 0] - tmp_0;
|
||||
values[k + 0] += tmp_0;
|
||||
let tmp_0 = omega_0 * values[k + 2];
|
||||
values[k + 2] = values[k] - tmp_0;
|
||||
values[k] += tmp_0;
|
||||
|
||||
let omega_1 = root_table[0][1];
|
||||
let tmp_1 = omega_1 * values[k + 2 + 1];
|
||||
@ -281,21 +281,21 @@ fn fft_unrolled<F: Field>(input: Vec<F>, r_orig: usize, root_table: FftRootTable
|
||||
let off1 = k + j;
|
||||
let off2 = k + m + j;
|
||||
|
||||
let omega_0 = root_table[lg_m - 1][j + 0];
|
||||
let omega_0 = root_table[lg_m - 1][j];
|
||||
let omega_1 = root_table[lg_m - 1][j + 1];
|
||||
let omega_2 = root_table[lg_m - 1][j + 2];
|
||||
let omega_3 = root_table[lg_m - 1][j + 3];
|
||||
|
||||
let tmp_0 = omega_0 * values[off2 + 0];
|
||||
let tmp_0 = omega_0 * values[off2];
|
||||
let tmp_1 = omega_1 * values[off2 + 1];
|
||||
let tmp_2 = omega_2 * values[off2 + 2];
|
||||
let tmp_3 = omega_3 * values[off2 + 3];
|
||||
|
||||
values[off2 + 0] = values[off1 + 0] - tmp_0;
|
||||
values[off2] = values[off1] - tmp_0;
|
||||
values[off2 + 1] = values[off1 + 1] - tmp_1;
|
||||
values[off2 + 2] = values[off1 + 2] - tmp_2;
|
||||
values[off2 + 3] = values[off1 + 3] - tmp_3;
|
||||
values[off1 + 0] += tmp_0;
|
||||
values[off1] += tmp_0;
|
||||
values[off1 + 1] += tmp_1;
|
||||
values[off1 + 2] += tmp_2;
|
||||
values[off1 + 3] += tmp_3;
|
||||
|
||||
@ -131,7 +131,7 @@ pub trait Field:
|
||||
|
||||
fn primitive_root_of_unity(n_log: usize) -> Self {
|
||||
assert!(n_log <= Self::TWO_ADICITY);
|
||||
let mut base = Self::POWER_OF_TWO_GENERATOR;
|
||||
let base = Self::POWER_OF_TWO_GENERATOR;
|
||||
base.exp_power_of_2(Self::TWO_ADICITY - n_log)
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,6 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
new_list.push(new_item);
|
||||
}
|
||||
|
||||
|
||||
new_list
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
// Gates have `new` methods that return `GateRef`s.
|
||||
#![allow(clippy::new_ret_no_self)]
|
||||
|
||||
pub mod arithmetic;
|
||||
pub mod base_sum;
|
||||
pub mod constant;
|
||||
|
||||
@ -56,8 +56,8 @@ pub fn gmimc_permute_array<F: Field, const W: usize, const R: usize>(
|
||||
xs[active] -= f;
|
||||
}
|
||||
|
||||
for i in 0..W {
|
||||
xs[i] += addition_buffer;
|
||||
for x_i in xs.iter_mut() {
|
||||
*x_i += addition_buffer;
|
||||
}
|
||||
|
||||
xs
|
||||
|
||||
10
src/hash.rs
10
src/hash.rs
@ -117,12 +117,6 @@ pub const GMIMC_CONSTANTS: [u64; GMIMC_ROUNDS] = [
|
||||
8651171085167737860,
|
||||
];
|
||||
|
||||
/// Controls the granularity of parallelization when building Merkle trees. I.e., we will try to
|
||||
/// split up the task into units of work, such that each unit involves hashing roughly this many
|
||||
/// elements. If this is too small, there may be too much synchronization overhead; if it's too
|
||||
/// large, some threads may spend significant time idle.
|
||||
const ELEMS_PER_CHUNK: usize = 1 << 8;
|
||||
|
||||
/// Hash the vector if necessary to reduce its length to ~256 bits. If it already fits, this is a
|
||||
/// no-op.
|
||||
pub fn hash_or_noop<F: Field>(inputs: Vec<F>) -> Hash<F> {
|
||||
@ -226,8 +220,8 @@ pub fn hash_n_to_m<F: Field>(mut inputs: Vec<F>, num_outputs: usize, pad: bool)
|
||||
// Squeeze until we have the desired number of outputs.
|
||||
let mut outputs = Vec::new();
|
||||
loop {
|
||||
for i in 0..SPONGE_RATE {
|
||||
outputs.push(state[i]);
|
||||
for &item in state.iter().take(SPONGE_RATE) {
|
||||
outputs.push(item);
|
||||
if outputs.len() == num_outputs {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ impl<T: Debug + Copy + Eq + PartialEq + Hash, F: Fn(T) -> usize> TargetPartition
|
||||
}
|
||||
|
||||
/// Path compression method, see https://en.wikipedia.org/wiki/Disjoint-set_data_structure#Finding_set_representatives.
|
||||
pub fn find(&mut self, mut x: ForestNode<T>) -> ForestNode<T> {
|
||||
pub fn find(&mut self, x: ForestNode<T>) -> ForestNode<T> {
|
||||
if x.parent != x.index {
|
||||
let root = self.find(self.forest[x.parent]);
|
||||
self.forest[x.index].parent = root.index;
|
||||
|
||||
@ -287,6 +287,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::circuit_data::CircuitConfig;
|
||||
use crate::fri::FriConfig;
|
||||
use crate::plonk_common::PlonkPolynomials;
|
||||
|
||||
fn gen_random_test_case<F: Field + Extendable<D>, const D: usize>(
|
||||
|
||||
@ -80,7 +80,7 @@ pub(crate) fn prove<F: Extendable<D>, const D: usize>(
|
||||
let gammas = challenger.get_n_challenges(num_challenges);
|
||||
|
||||
assert!(
|
||||
common_data.quotient_degree_factor + 1 <=common_data.config.num_routed_wires,
|
||||
common_data.quotient_degree_factor < common_data.config.num_routed_wires,
|
||||
"When the number of routed wires is smaller that the degree, we should change the logic to avoid computing partial products."
|
||||
);
|
||||
let mut partial_products = timed!(
|
||||
|
||||
@ -179,7 +179,7 @@ const MDS: [[u64; W]; W] = [
|
||||
],
|
||||
];
|
||||
|
||||
const RESCUE_CONSTANTS: [[u64; W]; 16] = [
|
||||
const RESCUE_CONSTANTS: [[u64; W]; ROUNDS * 2] = [
|
||||
[
|
||||
12050887499329086906,
|
||||
1748247961703512657,
|
||||
@ -442,7 +442,7 @@ fn mds_layer<F: Field>(x: [F; W]) -> [F; W] {
|
||||
let mut result = [F::ZERO; W];
|
||||
for r in 0..W {
|
||||
for c in 0..W {
|
||||
result[r] = result[r] + F::from_canonical_u64(MDS[r][c]) * x[c];
|
||||
result[r] += F::from_canonical_u64(MDS[r][c]) * x[c];
|
||||
}
|
||||
}
|
||||
result
|
||||
|
||||
@ -42,8 +42,8 @@ pub(crate) fn transpose<T: Clone>(matrix: &[Vec<T>]) -> Vec<Vec<T>> {
|
||||
let old_cols = matrix[0].len();
|
||||
let mut transposed = vec![Vec::with_capacity(old_rows); old_cols];
|
||||
for new_r in 0..old_cols {
|
||||
for new_c in 0..old_rows {
|
||||
transposed[new_r].push(matrix[new_c][new_r].clone());
|
||||
for old_row in matrix.iter() {
|
||||
transposed[new_r].push(old_row[new_r].clone());
|
||||
}
|
||||
}
|
||||
transposed
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user