mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
wip
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use math::ring::Ring;
|
||||
use math::modulus::VecOperations;
|
||||
use math::modulus::VectorOperations;
|
||||
use math::modulus::montgomery::Montgomery;
|
||||
use math::modulus::ONCE;
|
||||
use math::CHUNK;
|
||||
|
||||
fn vec_add_unary(c: &mut Criterion) {
|
||||
fn va_add_vb_into_vb(c: &mut Criterion) {
|
||||
fn runner(r: Ring<u64>) -> Box<dyn FnMut()> {
|
||||
|
||||
let mut p0: math::poly::Poly<u64> = r.new_poly();
|
||||
@@ -15,11 +15,11 @@ fn vec_add_unary(c: &mut Criterion) {
|
||||
p1.0[i] = i as u64;
|
||||
}
|
||||
Box::new(move || {
|
||||
r.modulus.vec_add_unary_assign::<CHUNK, ONCE>(&p0.0, &mut p1.0);
|
||||
r.modulus.va_add_vb_into_vb::<CHUNK, ONCE>(&p0.0, &mut p1.0);
|
||||
})
|
||||
}
|
||||
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("add_vec_unary");
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("va_add_vb_into_vb");
|
||||
for log_n in 11..17 {
|
||||
|
||||
let n: usize = 1<<log_n as usize;
|
||||
@@ -38,7 +38,7 @@ fn vec_add_unary(c: &mut Criterion) {
|
||||
}
|
||||
}
|
||||
|
||||
fn vec_mul_montgomery_external_unary_assign(c: &mut Criterion) {
|
||||
fn va_mont_mul_vb_into_vb(c: &mut Criterion) {
|
||||
fn runner(r: Ring<u64>) -> Box<dyn FnMut()> {
|
||||
|
||||
let mut p0: math::poly::Poly<Montgomery<u64>> = r.new_poly();
|
||||
@@ -48,11 +48,11 @@ fn vec_mul_montgomery_external_unary_assign(c: &mut Criterion) {
|
||||
p1.0[i] = i as u64;
|
||||
}
|
||||
Box::new(move || {
|
||||
r.modulus.vec_mul_montgomery_external_unary_assign::<CHUNK, ONCE>(&p0.0, &mut p1.0);
|
||||
r.modulus.va_mont_mul_vb_into_vb::<CHUNK, ONCE>(&p0.0, &mut p1.0);
|
||||
})
|
||||
}
|
||||
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("mul_vec_montgomery_external_unary_assign");
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("va_mont_mul_vb_into_vb");
|
||||
for log_n in 11..17 {
|
||||
|
||||
let n: usize = 1<<log_n as usize;
|
||||
@@ -71,7 +71,7 @@ fn vec_mul_montgomery_external_unary_assign(c: &mut Criterion) {
|
||||
}
|
||||
}
|
||||
|
||||
fn vec_mul_montgomery_external_binary_assign(c: &mut Criterion) {
|
||||
fn va_mont_mul_vb_into_vc(c: &mut Criterion) {
|
||||
fn runner(r: Ring<u64>) -> Box<dyn FnMut()> {
|
||||
|
||||
let mut p0: math::poly::Poly<Montgomery<u64>> = r.new_poly();
|
||||
@@ -82,11 +82,11 @@ fn vec_mul_montgomery_external_binary_assign(c: &mut Criterion) {
|
||||
p1.0[i] = i as u64;
|
||||
}
|
||||
Box::new(move || {
|
||||
r.modulus.vec_mul_montgomery_external_binary_assign::<CHUNK,ONCE>(&p0.0, & p1.0, &mut p2.0);
|
||||
r.modulus.va_mont_mul_vb_into_vc::<CHUNK,ONCE>(&p0.0, & p1.0, &mut p2.0);
|
||||
})
|
||||
}
|
||||
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("mul_vec_montgomery_external_binary_assign");
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("va_mont_mul_vb_into_vc");
|
||||
for log_n in 11..17 {
|
||||
|
||||
let n: usize = 1<<log_n as usize;
|
||||
@@ -105,5 +105,5 @@ fn vec_mul_montgomery_external_binary_assign(c: &mut Criterion) {
|
||||
}
|
||||
}
|
||||
|
||||
criterion_group!(benches, vec_add_unary, vec_mul_montgomery_external_unary_assign, vec_mul_montgomery_external_binary_assign);
|
||||
criterion_group!(benches, va_add_vb_into_vb, va_mont_mul_vb_into_vb, va_mont_mul_vb_into_vc);
|
||||
criterion_main!(benches);
|
||||
|
||||
@@ -3,7 +3,7 @@ use math::ring::{Ring, RingRNS};
|
||||
use math::ring::impl_u64::ring_rns::new_rings;
|
||||
use math::poly::PolyRNS;
|
||||
|
||||
fn div_floor_by_last_modulus_ntt(c: &mut Criterion) {
|
||||
fn div_floor_by_last_modulus_ntt_true(c: &mut Criterion) {
|
||||
fn runner(r: RingRNS<u64>) -> Box<dyn FnMut() + '_> {
|
||||
|
||||
let a: PolyRNS<u64> = r.new_polyrns();
|
||||
@@ -11,11 +11,11 @@ fn div_floor_by_last_modulus_ntt(c: &mut Criterion) {
|
||||
let mut c: PolyRNS<u64> = r.new_polyrns();
|
||||
|
||||
Box::new(move || {
|
||||
r.div_floor_by_last_modulus_ntt(&a, &mut b, &mut c)
|
||||
r.div_floor_by_last_modulus::<true>(&a, &mut b, &mut c)
|
||||
})
|
||||
}
|
||||
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("div_floor_by_last_modulus_ntt");
|
||||
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("div_floor_by_last_modulus_ntt_true");
|
||||
for log_n in 11..18 {
|
||||
|
||||
let n = 1<<log_n;
|
||||
@@ -35,5 +35,5 @@ fn div_floor_by_last_modulus_ntt(c: &mut Criterion) {
|
||||
}
|
||||
}
|
||||
|
||||
criterion_group!(benches, div_floor_by_last_modulus_ntt);
|
||||
criterion_group!(benches, div_floor_by_last_modulus_ntt_true);
|
||||
criterion_main!(benches);
|
||||
|
||||
Reference in New Issue
Block a user