36#define STRINGIFY(content) #content
37#define STRING_QUOTE(input) STRINGIFY(input)
59inline void printErrorNonIntrinsic
68 <<
"Bad input for " << context <<
": likely a programming problem\n"
69 <<
" Non-intrinsic/non-user data (type:" << int(dataTypeId) <<
")\n"
85 const int communicator,
93 Perr<<
"[mpi_gather] :";
99 && (!sendData || (sendData == recvData))
105 Perr<<
" type:" << int(dataTypeId) <<
" count:" <<
count
130 const void* sendData,
135 const int communicator,
143 Perr<<
"[mpi_scatter] :";
149 && (!recvData || (sendData == recvData))
155 Perr<<
" type:" << int(dataTypeId) <<
" count:" <<
count
156 <<
" comm:" << communicator
184 const int communicator,
192 Perr<<
"[mpi_allgather] :"
193 <<
" type:" << int(dataTypeId) <<
" count:" <<
count
194 <<
" comm:" << communicator
217 const void* sendData,
224 const int communicator
233 printErrorNonIntrinsic(
"MPI_Gatherv()", dataTypeId);
241 const int totalSize =
244 ? (recvOffsets[np-1] + recvCounts[np-1])
250 Perr<<
"[mpi_gatherv] :"
251 <<
" type:" << int(dataTypeId)
252 <<
" count:" << sendCount
253 <<
" total:" << totalSize
254 <<
" comm:" << communicator
264 recvData, recvCounts, recvOffsets,
265 datatype, communicator
279 #define dataPrinter(enumType, nativeType) \
280 case UPstream::dataTypes::enumType : \
282 UList<nativeType> combined \
284 static_cast<nativeType*>(recvData), \
288 Info<< "[mpi_gatherv] => " \
289 "List<" STRING_QUOTE(nativeType) "> "; \
290 combined.writeList(Info) << Foam::endl; \
296 dataPrinter(type_int32, int32_t);
297 dataPrinter(type_int64, int64_t);
298 dataPrinter(type_float,
float);
299 dataPrinter(type_double,
double);
317 const void* sendData,
325 const int communicator
334 printErrorNonIntrinsic(
"MPI_Scatterv()", dataTypeId);
341 sendData, sendCounts, sendOffsets,
343 datatype, communicator
Functions to wrap MPI_Bcast, MPI_Allreduce, MPI_Iallreduce etc.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An opaque wrapper for MPI_Request with a vendor-independent representation without any <mpi....
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
static void mpi_scatter(const void *sendData, void *recvData, int count, const UPstream::dataTypes dataTypeId, const int communicator, UPstream::Request *req=nullptr)
Send identically-sized (contiguous) data from rank 0 to all other ranks.
static void mpi_allgather(void *allData, int count, const UPstream::dataTypes dataTypeId, const int communicator, UPstream::Request *req=nullptr)
Gather/scatter identically-sized data.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static void mpi_scatterv(const void *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, void *recvData, int recvCount, const UPstream::dataTypes dataTypeId, const int communicator)
Send variable length data from rank 0 to all ranks. (caution: known to scale poorly).
static void mpi_gather(const void *sendData, void *recvData, int count, const UPstream::dataTypes dataTypeId, const int communicator, UPstream::Request *req=nullptr)
Receive identically-sized (contiguous) data from all ranks, placing the result on rank 0.
dataTypes
Mapping of some fundamental and aggregate types to MPI data types.
@ Basic_end
(internal use) end marker [basic types]
@ User_begin
(internal use) begin marker [user types]
@ User_end
(internal use) end marker [user types]
@ Basic_begin
(internal use) begin marker [basic/all types]
static void mpi_gatherv(const void *sendData, int sendCount, void *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, const UPstream::dataTypes dataTypeId, const int communicator)
Receive variable length data from all ranks, placing the result on rank 0. (caution: known to scale p...
#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.
void scatterv(const Type *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, Type *recvData, int recvCount, MPI_Datatype datatype, const int communicator, UPstream::Request *req=nullptr)
void gather(const Type *sendData, Type *recvData, int count, MPI_Datatype datatype, const int communicator, UPstream::Request *req=nullptr)
void scatter(const Type *sendData, Type *recvData, int count, MPI_Datatype datatype, const int communicator, UPstream::Request *req=nullptr)
void gatherv(const Type *sendData, int sendCount, Type *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, MPI_Datatype datatype, const int communicator, UPstream::Request *req=nullptr)
void allGather(Type *allData, int count, MPI_Datatype datatype, const int communicator, UPstream::Request *req=nullptr)
MPI_Datatype getDataType(UPstream::dataTypes id)
Lookup of dataTypes enumeration as an MPI_Datatype.
Vector< float > floatVector
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Vector< double > doubleVector
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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)