lamellar/array/atomic/
rdma.rs

1use crate::array::atomic::*;
2// use crate::array::private::ArrayExecAm;
3use crate::array::LamellarWrite;
4use crate::array::*;
5use crate::memregion::Dist;
6
7// type GetFn = fn(AtomicByteArray, usize, usize) -> LamellarArcAm;
8// //#[doc(hidden)]
9// pub(crate) struct AtomicArrayGet {
10//     pub id: TypeId,
11//     pub op: GetFn,
12// }
13// crate::inventory::collect!(AtomicArrayGet);
14// lazy_static! {
15//     pub(crate) static ref GET_OPS: HashMap<TypeId, GetFn> = {
16//         let mut map = HashMap::new();
17//         for get in crate::inventory::iter::<AtomicArrayGet> {
18//             map.insert(get.id.clone(),get.op);
19//         }
20//         map
21//         // map.insert(TypeId::of::<f64>(), f64_add::add as AddFn );
22//     };
23// }
24
25// type PutFn = fn(AtomicByteArray, usize, usize, Vec<u8>) -> LamellarArcAm;
26// //#[doc(hidden)]
27// pub(crate) struct AtomicArrayPut {
28//     pub id: TypeId,
29//     pub op: PutFn,
30// }
31// crate::inventory::collect!(AtomicArrayPut);
32// lazy_static! {
33//     pub(crate) static ref PUT_OPS: HashMap<TypeId, PutFn> = {
34//         let mut map = HashMap::new();
35//         for put in crate::inventory::iter::<AtomicArrayPut> {
36//             map.insert(put.id.clone(),put.op);
37//         }
38//         map
39//         // map.insert(TypeId::of::<f64>(), f64_add::add as AddFn );
40//     };
41// }
42
43impl<T: Dist> LamellarArrayGet<T> for AtomicArray<T> {
44    unsafe fn get<U: TeamTryInto<LamellarArrayRdmaOutput<T>> + LamellarWrite>(
45        &self,
46        index: usize,
47        buf: U,
48    ) -> ArrayRdmaHandle {
49        match self {
50            AtomicArray::NativeAtomicArray(array) => array.get(index, buf),
51            AtomicArray::GenericAtomicArray(array) => array.get(index, buf),
52        }
53    }
54    fn at(&self, index: usize) -> ArrayRdmaAtHandle<T> {
55        match self {
56            AtomicArray::NativeAtomicArray(array) => array.at(index),
57            AtomicArray::GenericAtomicArray(array) => array.at(index),
58        }
59    }
60}
61
62impl<T: Dist> LamellarArrayPut<T> for AtomicArray<T> {
63    unsafe fn put<U: TeamTryInto<LamellarArrayRdmaInput<T>> + LamellarRead>(
64        &self,
65        index: usize,
66        buf: U,
67    ) -> ArrayRdmaHandle {
68        match self {
69            AtomicArray::NativeAtomicArray(array) => array.put(index, buf),
70            AtomicArray::GenericAtomicArray(array) => array.put(index, buf),
71        }
72    }
73}