@@ -239,6 +239,68 @@ namespace Amesos2 {
239
239
node_t > > source_map,
240
240
EDistribution distribution );
241
241
242
+ template <typename KV, typename host_ordinal_type_array>
243
+ int
244
+ gather (KV& kokkos_new_view,
245
+ host_ordinal_type_array &perm_g2l,
246
+ host_ordinal_type_array &recvCountRows,
247
+ host_ordinal_type_array &recvDisplRows,
248
+ EDistribution distribution) const
249
+ {
250
+ auto comm = this ->getComm ();
251
+ int myRank = comm->getRank ();
252
+ int nCols = this ->mv_ ->NumVectors ();
253
+ int nRows = this ->mv_ ->GlobalLength ();
254
+ int nRows_l = this ->mv_ ->MyLength ();
255
+ if (myRank == 0 ) {
256
+ Kokkos::resize (kokkos_new_view, nRows, nCols);
257
+ if (int (perm_g2l.extent (0 )) == nRows) {
258
+ Kokkos::resize (this ->buf_ , nRows, 1 );
259
+ } else {
260
+ Kokkos::resize (this ->buf_ , 0 , 1 );
261
+ }
262
+ }
263
+ {
264
+ for (int j=0 ; j<nCols; j++) {
265
+ scalar_t * recvbuf = reinterpret_cast <scalar_t *> (myRank != 0 || this ->buf_ .extent (0 ) > 0 ? this ->buf_ .data () : &kokkos_new_view (0 ,j));
266
+ Teuchos::gatherv<int , scalar_t > (const_cast <scalar_t *> ((*this ->mv_ )[j]), nRows_l,
267
+ recvbuf, recvCountRows.data (), recvDisplRows.data (),
268
+ 0 , *comm);
269
+ if (myRank == 0 && this ->buf_ .extent (0 ) > 0 ) {
270
+ for (int i=0 ; i<nRows; i++) kokkos_new_view (perm_g2l (i),j) = this ->buf_ (i,0 );
271
+ }
272
+ }
273
+ }
274
+ return 0 ;
275
+ }
276
+
277
+ template <typename KV, typename host_ordinal_type_array>
278
+ int
279
+ scatter (KV& kokkos_new_view,
280
+ host_ordinal_type_array &perm_g2l,
281
+ host_ordinal_type_array &sendCountRows,
282
+ host_ordinal_type_array &sendDisplRows,
283
+ EDistribution distribution) const
284
+ {
285
+ auto comm = this ->getMap ()->getComm ();
286
+ int myRank = comm->getRank ();
287
+ int nCols = this ->mv_ ->NumVectors ();
288
+ int nRows = this ->mv_ ->GlobalLength ();
289
+ int nRows_l = this ->mv_ ->MyLength ();
290
+ {
291
+ for (int j=0 ; j<nCols; j++) {
292
+ if (myRank == 0 && this ->buf_ .extent (0 ) > 0 ) {
293
+ for (int i=0 ; i<nRows; i++) this ->buf_ (i, 0 ) = kokkos_new_view (perm_g2l (i),j);
294
+ }
295
+ scalar_t * sendbuf = reinterpret_cast <scalar_t *> (myRank != 0 || this ->buf_ .extent (0 ) > 0 ? this ->buf_ .data () : &kokkos_new_view (0 ,j));
296
+ Teuchos::scatterv<int , scalar_t > (sendbuf, sendCountRows.data (), sendDisplRows.data (),
297
+ reinterpret_cast <scalar_t *> ((*this ->mv_ )[j]), nRows_l,
298
+ 0 , *comm);
299
+ }
300
+ }
301
+ return 0 ;
302
+ }
303
+
242
304
// / Get a short description of this adapter class
243
305
std::string description () const ;
244
306
@@ -252,6 +314,7 @@ namespace Amesos2 {
252
314
253
315
// / The multi-vector this adapter wraps
254
316
Teuchos::RCP<multivec_t > mv_;
317
+ mutable Kokkos::View<scalar_t **, Kokkos::LayoutLeft, Kokkos::HostSpace> buf_;
255
318
256
319
mutable Teuchos::RCP<Epetra_Import> importer_;
257
320
mutable Teuchos::RCP<Epetra_Export> exporter_;
0 commit comments