Update to non-avx builds

This commit is contained in:
Pro7ech
2025-11-21 15:39:04 +01:00
parent 0fb88c9bd3
commit 3c818d292b
24 changed files with 356 additions and 128 deletions

View File

@@ -9,6 +9,9 @@ repository = "https://github.com/phantomzone-org/poulpy"
homepage = "https://github.com/phantomzone-org/poulpy"
documentation = "https://docs.rs/poulpy"
[features]
enable-avx = []
[dependencies]
poulpy-cpu-avx = {workspace = true}
poulpy-cpu-ref = {workspace = true}

View File

@@ -8,10 +8,12 @@ use poulpy_core::{
GLWESecretPreparedFactory, LWE, LWELayout, LWESecret,
},
};
#[cfg(target_arch = "x86_64")]
use poulpy_cpu_avx::FFT64Avx;
#[cfg(not(target_arch = "x86_64"))]
use poulpy_cpu_ref::FFT64Ref;
#[cfg(all(feature = "enable-avx", target_arch = "x86_64"))]
pub use poulpy_cpu_avx::FFT64Avx as BackendImpl;
#[cfg(not(all(feature = "enable-avx", target_arch = "x86_64")))]
pub use poulpy_cpu_ref::FFT64Ref as BackendImpl;
use poulpy_hal::{
api::{ModuleN, ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxRotateInplace},
@@ -130,7 +132,7 @@ where
}
}
for params in [Params {
let params: Params = Params {
name: String::from("1-bit"),
extension_factor: 1,
k_pt: 1,
@@ -174,27 +176,22 @@ where
rank: 2_u32.into(),
},
},
}] {
let id: BenchmarkId = BenchmarkId::from_parameter(params.name.clone());
let mut runner = runner::<BE, BRA>(&params);
group.bench_with_input(id, &(), |b, _| b.iter(&mut runner));
}
};
let id: BenchmarkId = BenchmarkId::from_parameter(params.name.clone());
let mut runner = runner::<BE, BRA>(&params);
group.bench_with_input(id, &(), |b, _| b.iter(&mut runner));
group.finish();
}
#[cfg(not(target_arch = "x86_64"))]
fn bench_circuit_bootstrapping_cpu_ref_fft64(c: &mut Criterion) {
benc_circuit_bootstrapping::<FFT64Ref, CGGI>(c, "fft64_ref");
fn bench_circuit_bootstrapping_fft64(c: &mut Criterion) {
#[cfg(all(feature = "enable-avx", target_arch = "x86_64"))]
let label = "fft64_avx";
#[cfg(not(all(feature = "enable-avx", target_arch = "x86_64")))]
let label = "fft64_ref";
benc_circuit_bootstrapping::<BackendImpl, CGGI>(c, label);
}
#[cfg(target_arch = "x86_64")]
fn bench_circuit_bootstrapping_cpu_avx_fft64(c: &mut Criterion) {
benc_circuit_bootstrapping::<FFT64Avx, CGGI>(c, "fft64_avx");
}
#[cfg(target_arch = "x86_64")]
criterion_group!(benches, bench_circuit_bootstrapping_cpu_ref_fft64, bench_circuit_bootstrapping_cpu_avx_fft64,);
#[cfg(not(target_arch = "x86_64"))]
criterion_group!(benches, bench_circuit_bootstrapping_cpu_ref_fft64,);
criterion_group!(benches, bench_circuit_bootstrapping_fft64);
criterion_main!(benches);

View File

@@ -8,10 +8,10 @@ use poulpy_core::{
};
use std::time::Instant;
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
#[cfg(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma"))]
use poulpy_cpu_avx::FFT64Avx as BackendImpl;
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
#[cfg(not(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma")))]
use poulpy_cpu_ref::FFT64Ref as BackendImpl;
use poulpy_hal::{

View File

@@ -5,7 +5,7 @@ use poulpy_cpu_avx::FFT64Avx;
use crate::bin_fhe::{bdd_arithmetic::tests::test_suite, blind_rotation::CGGI};
static TEST_CONTEXT_CGGI_FFT64_REF: LazyLock<test_suite::TestContext<CGGI, FFT64Avx>> =
LazyLock::new(|| test_suite::TestContext::<CGGI, FFT64Avx>::new());
LazyLock::new(test_suite::TestContext::<CGGI, FFT64Avx>::new);
#[test]
fn glwe_blind_retriever() {

View File

@@ -5,7 +5,7 @@ use poulpy_cpu_ref::FFT64Ref;
use crate::bin_fhe::{bdd_arithmetic::tests::test_suite, blind_rotation::CGGI};
static TEST_CONTEXT_CGGI_FFT64_REF: LazyLock<test_suite::TestContext<CGGI, FFT64Ref>> =
LazyLock::new(|| test_suite::TestContext::<CGGI, FFT64Ref>::new());
LazyLock::new(test_suite::TestContext::<CGGI, FFT64Ref>::new);
#[test]
fn glwe_blind_retriever() {

View File

@@ -1,9 +1,9 @@
pub mod test_suite;
#[cfg(test)]
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
#[cfg(not(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma")))]
mod fft64_ref;
#[cfg(test)]
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
#[cfg(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma"))]
mod fft64_avx;

View File

@@ -1,9 +1,9 @@
#[cfg(test)]
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
#[cfg(not(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma")))]
mod fft64_ref;
#[cfg(test)]
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
#[cfg(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma"))]
mod fft64_avx;
#[cfg(test)]

View File

@@ -1,9 +1,9 @@
pub mod circuit_bootstrapping;
#[cfg(test)]
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
#[cfg(not(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma")))]
mod fft64_ref;
#[cfg(test)]
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
#[cfg(all(feature = "enable-avx", target_arch = "x86_64", target_feature = "avx2", target_feature = "fma"))]
mod fft64_avx;