@@ -143,20 +143,20 @@ namespace comm {
143143 }
144144 if (send_rank >= 0 ) {
145145 if constexpr (D == Dim::_1D) {
146- auto host_send_fld = ndarray_mirror_t <2 >(" send_fld" ,
146+ send_fld = ndarray_t <2 >(" send_fld" ,
147147 send_slice[0 ].second - send_slice[0 ].first ,
148148 comps.second - comps.first );
149149 Kokkos::deep_copy (send_fld, Kokkos::subview (fld, send_slice[0 ], comps));
150150 } else if constexpr (D == Dim::_2D) {
151- auto host_send_fld = ndarray_mirror_t <3 >(" send_fld" ,
151+ send_fld = ndarray_t <3 >(" send_fld" ,
152152 send_slice[0 ].second - send_slice[0 ].first ,
153153 send_slice[1 ].second - send_slice[1 ].first ,
154154 comps.second - comps.first );
155155 Kokkos::deep_copy (
156156 send_fld,
157157 Kokkos::subview (fld, send_slice[0 ], send_slice[1 ], comps));
158158 } else if constexpr (D == Dim::_3D) {
159- auto host_send_fld = ndarray_mirror_t <4 >(" send_fld" ,
159+ send_fld = ndarray_t <4 >(" send_fld" ,
160160 send_slice[0 ].second - send_slice[0 ].first ,
161161 send_slice[1 ].second - send_slice[1 ].first ,
162162 send_slice[2 ].second - send_slice[2 ].first ,
@@ -168,22 +168,26 @@ namespace comm {
168168 }
169169 if (recv_rank >= 0 ) {
170170 if constexpr (D == Dim::_1D) {
171- host_recv_fld = ndarray_mirror_t <2 >(" recv_fld" ,
171+ recv_fld = ndarray_t <2 >(" recv_fld" ,
172172 recv_slice[0 ].second - recv_slice[0 ].first ,
173173 comps.second - comps.first );
174174 } else if constexpr (D == Dim::_2D) {
175- host_recv_fld = ndarray_mirror_t <3 >(" recv_fld" ,
175+ recv_fld = ndarray_t <3 >(" recv_fld" ,
176176 recv_slice[0 ].second - recv_slice[0 ].first ,
177177 recv_slice[1 ].second - recv_slice[1 ].first ,
178178 comps.second - comps.first );
179179 } else if constexpr (D == Dim::_3D) {
180- host_recv_fld = ndarray_mirror_t <4 >(" recv_fld" ,
180+ recv_fld = ndarray_t <4 >(" recv_fld" ,
181181 recv_slice[0 ].second - recv_slice[0 ].first ,
182182 recv_slice[1 ].second - recv_slice[1 ].first ,
183183 recv_slice[2 ].second - recv_slice[2 ].first ,
184184 comps.second - comps.first );
185185 }
186186 }
187+ auto host_send_fld = Kokkos::create_mirror_view (send_fld);
188+ auto host_recv_fld = Kokkos::create_mirror_view (recv_fld);
189+
190+ Kokkos::deep_copy (host_send_fld, send_fld);
187191
188192 if (send_rank >= 0 && recv_rank >= 0 ) {
189193 MPI_Sendrecv (host_send_fld.data (),
@@ -198,6 +202,8 @@ namespace comm {
198202 0 ,
199203 MPI_COMM_WORLD,
200204 MPI_STATUS_IGNORE);
205+
206+ Kokkos::deep_copy (recv_fld, host_recv_fld);
201207 } else if (send_rank >= 0 ) {
202208 MPI_Send (host_send_fld.data (),
203209 nsend,
@@ -214,6 +220,8 @@ namespace comm {
214220 0 ,
215221 MPI_COMM_WORLD,
216222 MPI_STATUS_IGNORE);
223+
224+ Kokkos::deep_copy (recv_fld, host_recv_fld);
217225 } else {
218226 raise::Error (" CommunicateField called with negative ranks" , HERE);
219227 }
@@ -223,16 +231,15 @@ namespace comm {
223231 // !TODO: perhaps directly recv to the fld?
224232 if (not additive) {
225233 if constexpr (D == Dim::_1D) {
226- Kokkos::deep_copy (Kokkos::subview (fld, recv_slice[0 ], comps), host_recv_fld );
234+ Kokkos::deep_copy (Kokkos::subview (fld, recv_slice[0 ], comps), recv_fld );
227235 } else if constexpr (D == Dim::_2D) {
228236 Kokkos::deep_copy (
229- Kokkos::subview (fld, recv_slice[0 ], recv_slice[1 ], comps), host_recv_fld );
237+ Kokkos::subview (fld, recv_slice[0 ], recv_slice[1 ], comps), recv_fld );
230238 } else if constexpr (D == Dim::_3D) {
231239 Kokkos::deep_copy (
232- Kokkos::subview (fld, recv_slice[0 ], recv_slice[1 ], recv_slice[2 ], comps), host_recv_fld );
240+ Kokkos::subview (fld, recv_slice[0 ], recv_slice[1 ], recv_slice[2 ], comps), recv_fld );
233241 }
234242 } else {
235- auto recv_fld = Kokkos::create_mirror_view (host_recv_fld);
236243 Kokkos::deep_copy (recv_fld, host_recv_fld);
237244 if constexpr (D == Dim::_1D) {
238245 const auto offset_x1 = recv_slice[0 ].first ;
0 commit comments