Closed rdfriese closed 2 years ago
Branch issue-2-memregion_dist_trait_private created!
@JosephCottam Is this similar to your use case?
use lamellar::array::{UnsafeArray,Distribution};
use lamellar::{LamellarWorld,Dist};
struct ArrayWrapper<T>{
array: UnsafeArray<T>
}
impl<T: Dist + Clone> ArrayWrapper<T>{
fn new(world: &LamellarWorld, len: usize) -> Self{
ArrayWrapper{
array: UnsafeArray::<T>::new(world,len,Distribution::Block)
}
}
}
fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let _num_pes = world.num_pes();
let wrapped_array_f32 = ArrayWrapper::<f32>::new(&world,10);
let wrapped_array_usize = ArrayWrapper::<f32>::new(&world,10);
}
That is basically what I wanted to do, but it won't quite work as written there.
I pushed public_memregion
branch with an example and a fix that makes it work.
Beyond what you have there, you also have to have implement serde::de::DeserializeOwned
and serde::ser::Serialize
. It would be nice if Dist somehow capture that idea (or if it was something more common like Clone or Copy instead of that pair).
@rdfriese I have confirmed that branch issue-2-memregion_dist_trait_private
solves the problem in my code. (And I think its cleaner than the public_memregion
branch solution...so use yours not mine!)
Cannot bound generic by memregion::Dist from user code