1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
use core::panic;
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use futures_util::{
stream::{Collect, FuturesOrdered},
StreamExt,
};
use pin_project::pin_project;
use crate::{
active_messaging::LocalAmHandle,
array::LamellarByteArray,
lamellae::{RdmaGetBufferHandle, RdmaGetHandle, RdmaGetIntoBufferHandle},
memregion::{AsLamellarBuffer, LamellarBuffer},
warnings::RuntimeWarning,
AmHandle, AtomicFetchOpHandle, Dist, LamellarTask, OneSidedMemoryRegion,
};
/// Handle returned by single-element array RDMA get operations.
///
/// Resolves to `T` when driven to completion via `spawn()`, `block()`, or `.await`.
/// Dropping this handle without doing so will only ensure completion if
/// [`wait_all`][crate::LamellarArray::wait_all] or a barrier is subsequently called.
pub struct ArrayRdmaGetHandle<T: Dist> {
pub(crate) array: LamellarByteArray, //prevents prematurely performing a local drop
pub(crate) state: ArrayRdmaGetState<T>,
pub(crate) spawned: bool,
}
pub(crate) enum ArrayRdmaGetState<T: Dist> {
LocalAmGet(LocalAmHandle<T>), //Am is initiated as a local am
RemoteAmGet(AmHandle<Vec<u8>>), //Am is initiated as a remote am
// LoadOp(ArrayFetchOpHandle<T>),
RdmaGet(RdmaGetHandle<T>),
AtomicGet(AtomicFetchOpHandle<T>),
}
impl<T: Dist> ArrayRdmaGetHandle<T> {
/// Enqueues the get operation on the runtime work queue and returns a [`LamellarTask<T>`]
/// that resolves to the retrieved element when the transfer is complete.
///
/// Prefer `spawn()` or `.await` over `block()` inside async contexts to avoid stalling
/// the executor.
///
/// # Examples
///```
/// use lamellar::array::prelude::*;
///
/// let world = LamellarWorldBuilder::new().build();
/// let my_pe = world.my_pe();
/// let num_pes = world.num_pes();
///
/// let array: ReadOnlyArray<usize> = ReadOnlyArray::new(&world, num_pes, Distribution::Block).block();
///
/// let handle = array.get(0);
/// let task = handle.spawn();
/// // do other work …
/// let val = task.block();
/// println!("PE{my_pe} got array[0] = {val}");
///```
#[must_use = "this function returns a future used to poll for completion. Call '.await' on the future otherwise, if it is ignored (via ' let _ = *.spawn()') or dropped the only way to ensure completion is calling 'wait_all()' on the world or array. Alternatively it may be acceptable to call '.block()' instead of 'spawn()'"]
pub fn spawn(mut self) -> LamellarTask<T> {
let task = match self.state {
ArrayRdmaGetState::LocalAmGet(req) => req.spawn(),
ArrayRdmaGetState::RemoteAmGet(req) => {
let task = req.spawn();
self.array.spawn(async move {
let data = task.await;
// println!("data: {:?}", data);
if data.len() != std::mem::size_of::<T>() {
panic!(
"Remote AM get returned incorrect number of bytes {:?} {:?}",
data.len(),
std::mem::size_of::<T>()
);
}
unsafe { std::ptr::read_unaligned(data.as_ptr() as *const T) }
})
}
// ArrayRdmaGetState::LoadOp(req) => req.spawn(),
ArrayRdmaGetState::RdmaGet(req) => req.spawn(),
ArrayRdmaGetState::AtomicGet(req) => req.spawn(),
};
self.spawned = true;
task
}
/// Blocks the current thread until the get transfer is complete and returns the retrieved
/// element.
///
/// Emits a [`RuntimeWarning`][crate::warnings::RuntimeWarning] when called inside an async
/// context; use `spawn()` or `.await` there instead.
///
/// # Examples
///```
/// use lamellar::array::prelude::*;
///
/// let world = LamellarWorldBuilder::new().build();
/// let my_pe = world.my_pe();
/// let num_pes = world.num_pes();
///
/// let array: ReadOnlyArray<usize> = ReadOnlyArray::new(&world, num_pes, Distribution::Block).block();
///
/// let val = array.get(0).block();
/// println!("PE{my_pe} got array[0] = {val}");
///```
pub fn block(mut self) -> T {
RuntimeWarning::BlockingCall(
"ArrayRdmaHandle::block",
"<handle>.spawn() or <handle>.await",
)
.print();
self.spawned = true;
match self.state {
ArrayRdmaGetState::LocalAmGet(req) => req.block(),
ArrayRdmaGetState::RemoteAmGet(req) => {
let data = req.block();
if data.len() != std::mem::size_of::<T>() {
panic!("Remote AM get returned incorrect number of bytes");
}
unsafe { std::ptr::read_unaligned(data.as_ptr() as *const T) }
}
// ArrayRdmaGetState::LoadOp(req) => req.block(),
ArrayRdmaGetState::RdmaGet(req) => req.block(),
ArrayRdmaGetState::AtomicGet(req) => req.block(),
}
}
}
impl<T: Dist> Future for ArrayRdmaGetHandle<T> {
type Output = T;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();
let res = match &mut this.state {
ArrayRdmaGetState::LocalAmGet(req) => Pin::new(req).poll(cx),
ArrayRdmaGetState::RemoteAmGet(req) => match Pin::new(req).poll(cx) {
Poll::Ready(data) => {
if data.len() != std::mem::size_of::<T>() {
panic!("Remote AM get returned incorrect number of bytes");
}
let value = unsafe { std::ptr::read_unaligned(data.as_ptr() as *const T) };
Poll::Ready(value)
}
Poll::Pending => Poll::Pending,
},
// ArrayRdmaGetState::LoadOp(req) => Pin::new(req).poll(cx),
ArrayRdmaGetState::RdmaGet(req) => Pin::new(req).poll(cx),
ArrayRdmaGetState::AtomicGet(req) => Pin::new(req).poll(cx),
};
this.spawned = true;
res
}
}
/// Handle returned by multi-element array RDMA get operations that allocate their own output buffer.
///
/// Resolves to `Vec<T>` when driven to completion via `spawn()`, `block()`, or `.await`.
/// Dropping this handle without doing so will only ensure completion if
/// [`wait_all`][crate::LamellarArray::wait_all] or a barrier is subsequently called.
#[pin_project]
pub struct ArrayRdmaGetBufferHandle<T: Dist> {
pub(crate) array: LamellarByteArray, //prevents prematurely performing a local drop
#[pin]
pub(crate) state: ArrayRdmaGetBufferState<T>,
pub(crate) spawned: bool,
}
#[pin_project(project = ArrayRdmaGetBufferStateProj)]
pub(crate) enum ArrayRdmaGetBufferState<T: Dist> {
LocalAmGet(#[pin] LocalAmHandle<Vec<T>>), //Am is initiated as a local am
RemoteAmGet(#[pin] AmHandle<()>, OneSidedMemoryRegion<T>), //Am is initiated as a remote am
RdmaGet(#[pin] RdmaGetBufferHandle<T>),
MultiRdmaBlockGet(#[pin] Collect<FuturesOrdered<RdmaGetBufferHandle<T>>, Vec<Vec<T>>>),
MultiRdmaCyclicGet(#[pin] Collect<FuturesOrdered<RdmaGetBufferHandle<T>>, Vec<Vec<T>>>),
}
impl<T: Dist> ArrayRdmaGetBufferHandle<T> {
/// Enqueues the get operation on the runtime work queue and returns a
/// [`LamellarTask<Vec<T>>`] that resolves to the retrieved elements when the transfer is
/// complete.
///
/// Prefer `spawn()` or `.await` over `block()` inside async contexts to avoid stalling
/// the executor.
///
/// # Examples
///```
/// use lamellar::array::prelude::*;
///
/// let world = LamellarWorldBuilder::new().build();
/// let my_pe = world.my_pe();
/// let num_pes = world.num_pes();
///
/// let array: ReadOnlyArray<usize> = ReadOnlyArray::new(&world, num_pes * 10, Distribution::Block).block();
///
/// let handle = array.get_buffer(0, 5);
/// let task = handle.spawn();
/// // do other work …
/// let data = task.block();
/// println!("PE{my_pe} elements[0..5]: {:?}", data);
///```
#[must_use = "this function returns a future used to poll for completion. Call '.await' on the future otherwise, if it is ignored (via ' let _ = *.spawn()') or dropped the only way to ensure completion is calling 'wait_all()' on the world or array. Alternatively it may be acceptable to call '.block()' instead of 'spawn()'"]
pub fn spawn(mut self) -> LamellarTask<Vec<T>> {
let task = match self.state {
ArrayRdmaGetBufferState::LocalAmGet(req) => req.spawn(),
ArrayRdmaGetBufferState::RemoteAmGet(req, mr) => {
let task = req.spawn();
self.array.spawn(async move {
let _ = task.await;
unsafe { mr.as_slice().to_vec() }
})
}
ArrayRdmaGetBufferState::RdmaGet(req) => req.spawn(),
ArrayRdmaGetBufferState::MultiRdmaBlockGet(ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
self.array.spawn(async move {
let data = tasks.await;
data.into_iter().flatten().collect()
})
}
ArrayRdmaGetBufferState::MultiRdmaCyclicGet(ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
self.array.spawn(async move {
// let mut results = Vec::with_capacity(tasks.len());
let results = tasks.await;
let num_elems = results.iter().map(|data| data.len()).sum();
let mut dst: Vec<T> = unsafe {
let mut v = Vec::with_capacity(num_elems);
v.set_len(num_elems);
v
};
let results_len = results.len();
for (k, data) in results.into_iter().enumerate() {
for (i, v) in data.into_iter().enumerate() {
dst[i * results_len + k] = v;
}
}
dst
})
}
};
self.spawned = true;
task
}
/// Blocks the current thread until the get transfer is complete and returns the retrieved
/// elements as `Vec<T>`.
///
/// Emits a [`RuntimeWarning`][crate::warnings::RuntimeWarning] when called inside an async
/// context; use `spawn()` or `.await` there instead.
///
/// # Examples
///```
/// use lamellar::array::prelude::*;
///
/// let world = LamellarWorldBuilder::new().build();
/// let my_pe = world.my_pe();
/// let num_pes = world.num_pes();
///
/// let array: ReadOnlyArray<usize> = ReadOnlyArray::new(&world, num_pes * 10, Distribution::Block).block();
///
/// let data = array.get_buffer(0, 5).block();
/// println!("PE{my_pe} elements[0..5]: {:?}", data);
///```
pub fn block(mut self) -> Vec<T> {
RuntimeWarning::BlockingCall(
"ArrayRdmaHandle::block",
"<handle>.spawn() or <handle>.await",
)
.print();
self.spawned = true;
match self.state {
ArrayRdmaGetBufferState::LocalAmGet(req) => req.block(),
ArrayRdmaGetBufferState::RemoteAmGet(req, mr) => {
req.block();
unsafe { mr.as_slice().to_vec() }
}
ArrayRdmaGetBufferState::RdmaGet(req) => req.block(),
ArrayRdmaGetBufferState::MultiRdmaBlockGet(ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
self.array.team().block_on(async move {
let data = tasks.await;
data.into_iter().flatten().collect()
})
}
ArrayRdmaGetBufferState::MultiRdmaCyclicGet(ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
self.array.team().block_on(async move {
let results = tasks.await;
let results_len = results.len();
let num_elems = results.iter().map(|data| data.len()).sum();
let mut dst: Vec<T> = unsafe {
let mut v = Vec::with_capacity(num_elems);
v.set_len(num_elems);
v
};
//results are ordered based on the pe where the first index was located, so we need to interleave them
for (k, data) in results.into_iter().enumerate() {
for (i, v) in data.into_iter().enumerate() {
dst[i * results_len + k] = v;
}
}
dst
})
}
}
}
}
impl<T: Dist> Future for ArrayRdmaGetBufferHandle<T> {
type Output = Vec<T>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
let res = match this.state.project() {
ArrayRdmaGetBufferStateProj::LocalAmGet(req) => req.poll(cx),
ArrayRdmaGetBufferStateProj::RemoteAmGet(req, mr) => match req.poll(cx) {
Poll::Ready(_) => {
let data = unsafe { mr.as_slice().to_vec() };
Poll::Ready(data)
}
Poll::Pending => Poll::Pending,
},
ArrayRdmaGetBufferStateProj::RdmaGet(req) => req.poll(cx),
ArrayRdmaGetBufferStateProj::MultiRdmaBlockGet(reqs) => match reqs.poll(cx) {
Poll::Ready(data) => {
let data = data.into_iter().flatten().collect();
Poll::Ready(data)
}
Poll::Pending => Poll::Pending,
},
ArrayRdmaGetBufferStateProj::MultiRdmaCyclicGet(reqs) => {
match reqs.poll(cx) {
Poll::Ready(mut results) => {
let num_elems = results.iter().map(|data| data.len()).sum();
let results_len = results.len();
let mut dst: Vec<T> = unsafe {
let mut v = Vec::with_capacity(num_elems);
v.set_len(num_elems);
v
};
for (k, data) in results.drain(..).enumerate() {
for (i, v) in data.into_iter().enumerate() {
dst[i * results_len + k] = v;
}
}
Poll::Ready(dst)
} //continue to process below
Poll::Pending => return Poll::Pending,
}
}
};
*this.spawned = true;
res
}
}
/// Handle returned by multi-element array RDMA get operations that write into a caller-supplied
/// [`LamellarBuffer`].
///
/// Resolves to `()` when driven to completion via `spawn()`, `block()`, or `.await`; the
/// transferred data is available in the original buffer afterwards.
/// Dropping this handle without doing so will only ensure completion if
/// [`wait_all`][crate::LamellarArray::wait_all] or a barrier is subsequently called.
#[pin_project]
pub struct ArrayRdmaGetIntoBufferHandle<T: Dist, B: AsLamellarBuffer<T>> {
pub(crate) array: LamellarByteArray, //prevents prematurely performing a local drop
#[pin]
pub(crate) state: ArrayRdmaGetIntoBufferState<T, B>,
pub(crate) spawned: bool,
// pub(crate) dst: LamellarBuffer<T, B>, //keep a reference to the dst buffer to ensure it is not dropped too early
}
#[pin_project(project = ArrayRdmaGetIntoBufferStateProj)]
pub(crate) enum ArrayRdmaGetIntoBufferState<T: Dist, B: AsLamellarBuffer<T>> {
LocalAmGet(#[pin] LocalAmHandle<()>), //Am is initiated as a local am
RemoteAmGet(LamellarBuffer<T, B>, #[pin] AmHandle<Vec<u8>>), //Am is initiated as a remote am
RdmaGet(#[pin] RdmaGetIntoBufferHandle<T, B>),
MultiRdmaBlockGet(#[pin] Collect<FuturesOrdered<RdmaGetIntoBufferHandle<T, B>>, Vec<()>>),
MultiRdmaCyclicGet(
LamellarBuffer<T, B>,
#[pin] Collect<FuturesOrdered<RdmaGetBufferHandle<T>>, Vec<Vec<T>>>,
),
}
impl<T: Dist, B: AsLamellarBuffer<T> + 'static> ArrayRdmaGetIntoBufferHandle<T, B> {
/// Enqueues the get operation on the runtime work queue and returns a [`LamellarTask<()>`]
/// that resolves when the transfer into the caller-supplied buffer is complete.
///
/// The buffer passed to the originating `get_into_buffer*` call will contain the results
/// after this task completes. Prefer `spawn()` or `.await` over `block()` inside async
/// contexts to avoid stalling the executor.
///
/// # Examples
///```
/// use lamellar::array::prelude::*;
/// use lamellar::memregion::prelude::*;
///
/// let world = LamellarWorldBuilder::new().build();
/// let my_pe = world.my_pe();
/// let num_pes = world.num_pes();
///
/// let array: ReadOnlyArray<usize> = ReadOnlyArray::new(&world, num_pes * 10, Distribution::Block).block();
///
/// let dst: Vec<usize> = vec![0usize; 5];
/// let buf = LamellarBuffer::from_vec(&world, dst);
/// let handle = array.get_into_buffer(0, buf);
/// let task = handle.spawn();
/// // do other work …
/// task.block();
/// // buf now contains the results — use try_unwrap to recover the Vec
///```
#[must_use = "this function returns a future used to poll for completion. Call '.await' on the future otherwise, if it is ignored (via ' let _ = *.spawn()') or dropped the only way to ensure completion is calling 'wait_all()' on the world or array. Alternatively it may be acceptable to call '.block()' instead of 'spawn()'"]
pub fn spawn(mut self) -> LamellarTask<()> {
let task = match self.state {
ArrayRdmaGetIntoBufferState::LocalAmGet(req) => req.spawn(),
ArrayRdmaGetIntoBufferState::RemoteAmGet(mut buf, req) => {
let task = req.spawn();
self.array.spawn(async move {
let data = task.await;
let buf_slice = buf.as_mut_slice();
let buf_slice_u8 = unsafe {
std::slice::from_raw_parts_mut(
buf_slice.as_mut_ptr() as *mut u8,
buf_slice.len() * std::mem::size_of::<T>(),
)
};
buf_slice_u8.copy_from_slice(&data);
})
}
ArrayRdmaGetIntoBufferState::RdmaGet(req) => req.spawn(),
ArrayRdmaGetIntoBufferState::MultiRdmaBlockGet(ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
self.array.spawn(async move {
tasks.await;
})
}
ArrayRdmaGetIntoBufferState::MultiRdmaCyclicGet(ref mut dst, ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
let mut tmp_dst = dst.split_off(0); //poor mans clone
self.array.spawn(async move {
let results = tasks.await;
let dst_slice = tmp_dst.as_mut_slice();
let results_len = results.len();
// let mut k = 0;
for (k, data) in results.into_iter().enumerate() {
for (i, v) in data.into_iter().enumerate() {
dst_slice[i * results_len + k] = v;
}
}
})
}
};
self.spawned = true;
task
}
/// Blocks the current thread until the get transfer into the caller-supplied buffer is
/// complete.
///
/// The buffer passed to the originating `get_into_buffer*` call will contain the results
/// after this returns. Emits a [`RuntimeWarning`][crate::warnings::RuntimeWarning] when
/// called inside an async context; use `spawn()` or `.await` there instead.
///
/// # Examples
///```
/// use lamellar::array::prelude::*;
/// use lamellar::memregion::prelude::*;
///
/// let world = LamellarWorldBuilder::new().build();
/// let my_pe = world.my_pe();
/// let num_pes = world.num_pes();
///
/// let array: ReadOnlyArray<usize> = ReadOnlyArray::new(&world, num_pes * 10, Distribution::Block).block();
///
/// let dst: Vec<usize> = vec![0usize; 5];
/// let mut buf = LamellarBuffer::from_vec(&world, dst);
/// let handle = buf.split_off(0);
/// array.get_into_buffer(0, handle).block();
/// let result = buf.try_unwrap().expect("no other references exist");
/// println!("PE{my_pe} elements[0..5]: {:?}", result);
///```
pub fn block(mut self) {
RuntimeWarning::BlockingCall(
"ArrayRdmaHandle::block",
"<handle>.spawn() or <handle>.await",
)
.print();
self.spawned = true;
match self.state {
ArrayRdmaGetIntoBufferState::LocalAmGet(req) => req.block(),
ArrayRdmaGetIntoBufferState::RemoteAmGet(mut buf, req) => {
let data = req.block();
let buf_slice = buf.as_mut_slice();
let buf_slice_u8 = unsafe {
std::slice::from_raw_parts_mut(
buf_slice.as_mut_ptr() as *mut u8,
buf_slice.len() * std::mem::size_of::<T>(),
)
};
buf_slice_u8.copy_from_slice(&data);
}
ArrayRdmaGetIntoBufferState::RdmaGet(req) => req.block(),
ArrayRdmaGetIntoBufferState::MultiRdmaBlockGet(ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
self.array.team().block_on(async move {
tasks.await;
});
}
ArrayRdmaGetIntoBufferState::MultiRdmaCyclicGet(ref mut dst, ref mut reqs) => {
let mut tasks = FuturesOrdered::new().collect();
std::mem::swap(&mut tasks, reqs);
let mut tmp_dst = dst.split_off(0); //poor mans clone
self.array.team().block_on(async move {
let results = tasks.await;
let dst_slice = tmp_dst.as_mut_slice();
let results_len = results.len();
for (k, data) in results.into_iter().enumerate() {
for (i, v) in data.into_iter().enumerate() {
dst_slice[i * results_len + k] = v;
}
}
});
}
}
}
}
impl<T: Dist, B: AsLamellarBuffer<T>> Future for ArrayRdmaGetIntoBufferHandle<T, B> {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
let res = match this.state.project() {
ArrayRdmaGetIntoBufferStateProj::LocalAmGet(req) => match req.poll(cx) {
Poll::Ready(_) => Poll::Ready(()),
Poll::Pending => Poll::Pending,
},
ArrayRdmaGetIntoBufferStateProj::RemoteAmGet(buf, req) => match req.poll(cx) {
Poll::Ready(data) => {
let buf_slice = buf.as_mut_slice();
let buf_slice_u8 = unsafe {
std::slice::from_raw_parts_mut(
buf_slice.as_mut_ptr() as *mut u8,
buf_slice.len() * std::mem::size_of::<T>(),
)
};
buf_slice_u8.copy_from_slice(&data);
Poll::Ready(())
}
Poll::Pending => Poll::Pending,
},
ArrayRdmaGetIntoBufferStateProj::RdmaGet(req) => match req.poll(cx) {
Poll::Ready(_) => Poll::Ready(()),
Poll::Pending => Poll::Pending,
},
ArrayRdmaGetIntoBufferStateProj::MultiRdmaBlockGet(reqs) => match reqs.poll(cx) {
Poll::Ready(_) => Poll::Ready(()),
Poll::Pending => Poll::Pending,
},
ArrayRdmaGetIntoBufferStateProj::MultiRdmaCyclicGet(dst, reqs) => match reqs.poll(cx) {
Poll::Ready(mut results) => {
let results_len = results.len();
let dst_slice = dst.as_mut_slice();
for (k, data) in results.drain(..).enumerate() {
for (i, v) in data.into_iter().enumerate() {
dst_slice[i * results_len + k] = v;
}
}
Poll::Ready(())
}
Poll::Pending => Poll::Pending,
},
};
*this.spawned = true;
res
}
}