mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Backend refactor (#120)
* remove spqlios, split cpu_ref and cpu_avx into different crates * remove spqlios submodule * update crate naming & add avx tests
This commit is contained in:
committed by
GitHub
parent
84598e42fe
commit
9e007c988f
@@ -6,7 +6,7 @@ use std::hint::black_box;
|
||||
|
||||
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
|
||||
use poulpy_backend::cpu_spqlios::FFT64Spqlios;
|
||||
use poulpy_cpu_ref::FFT64Ref;
|
||||
use poulpy_hal::{
|
||||
api::{ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow},
|
||||
layouts::{Module, ScalarZnx, ScratchOwned},
|
||||
@@ -26,7 +26,7 @@ fn bench_external_product_glwe_fft64(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
fn runner(p: Params) -> impl FnMut() {
|
||||
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
|
||||
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(1 << p.log_n);
|
||||
|
||||
let n: Degree = Degree(module.n() as u32);
|
||||
let base2k: Base2K = p.base2k;
|
||||
@@ -66,7 +66,7 @@ fn bench_external_product_glwe_fft64(c: &mut Criterion) {
|
||||
let mut ct_glwe_out: GLWE<Vec<u8>> = GLWE::alloc_from_infos(&glwe_out_layout);
|
||||
let pt_rgsw: ScalarZnx<Vec<u8>> = ScalarZnx::alloc(n.into(), 1);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
let mut scratch: ScratchOwned<FFT64Ref> = ScratchOwned::alloc(
|
||||
GGSW::encrypt_sk_tmp_bytes(&module, &ggsw_layout)
|
||||
| GLWE::encrypt_sk_tmp_bytes(&module, &glwe_in_layout)
|
||||
| GLWE::external_product_tmp_bytes(&module, &glwe_out_layout, &glwe_in_layout, &ggsw_layout),
|
||||
@@ -79,7 +79,7 @@ fn bench_external_product_glwe_fft64(c: &mut Criterion) {
|
||||
let mut sk: GLWESecret<Vec<u8>> = GLWESecret::alloc_from_infos(&glwe_in_layout);
|
||||
sk.fill_ternary_prob(0.5, &mut source_xs);
|
||||
|
||||
let mut sk_dft: GLWESecretPrepared<Vec<u8>, FFT64Spqlios> = GLWESecretPrepared::alloc(&module, rank);
|
||||
let mut sk_dft: GLWESecretPrepared<Vec<u8>, FFT64Ref> = GLWESecretPrepared::alloc(&module, rank);
|
||||
sk_dft.prepare(&module, &sk);
|
||||
|
||||
ct_ggsw.encrypt_sk(
|
||||
@@ -99,7 +99,7 @@ fn bench_external_product_glwe_fft64(c: &mut Criterion) {
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut ggsw_prepared: GGSWPrepared<Vec<u8>, FFT64Spqlios> = GGSWPrepared::alloc_from_infos(&module, &ct_ggsw);
|
||||
let mut ggsw_prepared: GGSWPrepared<Vec<u8>, FFT64Ref> = GGSWPrepared::alloc_from_infos(&module, &ct_ggsw);
|
||||
ggsw_prepared.prepare(&module, &ct_ggsw, scratch.borrow());
|
||||
|
||||
move || {
|
||||
@@ -138,7 +138,7 @@ fn bench_external_product_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
fn runner(p: Params) -> impl FnMut() {
|
||||
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
|
||||
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(1 << p.log_n);
|
||||
|
||||
let n: Degree = Degree(module.n() as u32);
|
||||
let base2k: Base2K = p.base2k;
|
||||
@@ -169,7 +169,7 @@ fn bench_external_product_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
let mut ct_glwe: GLWE<Vec<u8>> = GLWE::alloc_from_infos(&glwe_layout);
|
||||
let pt_rgsw: ScalarZnx<Vec<u8>> = ScalarZnx::alloc(n.into(), 1);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
let mut scratch: ScratchOwned<FFT64Ref> = ScratchOwned::alloc(
|
||||
GGSW::encrypt_sk_tmp_bytes(&module, &ggsw_layout)
|
||||
| GLWE::encrypt_sk_tmp_bytes(&module, &glwe_layout)
|
||||
| GLWE::external_product_tmp_bytes(&module, &glwe_layout, &glwe_layout, &ggsw_layout),
|
||||
@@ -182,7 +182,7 @@ fn bench_external_product_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
let mut sk: GLWESecret<Vec<u8>> = GLWESecret::alloc_from_infos(&glwe_layout);
|
||||
sk.fill_ternary_prob(0.5, &mut source_xs);
|
||||
|
||||
let mut sk_dft: GLWESecretPrepared<Vec<u8>, FFT64Spqlios> = GLWESecretPrepared::alloc(&module, rank);
|
||||
let mut sk_dft: GLWESecretPrepared<Vec<u8>, FFT64Ref> = GLWESecretPrepared::alloc(&module, rank);
|
||||
sk_dft.prepare(&module, &sk);
|
||||
|
||||
ct_ggsw.encrypt_sk(
|
||||
@@ -202,7 +202,7 @@ fn bench_external_product_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut ggsw_prepared: GGSWPrepared<Vec<u8>, FFT64Spqlios> = GGSWPrepared::alloc_from_infos(&module, &ct_ggsw);
|
||||
let mut ggsw_prepared: GGSWPrepared<Vec<u8>, FFT64Ref> = GGSWPrepared::alloc_from_infos(&module, &ct_ggsw);
|
||||
ggsw_prepared.prepare(&module, &ct_ggsw, scratch.borrow());
|
||||
move || {
|
||||
let scratch_borrow = scratch.borrow();
|
||||
|
||||
@@ -6,7 +6,7 @@ use poulpy_core::layouts::{
|
||||
use std::{hint::black_box, time::Duration};
|
||||
|
||||
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
use poulpy_backend::cpu_spqlios::FFT64Spqlios;
|
||||
use poulpy_cpu_ref::FFT64Ref;
|
||||
use poulpy_hal::{
|
||||
api::{ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow},
|
||||
layouts::{Module, ScratchOwned},
|
||||
@@ -27,7 +27,7 @@ fn bench_keyswitch_glwe_fft64(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
fn runner(p: Params) -> impl FnMut() {
|
||||
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
|
||||
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(1 << p.log_n);
|
||||
|
||||
let n: Degree = Degree(module.n() as u32);
|
||||
let base2k: Base2K = p.base2k;
|
||||
@@ -66,7 +66,7 @@ fn bench_keyswitch_glwe_fft64(c: &mut Criterion) {
|
||||
let mut ct_in: GLWE<Vec<u8>> = GLWE::alloc_from_infos(&glwe_in_layout);
|
||||
let mut ct_out: GLWE<Vec<u8>> = GLWE::alloc_from_infos(&glwe_out_layout);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
let mut scratch: ScratchOwned<FFT64Ref> = ScratchOwned::alloc(
|
||||
GLWESwitchingKey::encrypt_sk_tmp_bytes(&module, &gglwe_atk_layout)
|
||||
| GLWE::encrypt_sk_tmp_bytes(&module, &glwe_in_layout)
|
||||
| GLWE::keyswitch_tmp_bytes(
|
||||
@@ -84,7 +84,7 @@ fn bench_keyswitch_glwe_fft64(c: &mut Criterion) {
|
||||
let mut sk_in: GLWESecret<Vec<u8>> = GLWESecret::alloc_from_infos(&glwe_in_layout);
|
||||
sk_in.fill_ternary_prob(0.5, &mut source_xs);
|
||||
|
||||
let mut sk_in_dft: GLWESecretPrepared<Vec<u8>, FFT64Spqlios> = GLWESecretPrepared::alloc(&module, rank);
|
||||
let mut sk_in_dft: GLWESecretPrepared<Vec<u8>, FFT64Ref> = GLWESecretPrepared::alloc(&module, rank);
|
||||
sk_in_dft.prepare(&module, &sk_in);
|
||||
|
||||
ksk.encrypt_sk(
|
||||
@@ -150,7 +150,7 @@ fn bench_keyswitch_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
fn runner(p: Params) -> impl FnMut() {
|
||||
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
|
||||
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(1 << p.log_n);
|
||||
|
||||
let n: Degree = Degree(module.n() as u32);
|
||||
let base2k: Base2K = p.base2k;
|
||||
@@ -181,7 +181,7 @@ fn bench_keyswitch_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
let mut ksk: GLWESwitchingKey<Vec<u8>> = GLWESwitchingKey::alloc_from_infos(&gglwe_layout);
|
||||
let mut ct: GLWE<Vec<u8>> = GLWE::alloc_from_infos(&glwe_layout);
|
||||
|
||||
let mut scratch: ScratchOwned<FFT64Spqlios> = ScratchOwned::alloc(
|
||||
let mut scratch: ScratchOwned<FFT64Ref> = ScratchOwned::alloc(
|
||||
GLWESwitchingKey::encrypt_sk_tmp_bytes(&module, &gglwe_layout)
|
||||
| GLWE::encrypt_sk_tmp_bytes(&module, &glwe_layout)
|
||||
| GLWE::keyswitch_tmp_bytes(&module, &glwe_layout, &glwe_layout, &gglwe_layout),
|
||||
@@ -194,7 +194,7 @@ fn bench_keyswitch_glwe_inplace_fft64(c: &mut Criterion) {
|
||||
let mut sk_in: GLWESecret<Vec<u8>> = GLWESecret::alloc_from_infos(&glwe_layout);
|
||||
sk_in.fill_ternary_prob(0.5, &mut source_xs);
|
||||
|
||||
let mut sk_in_dft: GLWESecretPrepared<Vec<u8>, FFT64Spqlios> = GLWESecretPrepared::alloc(&module, rank);
|
||||
let mut sk_in_dft: GLWESecretPrepared<Vec<u8>, FFT64Ref> = GLWESecretPrepared::alloc(&module, rank);
|
||||
sk_in_dft.prepare(&module, &sk_in);
|
||||
|
||||
let mut sk_out: GLWESecret<Vec<u8>> = GLWESecret::alloc_from_infos(&glwe_layout);
|
||||
|
||||
Reference in New Issue
Block a user