mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
added vmp_prepare_dblptr
This commit is contained in:
5
.gitmodules
vendored
5
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
|||||||
[submodule "spqlios/spqlios-arithmetic"]
|
|
||||||
path = spqlios/spqlios-arithmetic
|
|
||||||
url = https://github.com/tfhe/spqlios-arithmetic
|
|
||||||
[submodule "base2k/spqlios-arithmetic"]
|
[submodule "base2k/spqlios-arithmetic"]
|
||||||
path = base2k/spqlios-arithmetic
|
path = base2k/spqlios-arithmetic
|
||||||
url = https://github.com/tfhe/spqlios-arithmetic
|
url = https://github.com/tfhe/spqlios-arithmetic
|
||||||
11
base2k/README.md
Normal file
11
base2k/README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# DISCLAIMER: ONLY TESTED ON UBUNTU
|
||||||
|
|
||||||
|
To use this crate you need to build spqlios-arithmetic, which is provided a as a git submodule:
|
||||||
|
1) Initialize the sub-modile
|
||||||
|
2) $ cd base2k/spqlios-arithmetic
|
||||||
|
3) mdkir build
|
||||||
|
4) cd build
|
||||||
|
5) cmake ..
|
||||||
|
6) make
|
||||||
|
|
||||||
|
Steps 3 to 6 might change depending of your platform. See [spqlios-arithmetic/wiki/build](https://github.com/tfhe/spqlios-arithmetic/wiki/build) for additional information and build options.
|
||||||
1
base2k/spqlios-arithmetic
Submodule
1
base2k/spqlios-arithmetic
Submodule
Submodule base2k/spqlios-arithmetic added at 7ea875f61c
@@ -68,7 +68,7 @@ unsafe extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" {
|
unsafe extern "C" {
|
||||||
pub fn vmp_prepare_contiguous(
|
pub unsafe fn vmp_prepare_contiguous(
|
||||||
module: *const MODULE,
|
module: *const MODULE,
|
||||||
pmat: *mut VMP_PMAT,
|
pmat: *mut VMP_PMAT,
|
||||||
mat: *const i64,
|
mat: *const i64,
|
||||||
@@ -78,10 +78,10 @@ unsafe extern "C" {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
unsafe extern "C" {
|
unsafe extern "C" {
|
||||||
pub fn vmp_prepare_dblptr(
|
pub unsafe fn vmp_prepare_dblptr(
|
||||||
module: *const MODULE,
|
module: *const MODULE,
|
||||||
pmat: *mut VMP_PMAT,
|
pmat: *mut VMP_PMAT,
|
||||||
mat: *mut *const i64,
|
mat: *const *const i64,
|
||||||
nrows: u64,
|
nrows: u64,
|
||||||
ncols: u64,
|
ncols: u64,
|
||||||
tmp_space: *mut u8,
|
tmp_space: *mut u8,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl Scalar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_buffer(&mut self, n: usize, buf: &[i64]) {
|
pub fn from_buffer(&mut self, n: usize, buf: &[i64]) {
|
||||||
let size = Self::buffer_size(n);
|
let size: usize = Self::buffer_size(n);
|
||||||
assert!(
|
assert!(
|
||||||
buf.len() >= size,
|
buf.len() >= size,
|
||||||
"invalid buffer: buf.len()={} < self.buffer_size(n={})={}",
|
"invalid buffer: buf.len()={} < self.buffer_size(n={})={}",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::ffi::vmp::{
|
use crate::ffi::vmp::{
|
||||||
delete_vmp_pmat, new_vmp_pmat, vmp_apply_dft, vmp_apply_dft_tmp_bytes, vmp_apply_dft_to_dft,
|
delete_vmp_pmat, new_vmp_pmat, vmp_apply_dft, vmp_apply_dft_tmp_bytes, vmp_apply_dft_to_dft,
|
||||||
vmp_apply_dft_to_dft_tmp_bytes, vmp_pmat_t, vmp_prepare_contiguous,
|
vmp_apply_dft_to_dft_tmp_bytes, vmp_pmat_t, vmp_prepare_contiguous,
|
||||||
vmp_prepare_contiguous_tmp_bytes,
|
vmp_prepare_contiguous_tmp_bytes, vmp_prepare_dblptr,
|
||||||
};
|
};
|
||||||
use crate::{Module, VecZnx, VecZnxDft};
|
use crate::{Module, VecZnx, VecZnxDft};
|
||||||
|
|
||||||
@@ -110,6 +110,21 @@ impl Module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn vmp_prepare_dblptr(&self, b: &mut VmpPMat, a: &Vec<&Vec<i64>>, buf: &mut [u8]) {
|
||||||
|
let ptrs: Vec<*const i64> = a.iter().map(|v| v.as_ptr()).collect();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
vmp_prepare_dblptr(
|
||||||
|
self.0,
|
||||||
|
b.data(),
|
||||||
|
ptrs.as_ptr(),
|
||||||
|
b.rows() as u64,
|
||||||
|
b.cols() as u64,
|
||||||
|
buf.as_mut_ptr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn vmp_apply_dft_tmp_bytes(
|
pub fn vmp_apply_dft_tmp_bytes(
|
||||||
&self,
|
&self,
|
||||||
c_limbs: usize,
|
c_limbs: usize,
|
||||||
@@ -209,7 +224,7 @@ pub struct Matrix3D<T> {
|
|||||||
pub n: usize,
|
pub n: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Default + Clone> Matrix3D<T> {
|
impl<T: Default + Clone + std::marker::Copy> Matrix3D<T> {
|
||||||
pub fn new(rows: usize, cols: usize, n: usize) -> Self {
|
pub fn new(rows: usize, cols: usize, n: usize) -> Self {
|
||||||
let size = rows * cols * n;
|
let size = rows * cols * n;
|
||||||
Self {
|
Self {
|
||||||
@@ -231,4 +246,9 @@ impl<T: Default + Clone> Matrix3D<T> {
|
|||||||
let idx: usize = col * (self.n * self.rows) + row * self.n;
|
let idx: usize = col * (self.n * self.rows) + row * self.n;
|
||||||
&mut self.data[idx..idx + self.n]
|
&mut self.data[idx..idx + self.n]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_col(&mut self, col: usize, a: &[T]) {
|
||||||
|
let idx: usize = col * (self.n * self.rows);
|
||||||
|
self.data[idx..idx + self.rows * self.n].copy_from_slice(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user