10#include "Tpetra_Details_PackTriples.hpp"
12#ifdef HAVE_TPETRACORE_MPI
16 mpiErrorCodeToString (
const int errCode)
18 if (errCode == MPI_SUCCESS) {
22 char rawErrString[MPI_MAX_ERROR_STRING];
24 int err = MPI_Error_string (errCode, rawErrString, &len);
25 if (err != MPI_SUCCESS) {
29 if (MPI_MAX_ERROR_STRING > 0) {
30 rawErrString[0] =
'\0';
33 return std::string (rawErrString);
43#ifdef HAVE_TPETRACORE_MPI
46countPackTriplesCountMpi (MPI_Comm comm,
48 std::ostream* errStrm)
53 const int errCode = MPI_Pack_size (1, MPI_INT, comm, &curSize);
54 if (errCode != MPI_SUCCESS) {
55 if (errStrm != NULL) {
56 *errStrm <<
"countPackTripleMpi: MPI_Pack_size failed on "
57 <<
"MPI_INT call. MPI reports: "
58 << mpiErrorCodeToString (errCode) << endl;
68packTriplesCountMpi (
const int numEnt,
73 std::ostream* errStrm)
80 int theNumEnt = numEnt;
81 const int errCode = MPI_Pack (&theNumEnt, 1, MPI_INT, outBuf,
82 outBufSize, &outBufCurPos, comm);
83 if (errCode != MPI_SUCCESS) {
84 if (errStrm != NULL) {
85 *errStrm <<
"packTriplesCountMpi: MPI_Pack failed with outBufSize="
86 << outBufSize <<
" and outBufCurPos=" << outBufCurPos
87 <<
". MPI reports: " << mpiErrorCodeToString (errCode)
96unpackTriplesCountMpi (
const char inBuf[],
101 std::ostream* errStrm)
104 int errCode = MPI_SUCCESS;
110 errCode = MPI_Unpack (
const_cast<char*
> (inBuf), inBufSize, &inBufCurPos,
111 &theNumEnt, 1, MPI_INT, comm);
112 if (errCode != MPI_SUCCESS) {
113 if (errStrm != NULL) {
114 *errStrm <<
"unpackTriplesCountMpi: MPI_Unpack failed on gblRowInd: "
115 <<
"inBufSize=" << inBufSize
116 <<
", inBufCurPos=" << inBufCurPos
117 <<
". MPI reports: " << mpiErrorCodeToString (errCode)
123 if (errStrm != NULL) {
124 *errStrm <<
"unpackTriplesCountMpi: The unpacked number of entries "
125 << theNumEnt <<
" is negative." << endl;
136#ifdef HAVE_TPETRACORE_MPI
139 std::ostream* errStrm)
143 std::ostream* errStrm)
146#ifdef HAVE_TPETRACORE_MPI
147 using ::Tpetra::Details::extractMpiCommFromTeuchos;
148 MPI_Comm mpiComm = extractMpiCommFromTeuchos (comm);
149 return countPackTriplesCountMpi (mpiComm, size, errStrm);
152 if (errStrm != NULL) {
153 *errStrm <<
"countPackTriplesCount: Not implemented (no need; there's no "
154 "need to pack or unpack anything if there's only one process)." << endl;
161#ifdef HAVE_TPETRACORE_MPI
164 const int outBufSize,
166 const ::Teuchos::Comm<int>& comm,
167 std::ostream* errStrm)
173 const ::Teuchos::Comm<int>& ,
174 std::ostream* errStrm)
177#ifdef HAVE_TPETRACORE_MPI
178 using ::Tpetra::Details::extractMpiCommFromTeuchos;
179 MPI_Comm mpiComm = extractMpiCommFromTeuchos (comm);
180 return packTriplesCountMpi (numEnt, outBuf, outBufSize,
181 outBufCurPos, mpiComm, errStrm);
183 if (errStrm != NULL) {
184 *errStrm <<
"packTriplesCount: Not implemented (no need; there's no need "
185 "to pack or unpack anything if there's only one process)." << std::endl;
192#ifdef HAVE_TPETRACORE_MPI
197 const ::Teuchos::Comm<int>& comm,
198 std::ostream* errStrm)
204 const ::Teuchos::Comm<int>& ,
205 std::ostream* errStrm)
208#ifdef HAVE_TPETRACORE_MPI
209 using ::Tpetra::Details::extractMpiCommFromTeuchos;
211 MPI_Comm mpiComm = extractMpiCommFromTeuchos (comm);
213 unpackTriplesCountMpi (inBuf, inBufSize, inBufCurPos,
214 numEnt, mpiComm, errStrm);
218 if (errStrm != NULL) {
219 *errStrm <<
"unpackTriplesCount: Not implemented (no need; there's no need "
220 "to pack or unpack anything if there's only one process)." << std::endl;
Nonmember function that computes a residual Computes R = B - A * X.
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.