mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Add prepare multi thread
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
api::{ModuleN, SvpPPolBytesOf, VecZnxBigBytesOf, VecZnxDftBytesOf, VmpPMatBytesOf},
|
||||
layouts::{Backend, MatZnx, ScalarZnx, Scratch, SvpPPol, VecZnx, VecZnxBig, VecZnxDft, VmpPMat},
|
||||
layouts::{Backend, MatZnx, ScalarZnx, Scratch, SvpPPol, VecZnx, VecZnxBig, VecZnxDft, VmpPMat, Zn},
|
||||
};
|
||||
|
||||
/// Allocates a new [crate::layouts::ScratchOwned] of `size` aligned bytes.
|
||||
@@ -28,7 +28,17 @@ pub trait TakeSlice {
|
||||
fn take_slice<T>(&mut self, len: usize) -> (&mut [T], &mut Self);
|
||||
}
|
||||
|
||||
impl<B: Backend> ScratchTakeBasic for Scratch<B> where Self: TakeSlice {}
|
||||
impl<BE: Backend> Scratch<BE>
|
||||
where
|
||||
Self: TakeSlice + ScratchFromBytes<BE>,
|
||||
{
|
||||
pub fn split_at_mut(&mut self, len: usize) -> (&mut Scratch<BE>, &mut Self) {
|
||||
let (take_slice, rem_slice) = self.take_slice(len);
|
||||
(Self::from_bytes(take_slice), rem_slice)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: Backend> ScratchTakeBasic for Scratch<B> where Self: TakeSlice + ScratchFromBytes<B> {}
|
||||
|
||||
pub trait ScratchTakeBasic
|
||||
where
|
||||
@@ -47,6 +57,11 @@ where
|
||||
(SvpPPol::from_data(take_slice, module.n(), cols), rem_slice)
|
||||
}
|
||||
|
||||
fn take_zn(&mut self, n: usize, cols: usize, size: usize) -> (Zn<&mut [u8]>, &mut Self) {
|
||||
let (take_slice, rem_slice) = self.take_slice(Zn::bytes_of(n, cols, size));
|
||||
(Zn::from_data(take_slice, n, cols, size), rem_slice)
|
||||
}
|
||||
|
||||
fn take_vec_znx(&mut self, n: usize, cols: usize, size: usize) -> (VecZnx<&mut [u8]>, &mut Self) {
|
||||
let (take_slice, rem_slice) = self.take_slice(VecZnx::bytes_of(n, cols, size));
|
||||
(VecZnx::from_data(take_slice, n, cols, size), rem_slice)
|
||||
|
||||
@@ -28,8 +28,8 @@ pub use zn::*;
|
||||
pub use znx_base::*;
|
||||
|
||||
pub trait Data = PartialEq + Eq + Sized + Default;
|
||||
pub trait DataRef = Data + AsRef<[u8]>;
|
||||
pub trait DataMut = DataRef + AsMut<[u8]>;
|
||||
pub trait DataRef = Data + AsRef<[u8]> + Sync;
|
||||
pub trait DataMut = DataRef + AsMut<[u8]> + Send;
|
||||
|
||||
pub trait ToOwnedDeep {
|
||||
type Owned;
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[allow(clippy::missing_safety_doc)]
|
||||
pub trait Backend: Sized {
|
||||
pub trait Backend: Sized + Sync + Send {
|
||||
type ScalarBig: Copy + Zero + Display + Debug + Pod;
|
||||
type ScalarPrep: Copy + Zero + Display + Debug + Pod;
|
||||
type Handle: 'static;
|
||||
|
||||
Reference in New Issue
Block a user