Tpetra parallel linear algebra  Version of the Day
Classes | Namespaces | Functions
Tpetra_Details_unpackCrsMatrixAndCombine_def.hpp File Reference

Definition of functions for unpacking the entries of a Tpetra::CrsMatrix for communication, in the case where it is valid to go to the KokkosSparse::CrsMatrix (local sparse matrix data structure) directly. More...

#include "TpetraCore_config.h"
#include "Teuchos_Array.hpp"
#include "Teuchos_ArrayView.hpp"
#include "Tpetra_Details_castAwayConstDualView.hpp"
#include "Tpetra_Details_computeOffsets.hpp"
#include "Tpetra_Details_createMirrorView.hpp"
#include "Tpetra_Details_OrdinalTraits.hpp"
#include "Tpetra_Details_PackTraits.hpp"
#include "Tpetra_CrsMatrix_decl.hpp"
#include "Tpetra_Details_getEntryOnHost.hpp"
#include "Kokkos_Core.hpp"
#include <memory>
#include <string>

Go to the source code of this file.

Classes

struct  Tpetra::Details::UnpackAndCombineCrsMatrixImpl::UnpackCrsMatrixAndCombineFunctor< LocalMatrix, LocalMap, BufferDeviceType >
 Unpacks and combines a single row of the CrsMatrix. More...
 
class  Tpetra::Details::UnpackAndCombineCrsMatrixImpl::NumEntriesFunctor< LO, DT, BDT >
 Kokkos::parallel_reduce functor to determine the number of entries (to unpack) in a KokkosSparse::CrsMatrix to pack. More...
 

Namespaces

 Tpetra
 Namespace Tpetra contains the class and methods constituting the Tpetra library.
 
 Tpetra::Details
 Namespace for Tpetra implementation details.
 

Functions

template<class ST , class LO , class GO , class DT , class BDT >
KOKKOS_FUNCTION int Tpetra::Details::UnpackAndCombineCrsMatrixImpl::unpackRow (typename PackTraits< GO, DT >::output_array_type &gids_out, typename PackTraits< int, DT >::output_array_type &pids_out, typename PackTraits< ST, DT >::output_array_type &vals_out, const Kokkos::View< const char *, BDT > &imports, const size_t offset, const size_t num_bytes, const size_t num_ent, const size_t num_bytes_per_value)
 Unpack a single row of a CrsMatrix. More...
 
template<class LO , class DT , class BDT >
size_t Tpetra::Details::UnpackAndCombineCrsMatrixImpl::compute_maximum_num_entries (const Kokkos::View< const size_t *, BDT > &num_packets_per_lid, const Kokkos::View< const size_t *, DT > &offsets, const Kokkos::View< const char *, BDT > &imports)
 Maximum number of entries in any row of the packed matrix. More...
 
template<class LO , class DT , class BDT >
size_t Tpetra::Details::UnpackAndCombineCrsMatrixImpl::compute_total_num_entries (const Kokkos::View< const size_t *, BDT > &num_packets_per_lid, const Kokkos::View< const size_t *, DT > &offsets, const Kokkos::View< const char *, BDT > &imports)
 Total number of entries in any row of the packed matrix. More...
 
template<class LocalMatrix , class LocalMap , class BufferDeviceType >
void Tpetra::Details::UnpackAndCombineCrsMatrixImpl::unpackAndCombineIntoCrsMatrix (const LocalMatrix &local_matrix, const LocalMap &local_map, const Kokkos::View< const char *, BufferDeviceType > &imports, const Kokkos::View< const size_t *, BufferDeviceType > &num_packets_per_lid, const typename PackTraits< typename LocalMap::local_ordinal_type, typename LocalMap::device_type >::input_array_type import_lids, const Tpetra::CombineMode combine_mode, const bool unpack_pids, const bool atomic)
 Perform the unpack operation for the matrix. More...
 
