43 const UPstream::commsTypes commsType,
45 std::streamsize count,
46 const UPstream::dataTypes dataTypeId,
49 const int communicator,
50 UPstream::Request* req
63 if (count > std::streamsize(INT_MAX))
65 Perr<<
"[mpi_recv] from rank " << fromProcNo
66 <<
" exceeds INT_MAX values of "
76 Perr<<
"[mpi_recv] : starting recv from:" << fromProcNo
77 <<
" type:" << int(dataTypeId)
78 <<
" count:" << label(count)
87 Perr<<
"[mpi_recv] : starting recv from:" << fromProcNo
88 <<
" type:" << int(dataTypeId)
89 <<
" count:" << label(count)
95 int returnCode = MPI_ERR_UNKNOWN;
110 returnCode = MPI_Recv
127 <<
"[mpi_recv] : cannot receive message from:"
129 <<
" type:" << int(dataTypeId)
130 <<
" count:" << label(count) <<
" tag:" << tag
136 Perr<<
"[mpi_recv] : finished recv from:"
138 <<
" type:" << int(dataTypeId)
139 <<
" count:" << label(count) <<
" tag:" << tag
144 MPI_Count num_recv(0);
145 MPI_Get_elements_x(&status, datatype, &num_recv);
148 if (
FOAM_UNLIKELY(num_recv == MPI_UNDEFINED || int64_t(num_recv) < 0))
151 <<
"[mpi_recv] : receive from:" << fromProcNo
152 <<
" type:" << int(dataTypeId)
153 <<
" received count is undefined or negative value"
165 <<
"[mpi_recv] : receive from:" << fromProcNo
166 <<
" type:" << int(dataTypeId)
167 <<
" received count is larger than UList<T>::max_size()"
173 <<
"[mpi_recv] : receive from:" << fromProcNo
174 <<
" type:" << int(dataTypeId)
175 <<
" count:" << label(count)
176 <<
" buffer is too small for incoming message ("
177 << label(num_recv) <<
')'
181 return std::streamsize(num_recv);
188 returnCode = MPI_Irecv
203 <<
"[mpi_recv] : cannot start non-blocking receive from:"
205 <<
" type:" << int(dataTypeId)
206 <<
" count:" << label(count)
218 Perr<<
"[mpi_recv] : started non-blocking recv from:"
220 <<
" type:" << int(dataTypeId)
221 <<
" count:" << label(count) <<
" tag:" << tag
232 <<
"Unsupported communications type " << int(
commsType)
241void Foam::UIPstream::bufferIPCrecv()
246 Perr<<
"UIPstream IPC read buffer :"
247 <<
" from:" << fromProcNo_
248 <<
" tag:" << tag_ <<
" comm:" << comm_
249 <<
" wanted size:" << recvBuf_.capacity()
254 messageSize_ = recvBuf_.capacity();
266 messageSize_ = recvBuf_.size();
268 else if (!recvBuf_.capacity())
286 MPI_Count num_recv(0);
287 MPI_Get_elements_x(&status, MPI_BYTE, &num_recv);
290 if (
FOAM_UNLIKELY(num_recv == MPI_UNDEFINED || int64_t(num_recv) < 0))
293 <<
"UIPstream IPC read buffer from:" << fromProcNo_
294 <<
" received count is undefined or negative value"
303 <<
"UIPstream IPC read buffer from:" << fromProcNo_
304 <<
" received count is larger than UList<T>::max_size()"
310 Perr<<
"UIPstream::bufferIPCrecv : probed size:"
314 recvBuf_.resize(label(num_recv));
315 messageSize_ = label(num_recv);
334 <<
"UIPstream IPC read buffer from:" << fromProcNo_
335 <<
" with negative size?"
341 <<
"UIPstream IPC read buffer from:" << fromProcNo_
342 <<
" received size is larger than UList<T>::max_size()"
347 recvBuf_.resize(label(count));
348 messageSize_ = label(count);
350 if (recvBuf_.empty())
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static constexpr label max_size() noexcept
The size of the largest possible UList.
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
static std::streamsize mpi_receive(const UPstream::commsTypes commsType, void *buf, std::streamsize count, const UPstream::dataTypes dataTypeId, const int fromProcNo, const int tag, const int communicator, UPstream::Request *req=nullptr)
Receive buffer contents of specified data type from given processor.
commsTypes commsType() const noexcept
Get the communications type of the stream.
@ type_byte
byte, char, unsigned char, ...
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
static void beginTiming()
Update timer prior to measurement.
static void addGatherTime()
Add time increment to gather time.
static void addRequestTime()
Add time increment to request time.
static void addProbeTime()
Add time increment to probe time.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
DynamicList< MPI_Request > outstandingRequests_
Outstanding non-blocking operations.
DataTypeCountLookupTable dataTypesCount_
Fundamental count for each valid UPstream::dataTypes entry Indexed by UPstream::dataTypes enum.
std::string dataType_name(MPI_Datatype datatype)
Return MPI internal name for specified MPI_Datatype.
MPI_Datatype getDataType(UPstream::dataTypes id)
Lookup of dataTypes enumeration as an MPI_Datatype.
DynamicList< MPI_Comm > MPICommunicators_
void push_request(MPI_Request request, UPstream::Request *req=nullptr)
Transcribe MPI_Request to UPstream::Request (does not affect the stack of outstanding requests) or el...
void reset_request(UPstream::Request *req) noexcept
Reset UPstream::Request to MPI_REQUEST_NULL.
bool warnCommunicator(int comm) noexcept
True if warn communicator is active and not equal to given communicator.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FOAM_UNLIKELY(cond)