mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 21:26:41 +01:00
Crates io (#76)
* crates re-organisation * fixed typo in layout & added test for vmp_apply * updated dependencies
This commit is contained in:
committed by
GitHub
parent
dce4d82706
commit
a1de248567
7
poulpy-backend/src/cpu_spqlios/ntt120/mod.rs
Normal file
7
poulpy-backend/src/cpu_spqlios/ntt120/mod.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
mod module;
|
||||
mod svp_ppol;
|
||||
mod vec_znx_big;
|
||||
mod vec_znx_dft;
|
||||
mod vmp_pmat;
|
||||
|
||||
pub use module::NTT120;
|
||||
33
poulpy-backend/src/cpu_spqlios/ntt120/module.rs
Normal file
33
poulpy-backend/src/cpu_spqlios/ntt120/module.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use poulpy_hal::{
|
||||
layouts::{Backend, Module},
|
||||
oep::ModuleNewImpl,
|
||||
};
|
||||
|
||||
use crate::cpu_spqlios::ffi::module::{MODULE, delete_module_info, new_module_info};
|
||||
|
||||
pub struct NTT120;
|
||||
|
||||
impl Backend for NTT120 {
|
||||
type ScalarPrep = i64;
|
||||
type ScalarBig = i128;
|
||||
type Handle = MODULE;
|
||||
unsafe fn destroy(handle: NonNull<Self::Handle>) {
|
||||
unsafe { delete_module_info(handle.as_ptr()) }
|
||||
}
|
||||
|
||||
fn layout_big_word_count() -> usize {
|
||||
4
|
||||
}
|
||||
|
||||
fn layout_prep_word_count() -> usize {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl ModuleNewImpl<Self> for NTT120 {
|
||||
fn new_impl(n: u64) -> Module<Self> {
|
||||
unsafe { Module::from_raw_parts(new_module_info(n, 1), n) }
|
||||
}
|
||||
}
|
||||
24
poulpy-backend/src/cpu_spqlios/ntt120/svp_ppol.rs
Normal file
24
poulpy-backend/src/cpu_spqlios/ntt120/svp_ppol.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use poulpy_hal::{
|
||||
layouts::{Backend, SvpPPolOwned},
|
||||
oep::{SvpPPolAllocBytesImpl, SvpPPolAllocImpl, SvpPPolFromBytesImpl},
|
||||
};
|
||||
|
||||
use crate::cpu_spqlios::NTT120;
|
||||
|
||||
unsafe impl SvpPPolFromBytesImpl<Self> for NTT120 {
|
||||
fn svp_ppol_from_bytes_impl(n: usize, cols: usize, bytes: Vec<u8>) -> SvpPPolOwned<NTT120> {
|
||||
SvpPPolOwned::from_bytes(n, cols, bytes)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SvpPPolAllocImpl<Self> for NTT120 {
|
||||
fn svp_ppol_alloc_impl(n: usize, cols: usize) -> SvpPPolOwned<NTT120> {
|
||||
SvpPPolOwned::alloc(n, cols)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SvpPPolAllocBytesImpl<Self> for NTT120 {
|
||||
fn svp_ppol_alloc_bytes_impl(n: usize, cols: usize) -> usize {
|
||||
NTT120::layout_prep_word_count() * n * cols * size_of::<i64>()
|
||||
}
|
||||
}
|
||||
9
poulpy-backend/src/cpu_spqlios/ntt120/vec_znx_big.rs
Normal file
9
poulpy-backend/src/cpu_spqlios/ntt120/vec_znx_big.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use poulpy_hal::{layouts::Backend, oep::VecZnxBigAllocBytesImpl};
|
||||
|
||||
use crate::cpu_spqlios::NTT120;
|
||||
|
||||
unsafe impl VecZnxBigAllocBytesImpl<NTT120> for NTT120 {
|
||||
fn vec_znx_big_alloc_bytes_impl(n: usize, cols: usize, size: usize) -> usize {
|
||||
NTT120::layout_big_word_count() * n * cols * size * size_of::<i128>()
|
||||
}
|
||||
}
|
||||
18
poulpy-backend/src/cpu_spqlios/ntt120/vec_znx_dft.rs
Normal file
18
poulpy-backend/src/cpu_spqlios/ntt120/vec_znx_dft.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use poulpy_hal::{
|
||||
layouts::{Backend, VecZnxDftOwned},
|
||||
oep::{VecZnxDftAllocBytesImpl, VecZnxDftAllocImpl},
|
||||
};
|
||||
|
||||
use crate::cpu_spqlios::NTT120;
|
||||
|
||||
unsafe impl VecZnxDftAllocBytesImpl<NTT120> for NTT120 {
|
||||
fn vec_znx_dft_alloc_bytes_impl(n: usize, cols: usize, size: usize) -> usize {
|
||||
NTT120::layout_prep_word_count() * n * cols * size * size_of::<i64>()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl VecZnxDftAllocImpl<NTT120> for NTT120 {
|
||||
fn vec_znx_dft_alloc_impl(n: usize, cols: usize, size: usize) -> VecZnxDftOwned<NTT120> {
|
||||
VecZnxDftOwned::alloc(n, cols, size)
|
||||
}
|
||||
}
|
||||
1
poulpy-backend/src/cpu_spqlios/ntt120/vmp_pmat.rs
Normal file
1
poulpy-backend/src/cpu_spqlios/ntt120/vmp_pmat.rs
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user