template<class LO , class DT , class BDT >
int Tpetra::Details::UnpackAndCombineCrsMatrixImpl::setupRowPointersForRemotes (const typename PackTraits< size_t, DT >::output_array_type &tgt_rowptr, const typename PackTraits< LO, DT >::input_array_type &import_lids, const Kokkos::View< const char *, BDT > &imports, const Kokkos::View< const size_t *, BDT > &num_packets_per_lid, const typename PackTraits< size_t, DT >::input_array_type &offsets)
 Setup row pointers for remotes. More...
 
template<typename ST , typename LO , typename GO , typename Node >
void Tpetra::Details::unpackCrsMatrixAndCombine (const CrsMatrix< ST, LO, GO, Node > &sourceMatrix, const Teuchos::ArrayView< const char > &imports, const Teuchos::ArrayView< const size_t > &numPacketsPerLID, const Teuchos::ArrayView< const LO > &importLIDs, size_t constantNumPackets, Distributor &distor, CombineMode combineMode, const bool atomic)
 Unpack the imported column indices and values, and combine into matrix. More...
 
template<typename Scalar , typename LocalOrdinal , typename GlobalOrdinal , typename Node >
size_t Tpetra::Details::unpackAndCombineWithOwningPIDsCount (const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &sourceMatrix, const Teuchos::ArrayView< const LocalOrdinal > &importLIDs, const Teuchos::ArrayView< const char > &imports, const Teuchos::ArrayView< const size_t > &numPacketsPerLID, size_t constantNumPackets, Distributor &distor, CombineMode combineMode, size_t numSameIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteToLIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteFromLIDs)
 Special version of Tpetra::Details::unpackCrsMatrixAndCombine that also unpacks owning process ranks. More...
 
template<typename Scalar , typename LocalOrdinal , typename GlobalOrdinal , typename Node >
void Tpetra::Details::unpackAndCombineIntoCrsArrays (const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &sourceMatrix, const Teuchos::ArrayView< const LocalOrdinal > &importLIDs, const Teuchos::ArrayView< const char > &imports, const Teuchos::ArrayView< const size_t > &numPacketsPerLID, const size_t constantNumPackets, Distributor &distor, const CombineMode combineMode, const size_t numSameIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteToLIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteFromLIDs, size_t TargetNumRows, size_t TargetNumNonzeros, const int MyTargetPID, const Teuchos::ArrayView< size_t > &CRS_rowptr, const Teuchos::ArrayView< GlobalOrdinal > &CRS_colind, const Teuchos::ArrayView< typename CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::impl_scalar_type > &CRS_vals, const Teuchos::ArrayView< const int > &SourcePids, Teuchos::Array< int > &TargetPids)
 unpackAndCombineIntoCrsArrays More...
 

Detailed Description

Definition of functions for unpacking the entries of a Tpetra::CrsMatrix for communication, in the case where it is valid to go to the KokkosSparse::CrsMatrix (local sparse matrix data structure) directly.

Warning
This file, and its contents, are implementation details of Tpetra. The file itself or its contents may disappear or change at any time.

Data (bytes) describing the row of the CRS matrix are "packed" (concatenated) in to a (view of) char* object in the following order:

  1. number of entries (LocalOrdinal)
  2. global column indices (GlobalOrdinal)
  3. proces IDs (optional, int)
  4. row values (Scalar)

The functions in this file are companions to Tpetra_Details_packCrsMatrix.hpp, i.e., Tpetra_Details_packCrsMatrix.hpp implements the packing order described above to ensure proper unpacking.

Definition in file Tpetra_Details_unpackCrsMatrixAndCombine_def.hpp.

Function Documentation

◆ unpackRow()

template<class ST , class LO , class GO , class DT , class BDT >
KOKKOS_FUNCTION int Tpetra::Details::UnpackAndCombineCrsMatrixImpl::unpackRow ( typename PackTraits< GO, DT >::output_array_type &  gids_out,
typename PackTraits< int, DT >::output_array_type &  pids_out,
typename PackTraits< ST, DT >::output_array_type &  vals_out,
const Kokkos::View< const char *, BDT > &  imports,
const size_t  offset,
const size_t  num_bytes,
const size_t  num_ent,
const size_t  num_bytes_per_value 
)

