mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
refactoring
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
[package]
|
||||
name = "spqlios"
|
||||
name = "base2k"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.5"
|
||||
rand_core = "0.6.4"
|
||||
itertools = "0.14.0"
|
||||
criterion = "0.5.1"
|
||||
rand_distr = "0.4.3"
|
||||
criterion = {workspace = true}
|
||||
itertools = {workspace = true}
|
||||
rand = {workspace = true}
|
||||
rand_distr = {workspace = true}
|
||||
rand_core = {workspace = true}
|
||||
sampling = { path = "../sampling" }
|
||||
utils = { path = "../utils" }
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.71.1"
|
||||
bindgen ="0.71.1"
|
||||
|
||||
[[bench]]
|
||||
name = "fft"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use spqlios::bindings::{
|
||||
use base2k::bindings::{
|
||||
new_reim_fft_precomp, new_reim_ifft_precomp, reim_fft, reim_fft_precomp,
|
||||
reim_fft_precomp_get_buffer, reim_from_znx64_simple, reim_ifft, reim_ifft_precomp,
|
||||
reim_ifft_precomp_get_buffer,
|
||||
};
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use std::ffi::c_void;
|
||||
|
||||
fn fft(c: &mut Criterion) {
|
||||
|
||||
@@ -7,9 +7,9 @@ use std::time::SystemTime;
|
||||
|
||||
fn main() {
|
||||
// Path to the C header file
|
||||
let header_paths = [
|
||||
"lib/spqlios/coeffs/coeffs_arithmetic.h",
|
||||
"lib/spqlios/arithmetic/vec_znx_arithmetic.h",
|
||||
let header_paths: [&str; 2] = [
|
||||
"spqlios-arithmetic/spqlios/coeffs/coeffs_arithmetic.h",
|
||||
"spqlios-arithmetic/spqlios/arithmetic/vec_znx_arithmetic.h",
|
||||
];
|
||||
|
||||
let out_path: PathBuf = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
@@ -46,7 +46,10 @@ fn main() {
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
absolute("./lib/build/spqlios").unwrap().to_str().unwrap()
|
||||
absolute("./spqlios-arithmetic/build/spqlios")
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=spqlios"); //"cargo:rustc-link-lib=dylib=spqlios"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
use base2k::bindings::{
|
||||
new_reim_fft_precomp, new_reim_ifft_precomp, reim_fft, reim_fft_precomp_get_buffer,
|
||||
reim_fftvec_mul_simple, reim_from_znx64_simple, reim_ifft, reim_ifft_precomp_get_buffer,
|
||||
reim_to_znx64_simple,
|
||||
};
|
||||
use std::ffi::c_void;
|
||||
use std::time::Instant;
|
||||
|
||||
use spqlios::bindings::*;
|
||||
|
||||
fn main() {
|
||||
let log_bound: usize = 19;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use base2k::module::{Module, FFT64};
|
||||
use base2k::scalar::Scalar;
|
||||
use base2k::vector::Vector;
|
||||
use itertools::izip;
|
||||
use sampling::source::Source;
|
||||
use spqlios::module::{Module, FFT64};
|
||||
use spqlios::scalar::Scalar;
|
||||
use spqlios::vector::Vector;
|
||||
|
||||
fn main() {
|
||||
let n: usize = 16;
|
||||
@@ -23,7 +23,7 @@ fn main() {
|
||||
s.fill_ternary_prob(0.5, &mut source);
|
||||
|
||||
// Buffer to store s in the DFT domain
|
||||
let mut s_ppol: spqlios::module::SVPPOL = module.svp_new_ppol();
|
||||
let mut s_ppol: base2k::module::SVPPOL = module.svp_new_ppol();
|
||||
|
||||
// s_ppol <- DFT(s)
|
||||
module.svp_prepare(&mut s_ppol, &s);
|
||||
@@ -33,13 +33,13 @@ fn main() {
|
||||
a.fill_uniform(&mut source);
|
||||
|
||||
// Scratch space for DFT values
|
||||
let mut buf_dft: spqlios::module::VECZNXDFT = module.new_vec_znx_dft(a.limbs());
|
||||
let mut buf_dft: base2k::module::VECZNXDFT = module.new_vec_znx_dft(a.limbs());
|
||||
|
||||
// Applies buf_dft <- s * a
|
||||
module.svp_apply_dft(&mut buf_dft, &s_ppol, &a);
|
||||
|
||||
// Alias scratch space
|
||||
let mut buf_big: spqlios::module::VECZNXBIG = buf_dft.as_vec_znx_big();
|
||||
let mut buf_big: base2k::module::VECZNXBIG = buf_dft.as_vec_znx_big();
|
||||
|
||||
// buf_big <- IDFT(buf_dft) (not normalized)
|
||||
module.vec_znx_idft_tmp_a(&mut buf_big, &mut buf_dft, a.limbs());
|
||||
|
||||
@@ -14,14 +14,20 @@ pub mod bindings {
|
||||
}
|
||||
|
||||
pub mod vec_znx_arithmetic;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub use vec_znx_arithmetic::*;
|
||||
pub mod vec_znx_big_arithmetic;
|
||||
#[allow(unused_imports)]
|
||||
pub use vec_znx_big_arithmetic::*;
|
||||
pub mod vec_znx_dft;
|
||||
#[allow(unused_imports)]
|
||||
pub use vec_znx_dft::*;
|
||||
pub mod scalar_vector_product;
|
||||
#[allow(unused_imports)]
|
||||
pub use scalar_vector_product::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn cast_mut_u64_to_mut_u8_slice(data: &mut [u64]) -> &mut [u8] {
|
||||
let ptr: *mut u8 = data.as_mut_ptr() as *mut u8;
|
||||
let len: usize = data.len() * std::mem::size_of::<u64>();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rand::distributions::{Distribution, WeightedIndex};
|
||||
use rand::seq::SliceRandom;
|
||||
use rand_core::RngCore;
|
||||
use rand_distr::{Distribution, WeightedIndex};
|
||||
use sampling::source::Source;
|
||||
|
||||
pub struct Scalar(pub Vec<i64>);
|
||||
|
||||
Reference in New Issue
Block a user