forked from kokkos/kokkos-comm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore_send.cpp
More file actions
29 lines (21 loc) · 822 Bytes
/
core_send.cpp
File metadata and controls
29 lines (21 loc) · 822 Bytes
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
#include <Kokkos_Comm.hpp>
// Define the execution space and transport
using ExecSpace = Kokkos::DefaultExecutionSpace;
using Transport = DefaultTransport;
// Create a Kokkos view
Kokkos::View<double*> data("data", 100);
// Fill the view with some data
Kokkos::parallel_for("fill_data", Kokkos::RangePolicy<ExecSpace>(0, 100), KOKKOS_LAMBDA(int i) {
data(i) = static_cast<double>(i);
});
// Destination rank and message tag
int dest = 1;
// Create a handle
KokkosComm::Handle<> handle; // Same as Handle<Execspace, Transport>
// Initiate a non-blocking send with a handle
auto req1 = send(handle, data, dest);
// Initiate a non-blocking send with a default handle
auto req2 = send(data, dest);
// Wait for the requests to complete (assuming a wait function exists)
KokkosComm::wait(req1);
KokkosComm::wait(req2);