305 ArrayView<global_ordinal_t> colind_view = colind_arrayview.view(rowInd,rowNNZ);
306 ArrayView<scalar_t> nzval_view = nzval_arrayview.view(rowInd,rowNNZ);
308 get_mat->getGlobalRowCopy(*row_it, colind_view, nzval_view, nnzRet);
310 for (
size_t rr = 0; rr < nnzRet ; rr++) {
311 colind_view[rr] -= rmap->getIndexBase();
317 if( ordering == SORTED_INDICES ) {
318 Tpetra::sort2(colind_view.begin(), colind_view.end(), nzval_view.begin());
321 TEUCHOS_TEST_FOR_EXCEPTION( rowNNZ != nnzRet,
323 "Number of values returned different from "
324 "number of values reported");
327 host_rowptr(rowptr_ind) = nnz = rowInd;
329 deep_copy_or_assign_view(nzval, mat_nzval);
330 deep_copy_or_assign_view(colind, mat_colind);
331 deep_copy_or_assign_view(rowptr, host_rowptr);
334 global_host_idx_t mat_colind(Kokkos::ViewAllocateWithoutInitializing(
"mat_colind"), nzval.size());
335 global_host_val_t mat_nzvals(Kokkos::ViewAllocateWithoutInitializing(
"mat_nzvals"), colind.size());
337 auto host_colind = Kokkos::create_mirror_view(colind);
338 auto host_nzval = Kokkos::create_mirror_view(nzval);
341 for( row_it = node_elements.begin(); row_it != row_end; ++row_it ){
342 size_t rowNNZ = get_mat->getGlobalRowNNZ(*row_it);
343 size_t nnzRet = OrdinalTraits<size_t>::zero();
347 global_host_idx_t colind_view (&(mat_colind(rowInd)), rowNNZ);
348 global_host_val_t nzvals_view (&(mat_nzvals(rowInd)), rowNNZ);
350 global_ordinal_t row_id = *row_it;
351 get_mat->getGlobalRowCopy_kokkos_view(row_id, colind_view, nzvals_view, nnzRet);
353 TEUCHOS_TEST_FOR_EXCEPTION( rowNNZ != nnzRet,
355 "Number of values returned different from "
356 "number of values reported");
357 host_rowptr(rowptr_ind++) = rowInd;
360 host_rowptr(rowptr_ind) = nnz = rowInd;
363 if (rmap->getIndexBase() != 0) {
364 for (
size_t k = 0; k < mat_colind.extent(0); k++) {
365 mat_colind(k) -= rmap->getIndexBase();
370 deep_copy_or_assign_view(nzval, mat_nzvals);
371 deep_copy_or_assign_view(colind, mat_colind);
372 deep_copy_or_assign_view(rowptr, host_rowptr);
375 if( ordering == SORTED_INDICES ) {
376 using execution_space =
typename KV_GS::execution_space;
377 KokkosSparse::sort_crs_matrix <execution_space, KV_GS, KV_GO, KV_S>
378 (rowptr, colind, nzval);
383 template <
class Matrix >
384 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
386 MatrixAdapter<Matrix>::help_getCcs_kokkos_view(KV_S & nzval,
389 typename MatrixAdapter<Matrix>::global_size_t& nnz,
390 const Teuchos::Ptr<const map_t> colmap,
391 EDistribution distribution,
392 EStorage_Ordering ordering,
393 no_special_impl nsi)
const
398 do_getCcs_kokkos_view(nzval, rowind, colptr,
399 nnz, colmap, distribution, ordering,
400 typename adapter_t::major_access());
403 template <
class Matrix >
404 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
406 MatrixAdapter<Matrix>::do_getCcs_kokkos_view(KV_S & nzval,
409 typename MatrixAdapter<Matrix>::global_size_t& nnz,
410 const Teuchos::Ptr<const map_t> colmap,
411 EDistribution distribution,
412 EStorage_Ordering ordering,
415 using Teuchos::ArrayView;
420 KV_S nzval_tmp(Kokkos::ViewAllocateWithoutInitializing(
"nzval_tmp"), nzval.size());
421 KV_GO colind(Kokkos::ViewAllocateWithoutInitializing(
"colind"), rowind.size());
422 KV_GS rowptr(Kokkos::ViewAllocateWithoutInitializing(
"rowptr"), this->getGlobalNumRows() + 1);
424 this->getCrs_kokkos_view(nzval_tmp, colind, rowptr, nnz, colmap, ordering, distribution);
430 ArrayView<typename KV_S::value_type> av_nzval_tmp(nzval_tmp.data(), nzval_tmp.size());
431 ArrayView<typename KV_GO::value_type> av_colind(colind.data(), colind.size());
432 ArrayView<typename KV_GS::value_type> av_rowptr(rowptr.data(), rowptr.size());
433 ArrayView<typename KV_S::value_type> av_nzval(nzval.data(), nzval.size());
434 ArrayView<typename KV_GO::value_type> av_rowind(rowind.data(), rowind.size());
435 ArrayView<typename KV_GS::value_type> av_colptr(colptr.data(), colptr.size());
436 Util::transpose(av_nzval_tmp, av_colind, av_rowptr, av_nzval, av_rowind, av_colptr);
441 template <
class Matrix >
442 template<
typename KV_GO,
typename KV_S>
449 static_cast<const adapter_t*
>(
this)->getGlobalRowCopy_kokkos_view_impl(row, indices, vals, nnz);
528 host_ordinal_type_array &perm_g2l,
529 host_ordinal_type_array &recvCountRows, host_ordinal_type_array &recvDisplRows,
530 host_ordinal_type_array &recvCounts, host_ordinal_type_array &recvDispls,
531 host_ordinal_type_array &transpose_map, host_scalar_type_array &nzvals_t,
532 bool column_major,
EPhase current_phase)
const
534 return static_cast<const adapter_t*
>(
this)->gather_impl(nzvals, indices, pointers, perm_g2l, recvCountRows, recvDisplRows, recvCounts, recvDispls,
535 transpose_map, nzvals_t, column_major, current_phase);