mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06: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 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 {
|
||||
(ptr as usize) % align == 0
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::ffi::svp::{self, svp_ppol_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 rand::seq::SliceRandom;
|
||||
@@ -119,6 +119,7 @@ impl Scalar {
|
||||
n: self.n,
|
||||
size: 1, // TODO REVIEW IF NEED TO ADD size TO SCALAR
|
||||
cols: 1,
|
||||
layout: LAYOUT::COL,
|
||||
data: Vec::new(),
|
||||
ptr: self.ptr,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::cast_mut;
|
||||
use crate::ffi::vec_znx;
|
||||
use crate::ffi::znx;
|
||||
use crate::LAYOUT;
|
||||
use crate::{Infos, Module};
|
||||
use crate::{alloc_aligned, assert_alignement};
|
||||
use itertools::izip;
|
||||
@@ -24,6 +25,9 @@ pub struct VecZnx {
|
||||
/// Stack size
|
||||
pub size: usize,
|
||||
|
||||
/// Stacking layout
|
||||
pub layout: LAYOUT,
|
||||
|
||||
/// Number of columns.
|
||||
pub cols: usize,
|
||||
|
||||
@@ -59,6 +63,7 @@ impl VecZnx {
|
||||
n: n,
|
||||
size: size,
|
||||
cols: cols,
|
||||
layout: LAYOUT::COL,
|
||||
data: Vec::from_raw_parts(ptr, bytes.len(), bytes.len()),
|
||||
ptr: ptr,
|
||||
}
|
||||
@@ -76,6 +81,7 @@ impl VecZnx {
|
||||
n: n,
|
||||
size: size,
|
||||
cols: cols,
|
||||
layout: LAYOUT::COL,
|
||||
data: Vec::new(),
|
||||
ptr: bytes.as_mut_ptr() as *mut i64,
|
||||
}
|
||||
@@ -254,6 +260,7 @@ impl VecZnx {
|
||||
Self {
|
||||
n: n,
|
||||
size: size,
|
||||
layout: LAYOUT::COL,
|
||||
cols: cols,
|
||||
data: data,
|
||||
ptr: ptr,
|
||||
|
||||
Reference in New Issue
Block a user