10#include "Tpetra_Details_PackTriples.hpp"
12#ifdef HAVE_TPETRACORE_MPI
16mpiErrorCodeToString(
const int errCode) {
17 if (errCode == MPI_SUCCESS) {
20 char rawErrString[MPI_MAX_ERROR_STRING];
22 int err = MPI_Error_string(errCode, rawErrString, &len);
23 if (err != MPI_SUCCESS) {
27 if (MPI_MAX_ERROR_STRING > 0) {
28 rawErrString[0] =
'\0';
31 return std::string(rawErrString);
41#ifdef HAVE_TPETRACORE_MPI
43int countPackTriplesCountMpi(MPI_Comm comm,
45 std::ostream* errStrm) {
49 const int errCode = MPI_Pack_size(1, MPI_INT, comm, &curSize);
50 if (errCode != MPI_SUCCESS) {
51 if (errStrm != NULL) {
52 *errStrm <<
"countPackTripleMpi: MPI_Pack_size failed on "
53 <<
"MPI_INT call. MPI reports: "
54 << mpiErrorCodeToString(errCode) << endl;
63int packTriplesCountMpi(
const int numEnt,
68 std::ostream* errStrm) {
74 int theNumEnt = numEnt;
75 const int errCode = MPI_Pack(&theNumEnt, 1, MPI_INT, outBuf,
76 outBufSize, &outBufCurPos, comm);
77 if (errCode != MPI_SUCCESS) {
78 if (errStrm != NULL) {
79 *errStrm <<
"packTriplesCountMpi: MPI_Pack failed with outBufSize="
80 << outBufSize <<
" and outBufCurPos=" << outBufCurPos
81 <<
". MPI reports: " << mpiErrorCodeToString(errCode)
89int unpackTriplesCountMpi(
const char inBuf[],
94 std::ostream* errStrm) {
96 int errCode = MPI_SUCCESS;
102 errCode = MPI_Unpack(
const_cast<char*
>(inBuf), inBufSize, &inBufCurPos,
103 &theNumEnt, 1, MPI_INT, comm);
104 if (errCode != MPI_SUCCESS) {
105 if (errStrm != NULL) {
106 *errStrm <<
"unpackTriplesCountMpi: MPI_Unpack failed on gblRowInd: "
107 <<
"inBufSize=" << inBufSize
108 <<
", inBufCurPos=" << inBufCurPos
109 <<
". MPI reports: " << mpiErrorCodeToString(errCode)
115 if (errStrm != NULL) {
116 *errStrm <<
"unpackTriplesCountMpi: The unpacked number of entries "
117 << theNumEnt <<
" is negative." << endl;
128#ifdef HAVE_TPETRACORE_MPI
131 std::ostream* errStrm)
138#ifdef HAVE_TPETRACORE_MPI
139 using ::Tpetra::Details::extractMpiCommFromTeuchos;
145 *
errStrm <<
"countPackTriplesCount: Not implemented (no need; there's no "
146 "need to pack or unpack anything if there's only one process)."
154#ifdef HAVE_TPETRACORE_MPI
159 const ::Teuchos::Comm<int>& comm,
166 const ::Teuchos::Comm<int>& ,
170#ifdef HAVE_TPETRACORE_MPI
171 using ::Tpetra::Details::extractMpiCommFromTeuchos;
177 *
errStrm <<
"packTriplesCount: Not implemented (no need; there's no need "
178 "to pack or unpack anything if there's only one process)."
186#ifdef HAVE_TPETRACORE_MPI
191 const ::Teuchos::Comm<int>& comm,
198 const ::Teuchos::Comm<int>& ,
202#ifdef HAVE_TPETRACORE_MPI
203 using ::Tpetra::Details::extractMpiCommFromTeuchos;
213 *
errStrm <<
"unpackTriplesCount: Not implemented (no need; there's no need "
214 "to pack or unpack anything if there's only one process)."
Struct that holds views of the contents of a CrsMatrix.
Implementation details of Tpetra.
int packTriplesCount(const int, char[], const int, int &, const ::Teuchos::Comm< int > &, std::ostream *errStrm)
Pack the count (number) of matrix triples.
int countPackTriplesCount(const ::Teuchos::Comm< int > &, int &size, std::ostream *errStrm)
Compute the buffer size required by packTriples for packing the number of matrix entries ("triples").
int unpackTriplesCount(const char[], const int, int &, int &, const ::Teuchos::Comm< int > &, std::ostream *errStrm)
Unpack just the count of triples from the given input buffer.
Namespace Tpetra contains the class and methods constituting the Tpetra library.