39 sendRanks_ = t.sendRanks;
40 sendCounts_ = t.sendCounts;
41 sendOff_ = t.sendOffsets;
42 recvRanks_ = t.recvRanks;
43 recvCounts_ = t.recvCounts;
44 recvOff_.assign(t.recvOffsets.begin(),
46 nSend_ =
static_cast<Index>(t.sendIdx.size());
48 numReceived_ = t.numReceived;
49 numSelf_ = numGhost_ - numReceived_;
50 d_sendIdx_ =
toDevice(t.sendIdx,
"peclet::core::halo::p_sendIdx");
51 d_selfIdx_ =
toDevice(t.selfIdx,
"peclet::core::halo::p_selfIdx");
58 View<T> sendBuf = scratchAs<T>(
"peclet::core::halo::p_sendBuf");
64 "peclet::core::halo::p_gather", Kokkos::RangePolicy<ExecSpace>(0, nSend_),
65 KOKKOS_LAMBDA(
const Index i) { buf(i) = o(idx(i)); });
70 std::vector<T> hSend, hRecv;
75 sendBase = sendBuf.data();
76 recvBase = ghost.data();
78 hSend.resize(
static_cast<std::size_t
>(nSend_));
79 hRecv.resize(
static_cast<std::size_t
>(numReceived_));
80 copyToHost(sendBuf, hSend);
81 sendBase = hSend.data();
82 recvBase = hRecv.data();
85 std::vector<MPI_Request> reqs;
86 postRecv(recvBase, recvRanks_, recvOff_, recvCounts_, tag, reqs);
87 postSend(sendBase, sendRanks_, sendOff_, sendCounts_, tag, reqs);
91 if (!aware && numReceived_) {
92 auto sub = Kokkos::subview(
93 ghost, std::pair<std::size_t, std::size_t>(0,
static_cast<std::size_t
>(numReceived_)));
94 Kokkos::View<const T*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>> hv(
95 hRecv.data(), hRecv.size());
96 Kokkos::deep_copy(sub, hv);
104 const Index base = numReceived_;
105 Kokkos::parallel_for(
106 "peclet::core::halo::p_selfGather", Kokkos::RangePolicy<ExecSpace>(0, numSelf_),
107 KOKKOS_LAMBDA(
const Index j) { g(base + j) = o(sidx(j)); });
117 std::vector<T> hGhost, hRecv;
121 scratchAs<T>(
"peclet::core::halo::p_recvBuf");
124 ghostBase = ghost.data();
125 recvBase = recvBuf.data();
130 hGhost.resize(
static_cast<std::size_t
>(numReceived_));
131 hRecv.resize(
static_cast<std::size_t
>(nSend_));
133 copyToHost(Kokkos::subview(ghost, std::pair<std::size_t, std::size_t>(
134 0,
static_cast<std::size_t
>(numReceived_))),
136 ghostBase = hGhost.data();
137 recvBase = hRecv.data();
142 std::vector<MPI_Request> reqs;
143 postRecv(recvBase, sendRanks_, sendOff_, sendCounts_, tag, reqs);
144 postSend(ghostBase, recvRanks_, recvOff_, recvCounts_, tag, reqs);
149 copyToDevice(hRecv, recvBuf);
155 Kokkos::parallel_for(
156 "peclet::core::halo::p_scatter", Kokkos::RangePolicy<ExecSpace>(0, nSend_),
157 KOKKOS_LAMBDA(
const Index i) { Kokkos::atomic_add(&o(idx(i)), buf(i)); });
164 const Index base = numReceived_;
165 Kokkos::parallel_for(
166 "peclet::core::halo::p_selfScatter", Kokkos::RangePolicy<ExecSpace>(0, numSelf_),
167 KOKKOS_LAMBDA(
const Index j) { Kokkos::atomic_add(&o(sidx(j)), g(base + j)); });
179 Kokkos::View<T*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>> hv(h.data(),
200 Kokkos::View<const T*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>> hv(h.data(),