mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-09 23:51:30 +01:00
add more ntt benches
This commit is contained in:
@@ -13,6 +13,15 @@ fn forward_lazy_matrix(a: &mut [Vec<u64>], nttop: &NttBackendU64) {
|
||||
.for_each(|r| nttop.forward_lazy(r.as_mut_slice()));
|
||||
}
|
||||
|
||||
fn backward_matrix(a: &mut [Vec<u64>], nttop: &NttBackendU64) {
|
||||
a.iter_mut().for_each(|r| nttop.backward(r.as_mut_slice()));
|
||||
}
|
||||
|
||||
fn backward_lazy_matrix(a: &mut [Vec<u64>], nttop: &NttBackendU64) {
|
||||
a.iter_mut()
|
||||
.for_each(|r| nttop.backward_lazy(r.as_mut_slice()));
|
||||
}
|
||||
|
||||
fn benchmark(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("ntt");
|
||||
// 55
|
||||
@@ -85,6 +94,17 @@ fn benchmark(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
{
|
||||
group.bench_function(
|
||||
BenchmarkId::new("backward", format!("q={prime}/N={ring_size}")),
|
||||
|b| {
|
||||
b.iter_batched_ref(
|
||||
|| a.clone(),
|
||||
|mut a| black_box(ntt.backward(&mut a)),
|
||||
criterion::BatchSize::PerIteration,
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
group.bench_function(
|
||||
BenchmarkId::new("backward_lazy", format!("q={prime}/N={ring_size}")),
|
||||
|b| {
|
||||
@@ -95,6 +115,31 @@ fn benchmark(c: &mut Criterion) {
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
group.bench_function(
|
||||
BenchmarkId::new("backward_matrix", format!("q={prime}/N={ring_size}")),
|
||||
|b| {
|
||||
b.iter_batched_ref(
|
||||
|| a_matrix.clone(),
|
||||
|a_matrix| black_box(backward_matrix(a_matrix, &ntt)),
|
||||
criterion::BatchSize::PerIteration,
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
group.bench_function(
|
||||
BenchmarkId::new(
|
||||
"backward_lazy_matrix",
|
||||
format!("q={prime}/N={ring_size}/d={d}"),
|
||||
),
|
||||
|b| {
|
||||
b.iter_batched_ref(
|
||||
|| a_matrix.clone(),
|
||||
|a_matrix| black_box(backward_lazy_matrix(a_matrix, &ntt)),
|
||||
criterion::BatchSize::PerIteration,
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user