Unpack a single row of a CrsMatrix.

Template Parameters
STThe type of the numerical entries of the matrix. (You can use real-valued or complex-valued types here, unlike in Epetra, where the scalar type is always double.)
LOThe type of local indices. See the documentation of Map for requirements.
GOThe type of global indices. See the documentation of Map for requirements.
DTThe Kokkos device type. See the documentation of Map for requirements.
BDTThe "buffer device type."

Definition at line 108 of file Tpetra_Details_unpackCrsMatrixAndCombine_def.hpp.

◆ compute_maximum_num_entries()

template<class LO , class DT , class BDT >
size_t Tpetra::Details::UnpackAndCombineCrsMatrixImpl::compute_maximum_num_entries ( const Kokkos::View< const size_t *, BDT > &  num_packets_per_lid,
const Kokkos::View< const size_t *, DT > &  offsets,
const Kokkos::View< const char *, BDT > &  imports 
)

Maximum number of entries in any row of the packed matrix.

Template Parameters
LOThe type of local indices.
DTThe Kokkos device type.
The"buffer device type."

This procedure is a higher-level interface to NumEntriesFunctor.

Definition at line 479 of file Tpetra_Details_unpackCrsMatrixAndCombine_def.hpp.

◆ compute_total_num_entries()

template<class LO , class DT , class BDT >
size_t Tpetra::Details::UnpackAndCombineCrsMatrixImpl::compute_total_num_entries ( const Kokkos::View< const size_t *, BDT > &  num_packets_per_lid,
const Kokkos::View< const size_t *, DT > &  offsets,
const Kokkos::View< const char *, BDT > &  imports 
)

Total number of entries in any row of the packed matrix.

Template Parameters
LOThe type of local indices.
DTThe Kokkos device type.
BDTThe "buffer device type."

This procedure is a high level interface to NumEntriesFunctor

Definition at line 508 of file Tpetra_Details_unpackCrsMatrixAndCombine_def.hpp.

◆ unpackAndCombineIntoCrsMatrix()

template<class LocalMatrix , class LocalMap , class BufferDeviceType >
void Tpetra::Details::UnpackAndCombineCrsMatrixImpl::unpackAndCombineIntoCrsMatrix ( const LocalMatrix &  local_matrix,
const LocalMap local_map,
const Kokkos::View< const char *, BufferDeviceType > &  imports,
const Kokkos::View< const size_t *, BufferDeviceType > &  num_packets_per_lid,
const typename PackTraits< typename LocalMap::local_ordinal_type, typename LocalMap::device_type >::input_array_type  import_lids,
const Tpetra::CombineMode  combine_mode,
const bool  unpack_pids,
const bool  atomic 
)

Perform the unpack operation for the matrix.

Template Parameters
LocalMatrixthe specialization of the KokkosSparse::CrsMatrix local matrix
LocalMapthe type of the local column map

This is a higher level interface to the UnpackCrsMatrixAndCombineFunctor

Definition at line 535 of file Tpetra_Details_unpackCrsMatrixAndCombine_def.hpp.

◆ setupRowPointersForRemotes()

template<class LO , class DT , class BDT >
int Tpetra::Details::UnpackAndCombineCrsMatrixImpl::setupRowPointersForRemotes ( const typename PackTraits< size_t, DT >::output_array_type &  tgt_rowptr,
const typename PackTraits< LO, DT >::input_array_type &  import_lids,
const Kokkos::View< const char *, BDT > &  imports,
const Kokkos::View< const size_t *, BDT > &  num_packets_per_lid,
const typename PackTraits< size_t, DT >::input_array_type &  offsets 
)

Setup row pointers for remotes.

Definition at line 699 of file Tpetra_Details_unpackCrsMatrixAndCombine_def.hpp.