Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fork update feb 26 for AVX error #25

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion baby-bear/src/baby_bear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ fn monty_reduce(x: u64) -> u32 {

#[cfg(test)]
mod tests {
use p3_field::PrimeField64;
use p3_field_testing::{test_field, test_two_adic_field};

use super::*;
Expand Down
10 changes: 7 additions & 3 deletions baby-bear/src/x86_64_avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::iter::{Product, Sum};
use core::mem::transmute;
use core::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};

use p3_field::{AbstractField, Field, PackedField};
use p3_field::{AbstractField, Field, PackedField, PackedValue};
use rand::distributions::{Distribution, Standard};
use rand::Rng;

Expand Down Expand Up @@ -604,8 +604,8 @@ fn interleave4(a: __m256i, b: __m256i) -> (__m256i, __m256i) {
}
}

unsafe impl PackedField for PackedBabyBearAVX2 {
type Scalar = BabyBear;
unsafe impl PackedValue for PackedBabyBearAVX2 {
type Value = BabyBear;

const WIDTH: usize = WIDTH;

Expand Down Expand Up @@ -645,6 +645,10 @@ unsafe impl PackedField for PackedBabyBearAVX2 {
fn as_slice_mut(&mut self) -> &mut [BabyBear] {
&mut self.0[..]
}
}

unsafe impl PackedField for PackedBabyBearAVX2 {
type Scalar = BabyBear;

#[inline]
fn interleave(&self, other: Self, block_len: usize) -> (Self, Self) {
Expand Down
1 change: 0 additions & 1 deletion brakedown/src/brakedown_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ where
#[cfg(test)]
#[allow(deprecated)] // TODO: remove when `p3_lde::NaiveUndefinedLde` is gone
mod tests {
use p3_matrix::Matrix;
use p3_mersenne_31::Mersenne31;
use rand::SeedableRng;
use rand_chacha::ChaCha20Rng;
Expand Down
2 changes: 1 addition & 1 deletion challenger/src/duplex_challenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where
mod tests {
use p3_field::AbstractField;
use p3_goldilocks::Goldilocks;
use p3_symmetric::{CryptographicPermutation, Permutation};
use p3_symmetric::Permutation;

use super::*;

Expand Down
13 changes: 9 additions & 4 deletions challenger/src/serializing_challenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,16 @@ where
Inner: CanSample<u8>,
{
fn sample(&mut self) -> EF {
let log_size = log2_ceil_u64(F::ORDER_U64).saturating_sub(1);
let bound = (1 << log_size) - 1;
let sample_base = |inner: &mut Inner| {
let modulus = F::ORDER_U64;
let log_size = log2_ceil_u64(F::ORDER_U64);
let pow_of_two_bound = (1 << log_size) - 1;
// Perform rejection sampling over the uniform range (0..log2_ceil(p))
let sample_base = |inner: &mut Inner| loop {
let value = u64::from_le_bytes(inner.sample_array::<8>());
F::from_canonical_u64(value & bound)
let value = value & pow_of_two_bound;
if value < modulus {
return F::from_canonical_u64(value);
}
};
EF::from_base_fn(|_| sample_base(&mut self.inner))
}
Expand Down
2 changes: 1 addition & 1 deletion field-testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ mod tests {
use p3_baby_bear::BabyBear;
use p3_field::extension::{BinomialExtensionField, HasFrobenius};
use p3_field::{binomial_expand, eval_poly, AbstractExtensionField, AbstractField};
use rand::{thread_rng, Rng};
use rand::thread_rng;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion fri/src/fold_even_odd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn fold_even_odd<F: TwoAdicField>(poly: Vec<F>, beta: F) -> Vec<F> {

#[cfg(test)]
mod tests {
use itertools::{izip, Itertools};
use itertools::izip;
use p3_baby_bear::BabyBear;
use p3_dft::{Radix2Dit, TwoAdicSubgroupDft};
use rand::{thread_rng, Rng};
Expand Down
2 changes: 1 addition & 1 deletion mersenne-31/src/dft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod tests {
use rand::{thread_rng, Rng};

use super::*;
use crate::{Mersenne31, Mersenne31ComplexRadix2Dit};
use crate::Mersenne31ComplexRadix2Dit;

type Base = Mersenne31;
type Dft = Mersenne31ComplexRadix2Dit;
Expand Down
10 changes: 7 additions & 3 deletions mersenne-31/src/x86_64_avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::iter::{Product, Sum};
use core::mem::transmute;
use core::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};

use p3_field::{AbstractField, Field, PackedField};
use p3_field::{AbstractField, Field, PackedField, PackedValue};
use rand::distributions::{Distribution, Standard};
use rand::Rng;

Expand Down Expand Up @@ -578,8 +578,8 @@ fn interleave4(a: __m256i, b: __m256i) -> (__m256i, __m256i) {
}
}

unsafe impl PackedField for PackedMersenne31AVX2 {
type Scalar = Mersenne31;
unsafe impl PackedValue for PackedMersenne31AVX2 {
type Value = Mersenne31;

const WIDTH: usize = WIDTH;

Expand Down Expand Up @@ -619,6 +619,10 @@ unsafe impl PackedField for PackedMersenne31AVX2 {
fn as_slice_mut(&mut self) -> &mut [Mersenne31] {
&mut self.0[..]
}
}

unsafe impl PackedField for PackedMersenne31AVX2 {
type Scalar = Mersenne31;

#[inline]
fn interleave(&self, other: Self, block_len: usize) -> (Self, Self) {
Expand Down
1 change: 0 additions & 1 deletion util/src/array_serialization.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use alloc::vec::Vec;
use core::convert::TryInto;
use core::marker::PhantomData;

use serde::de::{SeqAccess, Visitor};
Expand Down
Loading