mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Non-avx build (wip)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#![cfg(target_arch = "x86_64")]
|
||||
use std::hint::black_box;
|
||||
|
||||
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![cfg(target_arch = "x86_64")]
|
||||
// poulpy-backend/benches/vec_znx_add.rs
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use poulpy_cpu_avx::FFT64Avx;
|
||||
|
||||
@@ -1,11 +1,27 @@
|
||||
// poulpy-backend/benches/vec_znx_add.rs
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use poulpy_cpu_avx::FFT64Avx;
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
use poulpy_cpu_ref::FFT64Ref;
|
||||
|
||||
use poulpy_hal::bench_suite::vmp::bench_vmp_apply_dft_to_dft;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn bench_vmp_apply_dft_to_dft_cpu_avx_fft64(c: &mut Criterion) {
|
||||
bench_vmp_apply_dft_to_dft::<FFT64Avx>(c, "FFT64Avx");
|
||||
}
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
fn bench_vmp_apply_dft_to_dft_cpu_ref_fft64(c: &mut Criterion) {
|
||||
bench_vmp_apply_dft_to_dft::<FFT64Ref>(c, "FFT64Ref");
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
criterion_group!(benches_x86, bench_vmp_apply_dft_to_dft_cpu_avx_fft64,);
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
criterion_group!(benches_ref, bench_vmp_apply_dft_to_dft_cpu_ref_fft64,);
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
criterion_main!(benches_x86);
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
criterion_main!(benches_ref);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
use itertools::izip;
|
||||
use poulpy_cpu_avx::FFT64Avx;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use poulpy_cpu_avx::FFT64Avx as BackendImpl;
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
use poulpy_cpu_ref::FFT64Ref as BackendImpl;
|
||||
|
||||
use poulpy_hal::{
|
||||
api::{
|
||||
ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyDftToDftInplace, SvpPPolAlloc, SvpPrepare, VecZnxAddNormal,
|
||||
@@ -16,9 +21,9 @@ fn main() {
|
||||
let ct_size: usize = 3;
|
||||
let msg_size: usize = 2;
|
||||
let log_scale: usize = msg_size * base2k - 5;
|
||||
let module: Module<FFT64Avx> = Module::<FFT64Avx>::new(n as u64);
|
||||
let module: Module<BackendImpl> = Module::<BackendImpl>::new(n as u64);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Avx> = ScratchOwned::<FFT64Avx>::alloc(module.vec_znx_big_normalize_tmp_bytes());
|
||||
let mut scratch: ScratchOwned<BackendImpl> = ScratchOwned::<BackendImpl>::alloc(module.vec_znx_big_normalize_tmp_bytes());
|
||||
|
||||
let seed: [u8; 32] = [0; 32];
|
||||
let mut source: Source = Source::new(seed);
|
||||
@@ -28,7 +33,7 @@ fn main() {
|
||||
s.fill_ternary_prob(0, 0.5, &mut source);
|
||||
|
||||
// Buffer to store s in the DFT domain
|
||||
let mut s_dft: SvpPPol<Vec<u8>, FFT64Avx> = module.svp_ppol_alloc(s.cols());
|
||||
let mut s_dft: SvpPPol<Vec<u8>, BackendImpl> = module.svp_ppol_alloc(s.cols());
|
||||
|
||||
// s_dft <- DFT(s)
|
||||
module.svp_prepare(&mut s_dft, 0, &s, 0);
|
||||
@@ -43,7 +48,7 @@ fn main() {
|
||||
// Fill the second column with random values: ct = (0, a)
|
||||
module.vec_znx_fill_uniform(base2k, &mut ct, 1, &mut source);
|
||||
|
||||
let mut buf_dft: VecZnxDft<Vec<u8>, FFT64Avx> = module.vec_znx_dft_alloc(1, ct_size);
|
||||
let mut buf_dft: VecZnxDft<Vec<u8>, BackendImpl> = module.vec_znx_dft_alloc(1, ct_size);
|
||||
|
||||
module.vec_znx_dft_apply(1, 0, &mut buf_dft, 0, &ct, 1);
|
||||
|
||||
@@ -58,7 +63,7 @@ fn main() {
|
||||
// Alias scratch space (VecZnxDft<B> is always at least as big as VecZnxBig<B>)
|
||||
|
||||
// BIG(ct[1] * s) <- IDFT(DFT(ct[1] * s)) (not normalized)
|
||||
let mut buf_big: VecZnxBig<Vec<u8>, FFT64Avx> = module.vec_znx_big_alloc(1, ct_size);
|
||||
let mut buf_big: VecZnxBig<Vec<u8>, BackendImpl> = module.vec_znx_big_alloc(1, ct_size);
|
||||
module.vec_znx_idft_apply_tmpa(&mut buf_big, 0, &mut buf_dft, 0);
|
||||
|
||||
// Creates a plaintext: VecZnx with 1 column
|
||||
@@ -138,3 +143,4 @@ fn main() {
|
||||
println!("{}: {} {}", i, a, (*b as f64) / scale);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
|
||||
mod module;
|
||||
mod reim;
|
||||
mod reim4;
|
||||
|
||||
Reference in New Issue
Block a user