mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
Added memory layout field
This commit is contained in:
@@ -27,6 +27,14 @@ pub use vmp::*;
|
|||||||
pub const GALOISGENERATOR: u64 = 5;
|
pub const GALOISGENERATOR: u64 = 5;
|
||||||
pub const DEFAULTALIGN: usize = 64;
|
pub const DEFAULTALIGN: usize = 64;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum LAYOUT {
|
||||||
|
ROW,
|
||||||
|
COL,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn is_aligned_custom<T>(ptr: *const T, align: usize) -> bool {
|
pub fn is_aligned_custom<T>(ptr: *const T, align: usize) -> bool {
|
||||||
(ptr as usize) % align == 0
|
(ptr as usize) % align == 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::ffi::svp::{self, svp_ppol_t};
|
use crate::ffi::svp::{self, svp_ppol_t};
|
||||||
use crate::ffi::vec_znx_dft::vec_znx_dft_t;
|
use crate::ffi::vec_znx_dft::vec_znx_dft_t;
|
||||||
use crate::{BACKEND, Module, VecZnx, VecZnxDft, assert_alignement};
|
use crate::{assert_alignement, Module, VecZnx, VecZnxDft, BACKEND, LAYOUT};
|
||||||
|
|
||||||
use crate::{Infos, alloc_aligned, cast_mut};
|
use crate::{Infos, alloc_aligned, cast_mut};
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
@@ -119,6 +119,7 @@ impl Scalar {
|
|||||||
n: self.n,
|
n: self.n,
|
||||||
size: 1, // TODO REVIEW IF NEED TO ADD size TO SCALAR
|
size: 1, // TODO REVIEW IF NEED TO ADD size TO SCALAR
|
||||||
cols: 1,
|
cols: 1,
|
||||||
|
layout: LAYOUT::COL,
|
||||||
data: Vec::new(),
|
data: Vec::new(),
|
||||||
ptr: self.ptr,
|
ptr: self.ptr,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::cast_mut;
|
use crate::cast_mut;
|
||||||
use crate::ffi::vec_znx;
|
use crate::ffi::vec_znx;
|
||||||
use crate::ffi::znx;
|
use crate::ffi::znx;
|
||||||
|
use crate::LAYOUT;
|
||||||
use crate::{Infos, Module};
|
use crate::{Infos, Module};
|
||||||
use crate::{alloc_aligned, assert_alignement};
|
use crate::{alloc_aligned, assert_alignement};
|
||||||
use itertools::izip;
|
use itertools::izip;
|
||||||
@@ -24,6 +25,9 @@ pub struct VecZnx {
|
|||||||
/// Stack size
|
/// Stack size
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
|
|
||||||
|
/// Stacking layout
|
||||||
|
pub layout: LAYOUT,
|
||||||
|
|
||||||
/// Number of columns.
|
/// Number of columns.
|
||||||
pub cols: usize,
|
pub cols: usize,
|
||||||
|
|
||||||
@@ -59,6 +63,7 @@ impl VecZnx {
|
|||||||
n: n,
|
n: n,
|
||||||
size: size,
|
size: size,
|
||||||
cols: cols,
|
cols: cols,
|
||||||
|
layout: LAYOUT::COL,
|
||||||
data: Vec::from_raw_parts(ptr, bytes.len(), bytes.len()),
|
data: Vec::from_raw_parts(ptr, bytes.len(), bytes.len()),
|
||||||
ptr: ptr,
|
ptr: ptr,
|
||||||
}
|
}
|
||||||
@@ -76,6 +81,7 @@ impl VecZnx {
|
|||||||
n: n,
|
n: n,
|
||||||
size: size,
|
size: size,
|
||||||
cols: cols,
|
cols: cols,
|
||||||
|
layout: LAYOUT::COL,
|
||||||
data: Vec::new(),
|
data: Vec::new(),
|
||||||
ptr: bytes.as_mut_ptr() as *mut i64,
|
ptr: bytes.as_mut_ptr() as *mut i64,
|
||||||
}
|
}
|
||||||
@@ -254,6 +260,7 @@ impl VecZnx {
|
|||||||
Self {
|
Self {
|
||||||
n: n,
|
n: n,
|
||||||
size: size,
|
size: size,
|
||||||
|
layout: LAYOUT::COL,
|
||||||
cols: cols,
|
cols: cols,
|
||||||
data: data,
|
data: data,
|
||||||
ptr: ptr,
|
ptr: ptr,
|
||||||
|
|||||||
Reference in New Issue
Block a user