Loading...
Searching...
No Matches
UIPstreamBase Class Reference

Base class for input inter-processor communications stream (ie, parallel streams). Not to be used directly, thus contructors are protected. More...

#include <UIPstream.H>

Inheritance diagram for UIPstreamBase:
Collaboration diagram for UIPstreamBase:

Public Member Functions

virtual ~UIPstreamBase ()
 Destructor. Optionally clears external receive buffer.
virtual std::ios_base::fmtflags flags () const override
 Return current stream flags. Dummy for parallel stream, returns 0.
virtual std::ios_base::fmtflags flags (std::ios_base::fmtflags) override
 Set stream flags, return old stream flags. Dummy for parallel stream, returns 0.
label remaining () const noexcept
 The number of characters remaining in the get buffer.
virtual Istreamread (token &) override
 Return next token from stream.
virtual Istreamread (char &c) override
 Read a character.
virtual Istreamread (word &str) override
 Read a word.
virtual Istreamread (string &str) override
 Read a string (including enclosing double-quotes).
virtual Istreamread (int32_t &val) override
 Read int32_t.
virtual Istreamread (int64_t &val) override
 Read int64_t.
virtual Istreamread (uint32_t &val) override
 Read uint32_t.
virtual Istreamread (uint64_t &val) override
 Read uint64_t.
virtual Istreamread (float &val) override
 Read a float.
virtual Istreamread (double &val) override
 Read a double.
virtual Istreamread (char *data, std::streamsize count) override
 Read binary block with 8-byte alignment. Reading into a null pointer behaves like a forward seek of count characters.
virtual IstreamreadRaw (char *data, std::streamsize count) override
 Low-level raw binary read. Reading into a null pointer behaves like a forward seek of count characters.
virtual bool beginRawRead () override
 Start of low-level raw binary read.
virtual bool endRawRead () override
 End of low-level raw binary read.
virtual void rewind () override
 Rewind the receive stream position so that it may be read again.
void print (Ostream &os) const override
 Print stream description to Ostream.
Public Member Functions inherited from UPstream
 ClassName ("UPstream")
 Declare name of the class and its debug switch.
 UPstream (const commsTypes commsType) noexcept
 Construct for given communication type.
commsTypes commsType () const noexcept
 Get the communications type of the stream.
commsTypes commsType (const commsTypes ct) noexcept
 Set the communications type of the stream.
Public Member Functions inherited from Istream
 Istream (const Istream &)=default
 Copy construct.
virtual ~Istream ()=default
 Destructor.
 Istream (IOstreamOption streamOpt=IOstreamOption())
 Default construct (ASCII, uncompressed), construct with specified stream option.
 Istream (IOstreamOption::streamFormat fmt, IOstreamOption::compressionType cmp=IOstreamOption::UNCOMPRESSED)
 Construct with format (uncompressed).
const tokenpeekBack () const noexcept
 Examine putback token without removing it.
void putBackClear ()
 Drop the putback token.
void putBack (const token &tok)
 Put back a token (copy). Only a single put back is permitted.
void putBack (token &&tok)
 Put back a token (move). Only a single put back is permitted.
bool getBack (token &tok)
 Retrieve the put-back token if there is one.
bool readBegin (const char *funcName)
 Begin read of data chunk, starts with '('.
bool readEnd (const char *funcName)
 End read of data chunk, ends with ')'.
char readBeginList (const char *funcName)
 Begin read of list data, starts with '(' or '{'.
char readEndList (const char *funcName)
 End read of list data, ends with ')' or '}'.
Istreamoperator() () const
 Return a non-const reference to const Istream.
Public Member Functions inherited from IOstream
 IOstream (const IOstream &)=default
 Copy construct.
virtual ~IOstream ()=default
 Destructor.
 IOstream (IOstreamOption streamOpt=IOstreamOption())
 Default construct (ASCII, uncompressed), construct with specified stream option.
 IOstream (IOstreamOption::streamFormat fmt, IOstreamOption::versionNumber ver, IOstreamOption::compressionType cmp=IOstreamOption::UNCOMPRESSED)
 Construct with format, version (compression).
virtual const fileNamename () const
 The name of the stream.
fileName relativeName () const
 Return the name of the stream relative to the current case.
virtual bool check (const char *operation) const
 Check IOstream status for given operation.
bool fatalCheck (const char *operation) const
 Check IOstream status for given operation.
bool opened () const noexcept
 True if stream has been opened.
bool closed () const noexcept
 True if stream is closed.
bool good () const noexcept
 True if next operation might succeed.
bool eof () const noexcept
 True if end of input seen.
bool fail () const noexcept
 True if next operation will fail.
bool bad () const noexcept
 True if stream is corrupted.
 operator bool () const noexcept
 True if the stream has not failed.
bool operator! () const noexcept
 True if the stream has failed.
unsigned labelByteSize () const noexcept
 The sizeof (label) in bytes associated with the stream.
unsigned scalarByteSize () const noexcept
 The sizeof (scalar) in bytes associated with the stream.
void setLabelByteSize (unsigned nbytes) noexcept
 Set the sizeof (label) in bytes associated with the stream.
void setScalarByteSize (unsigned nbytes) noexcept
 Set the sizeof (scalar) in bytes associated with the stream.
template<class T, class = std::enable_if_t<std::is_integral_v<T>>>
bool checkLabelSize () const noexcept
 Test if the label byte-size associated with the stream is the same as the given type.
template<class T, class = std::enable_if_t<std::is_floating_point_v<T>>>
bool checkScalarSize () const noexcept
 Test if the scalar byte-size associated with the stream is the same as the given type.
bool checkNativeSizes () const noexcept
 Test if the label/scalar byte-size associated with the stream are the native label/scalar sizes.
bool fatalCheckNativeSizes (const char *operation) const
 Assert that the label/scalar byte-size associated with the stream are the native label/scalar sizes.
label lineNumber () const noexcept
 Const access to the current stream line number.
label & lineNumber () noexcept
 Non-const access to the current stream line number.
label lineNumber (const label num) noexcept
 Set the stream line number.
void setEof () noexcept
 Set stream state as reached 'eof'.
void setFail () noexcept
 Set stream state as 'failed'.
void setBad () noexcept
 Set stream state to be 'bad'.
std::ios_base::fmtflags setf (std::ios_base::fmtflags f)
 Set stream flag(s), return old stream flags.
std::ios_base::fmtflags setf (const std::ios_base::fmtflags f, const std::ios_base::fmtflags mask)
 Set stream flag(s) with mask, return old stream flags.
std::ios_base::fmtflags unsetf (std::ios_base::fmtflags f)
 Unset stream flags, return old stream flags.
void print (Ostream &os, const int streamState) const
 Print information about the stream state bits.
InfoProxy< IOstreaminfo () const noexcept
 Return info proxy, used to print IOstream information to a stream.
Public Member Functions inherited from IOstreamOption
constexpr IOstreamOption (streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
 Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression.
constexpr IOstreamOption (streamFormat fmt, compressionType comp, versionNumber ver) noexcept
 Construct from components (format, compression, version).
constexpr IOstreamOption (streamFormat fmt, versionNumber ver, compressionType comp=compressionType::UNCOMPRESSED) noexcept
 Construct from components (format, version, compression).
 IOstreamOption (const IOstreamOption &opt, streamFormat fmt) noexcept
 Copy construct with change of format.
streamFormat format () const noexcept
 Get the current stream format.
streamFormat format (const streamFormat fmt) noexcept
 Set the stream format.
streamFormat format (const word &formatName)
 Set the stream format from string value.
compressionType compression () const noexcept
 Get the stream compression.
compressionType compression (const compressionType comp) noexcept
 Set the stream compression.
compressionType compression (const word &compName)
 Set the stream compression from string value.
versionNumber version () const noexcept
 Get the stream version.
versionNumber version (const versionNumber ver) noexcept
 Set the stream version.
versionNumber version (const token &tok)
 Set the stream version from token.

Protected Member Functions

 UIPstreamBase (const UPstream::commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
 Construct given process index to read from using the given attached receive buffer, optional communication characteristics and IO format.
 UIPstreamBase (const int fromProcNo, PstreamBuffers &buffers)
 Construct given buffers.
 UIPstreamBase (const DynamicList< char > &receiveBuf, IOstreamOption::streamFormat fmt)
 Construct for an externally obtained buffer.
Protected Member Functions inherited from Istream
bool hasPutback () const noexcept
 True if putback token is in use.
Protected Member Functions inherited from IOstream
void setOpened () noexcept
 Set stream opened.
void setClosed () noexcept
 Set stream closed.
void setState (std::ios_base::iostate state) noexcept
 Set stream state.
void setGood () noexcept
 Set stream state to be good.

Protected Attributes

const int fromProcNo_
 Source rank for the data.
const int tag_
 Message tag for communication.
const int comm_
 The communicator index.
label messageSize_
 The message size, read on bufferIPCrecv or set directly.
label storedRecvBufPos_
 Receive position in buffer data, if ony If there is no external location for recvBufPos_.
const bool clearAtEnd_
 Clear the receive buffer on termination (in the destructor).
DynamicList< char > & recvBuf_
 Reference to the receive buffer data.
label & recvBufPos_
 Reference to the receive position in buffer data.
Protected Attributes inherited from IOstream
std::ios_base::iostate ioState_
 Mirror of internal stream io state.
streamAccess openClosed_
 The stream open/closed state.
unsigned char sizeofLabel_
 The sizeof (label), possibly read from the header.
unsigned char sizeofScalar_
 The sizeof (scalar), possibly read from the header.
label lineNumber_
 The file line.

Additional Inherited Members

Public Types inherited from UPstream
enum class  commsTypes : char { buffered , scheduled , nonBlocking , blocking = buffered }
 Communications types. More...
enum class  sendModes : char { normal , sync }
 Different MPI-send modes (ignored for commsTypes::buffered). More...
enum class  dataTypes : char {
  Basic_begin , type_byte = Basic_begin , type_int16 , type_int32 ,
  type_int64 , type_uint16 , type_uint32 , type_uint64 ,
  type_float , type_double , type_long_double , Basic_end ,
  User_begin = Basic_end , type_3float = User_begin , type_3double , type_6float ,
  type_6double , type_9float , type_9double , invalid ,
  User_end = invalid , DataTypes_end = invalid
}
 Mapping of some fundamental and aggregate types to MPI data types. More...
enum class  opCodes : char {
  Basic_begin , op_min = Basic_begin , op_max , op_sum ,
  op_prod , op_bool_and , op_bool_or , op_bool_xor ,
  op_bit_and , op_bit_or , op_bit_xor , Basic_end ,
  Extra_begin = Basic_end , op_replace = Extra_begin , op_no_op , invalid ,
  Extra_end = invalid , OpCodes_end = invalid
}
 Mapping of some MPI op codes. More...
enum class  topoControls : int {
  broadcast = 1 , reduce = 2 , gather = 4 , combine = 16 ,
  mapGather = 32 , gatherList = 64
}
 Some bit masks corresponding to topology controls. More...
typedef IntRange< int > rangeType
 Int ranges are used for MPI ranks (processes).
Public Types inherited from IOstream
enum  streamAccess : char { CLOSED = 0 , OPENED }
 Enumeration for stream open/closed state. More...
Public Types inherited from IOstreamOption
enum  streamFormat : char { ASCII = 0 , BINARY , COHERENT , UNKNOWN_FORMAT }
 Data format (ascii | binary | coherent). More...
enum  compressionType : char { UNCOMPRESSED = 0 , COMPRESSED }
 Compression treatment (UNCOMPRESSED | COMPRESSED). More...
enum  appendType : char {
  NO_APPEND = 0 , APPEND_APP , APPEND_ATE , NON_APPEND = NO_APPEND ,
  APPEND = APPEND_APP
}
 File appending (NO_APPEND | APPEND_APP | APPEND_ATE). More...
enum  atomicType : char { NON_ATOMIC = 0 , ATOMIC }
 Atomic operations (output). More...
enum class  floatFormat : unsigned { general = unsigned(0) , fixed = unsigned(std::ios_base::fixed) , scientific = unsigned(std::ios_base::scientific) }
 Float formats (eg, time directory name formats). More...
Static Public Member Functions inherited from UPstream
static bool usingTopoControl (UPstream::topoControls ctrl) noexcept
 Test for selection of given topology-aware routine.
static constexpr int commGlobal () noexcept
 Communicator for all ranks, irrespective of any local worlds.
static constexpr int commSelf () noexcept
 Communicator within the current rank only.
static int commConstWorld () noexcept
 Communicator for all ranks (respecting any local worlds).
static label commWorld () noexcept
 Communicator for all ranks (respecting any local worlds).
static label commWorld (const label communicator) noexcept
 Set world communicator. Negative values are a no-op.
static label commWarn (const label communicator) noexcept
 Alter communicator debugging setting. Warns for use of any communicator differing from specified. Negative values disable.
static label nComms () noexcept
 Number of currently defined communicators.
static void printCommTree (int communicator, bool linear=false)
 Debugging: print the communication tree.
static int commInterNode () noexcept
 Communicator between nodes/hosts (respects any local worlds).
static int commLocalNode () noexcept
 Communicator within the node/host (respects any local worlds).
static bool hasNodeCommunicators () noexcept
 Both inter-node and local-node communicators have been created.
static bool usingNodeComms (const int communicator)
 True if node topology-aware routines have been enabled, it is running in parallel, the starting point is the world-communicator and it is not an odd corner case (ie, all processes on one node, all processes on different nodes).
static label newCommunicator (const label parent, const labelRange &subRanks, const bool withComponents=true)
 Create new communicator with sub-ranks on the parent communicator.
static label newCommunicator (const label parent, const labelUList &subRanks, const bool withComponents=true)
 Create new communicator with sub-ranks on the parent communicator.
static label dupCommunicator (const label parent)
 Duplicate the parent communicator.
static label splitCommunicator (const label parent, const int colour, const bool two_step=true)
 Allocate a new communicator by splitting the parent communicator on the given colour.
static void freeCommunicator (const label communicator, const bool withComponents=true)
 Free a previously allocated communicator.
static int baseProcNo (label comm, int procID)
 Return physical processor number (i.e. processor number in worldComm) given communicator and processor.
static label procNo (const label comm, const int baseProcID)
 Return processor number in communicator (given physical processor number) (= reverse of baseProcNo).
static label procNo (const label comm, const label currentComm, const int currentProcID)
 Return processor number in communicator (given processor number and communicator).
static void addValidParOptions (HashTable< string > &validParOptions)
 Add the valid option this type of communications library adds/requires on the command line.
static bool init (int &argc, char **&argv, const bool needsThread)
 Initialisation function called from main.
static bool initNull ()
 Special purpose initialisation function.
static void barrier (const int communicator, UPstream::Request *req=nullptr)
 Impose a synchronisation barrier (optionally non-blocking).
static void send_done (const int toProcNo, const int communicator, const int tag=UPstream::msgType()+1970)
 Impose a point-to-point synchronisation barrier by sending a zero-byte "done" message to given rank.
static int wait_done (const int fromProcNo, const int communicator, const int tag=UPstream::msgType()+1970)
 Impose a point-to-point synchronisation barrier by receiving a zero-byte "done" message from given rank.
static std::pair< int, int64_t > probeMessage (const UPstream::commsTypes commsType, const int fromProcNo, const int tag=UPstream::msgType(), const int communicator=worldComm)
 Probe for an incoming message.
static void printNodeCommsControl (Ostream &os)
 Report the node-communication settings.
static void printTopoControl (Ostream &os)
 Report the topology routines settings.
static label nRequests () noexcept
 Number of outstanding requests (on the internal list of requests).
static void resetRequests (const label n)
 Truncate outstanding requests to given length, which is expected to be in the range [0 to nRequests()].
static void addRequest (UPstream::Request &req)
 Transfer the (wrapped) MPI request to the internal global list and invalidate the parameter (ignores null requests).
static void cancelRequest (const label i)
 Non-blocking comms: cancel and free outstanding request. Corresponds to MPI_Cancel() + MPI_Request_free().
static void cancelRequest (UPstream::Request &req)
 Non-blocking comms: cancel and free outstanding request. Corresponds to MPI_Cancel() + MPI_Request_free().
static void cancelRequests (UList< UPstream::Request > &requests)
 Non-blocking comms: cancel and free outstanding requests. Corresponds to MPI_Cancel() + MPI_Request_free().
static void removeRequests (label pos, label len=-1)
 Non-blocking comms: cancel/free outstanding requests (from position onwards) and remove from internal list of requests. Corresponds to MPI_Cancel() + MPI_Request_free().
static void freeRequest (UPstream::Request &req)
 Non-blocking comms: free outstanding request. Corresponds to MPI_Request_free().
static void freeRequests (UList< UPstream::Request > &requests)
 Non-blocking comms: free outstanding requests. Corresponds to MPI_Request_free().
static void waitRequests (label pos, label len=-1)
 Wait until all requests (from position onwards) have finished. Corresponds to MPI_Waitall().
static void waitRequests (UList< UPstream::Request > &requests)
 Wait until all requests have finished. Corresponds to MPI_Waitall().
static bool waitAnyRequest (label pos, label len=-1)
 Wait until any request (from position onwards) has finished. Corresponds to MPI_Waitany().
static bool waitSomeRequests (label pos, label len=-1, DynamicList< int > *indices=nullptr)
 Wait until some requests (from position onwards) have finished. Corresponds to MPI_Waitsome().
static bool waitSomeRequests (UList< UPstream::Request > &requests, DynamicList< int > *indices=nullptr)
 Wait until some requests have finished. Corresponds to MPI_Waitsome().
static int waitAnyRequest (UList< UPstream::Request > &requests)
 Wait until any request has finished and return its index. Corresponds to MPI_Waitany().
static void waitRequest (const label i)
 Wait until request i has finished. Corresponds to MPI_Wait().
static void waitRequest (UPstream::Request &req)
 Wait until specified request has finished. Corresponds to MPI_Wait().
static bool activeRequest (const label i)
 Is request i active (!= MPI_REQUEST_NULL)?
static bool activeRequest (const UPstream::Request &req)
 Is request active (!= MPI_REQUEST_NULL)?
static bool finishedRequest (const label i)
 Non-blocking comms: has request i finished? Corresponds to MPI_Test().
static bool finishedRequest (UPstream::Request &req)
 Non-blocking comms: has request finished? Corresponds to MPI_Test().
static bool finishedRequests (label pos, label len=-1)
 Non-blocking comms: have all requests (from position onwards) finished? Corresponds to MPI_Testall().
static bool finishedRequests (UList< UPstream::Request > &requests)
 Non-blocking comms: have all requests finished? Corresponds to MPI_Testall().
static bool finishedRequestPair (label &req0, label &req1)
 Non-blocking comms: have both requests finished? Corresponds to pair of MPI_Test().
static void waitRequestPair (label &req0, label &req1)
 Non-blocking comms: wait for both requests to finish. Corresponds to pair of MPI_Wait().
static bool parRun (const bool on) noexcept
 Set as parallel run on/off.
static bool & parRun () noexcept
 Test if this a parallel run.
static bool haveThreads () noexcept
 Have support for threads.
static constexpr int masterNo () noexcept
 Relative rank for the master process - is always 0.
static label nProcs (const label communicator=worldComm)
 Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static int myProcNo (const label communicator=worldComm)
 Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a rank in the communicator.
static bool master (const label communicator=worldComm)
 True if process corresponds to the master rank in the communicator.
static bool is_rank (const label communicator=worldComm)
 True if process corresponds to any rank (master or sub-rank) in the given communicator.
static bool is_subrank (const label communicator=worldComm)
 True if process corresponds to a sub-rank in the given communicator.
static bool is_parallel (const label communicator=worldComm)
 True if parallel algorithm or exchange is required.
static int numNodes () noexcept
 The number of shared/host nodes in the (const) world communicator.
static label parent (int communicator)
 The parent communicator.
static List< int > & procID (int communicator)
 The list of ranks within a given communicator.
static bool sameProcs (int communicator1, int communicator2)
 Test for communicator equality.
template<typename T1, typename = std::void_t <std::enable_if_t<std::is_integral_v<T1>>>>
static bool sameProcs (int communicator, const UList< T1 > &procs)
 Test equality of communicator procs with the given list of ranks. Includes a guard for the communicator index.
template<typename T1, typename T2, typename = std::void_t < std::enable_if_t<std::is_integral_v<T1>>, std::enable_if_t<std::is_integral_v<T2>> >>
static bool sameProcs (const UList< T1 > &procs1, const UList< T2 > &procs2)
 Test the equality of two lists of ranks.
static const wordListallWorlds () noexcept
 All worlds.
static const labelListworldIDs () noexcept
 The indices into allWorlds for all processes.
static label myWorldID ()
 My worldID.
static const wordmyWorld ()
 My world.
static rangeType allProcs (const label communicator=worldComm)
 Range of process indices for all processes.
static rangeType subProcs (const label communicator=worldComm)
 Range of process indices for sub-processes.
static const List< int > & interNode_offsets ()
 Processor offsets corresponding to the inter-node communicator.
static const rangeTypelocalNode_parentProcs ()
 The range (start/size) of the commLocalNode ranks in terms of the (const) world communicator processors.
static const commsStructListlinearCommunication (int communicator)
 Linear communication schedule (special case) for given communicator.
static const commsStructListtreeCommunication (int communicator)
 Tree communication schedule (standard case) for given communicator.
static const commsStructListwhichCommunication (const int communicator, bool linear=false)
 Communication schedule for all-to-master (proc 0) as linear/tree/none with switching based on UPstream::nProcsSimpleSum, the is_parallel() state and the optional linear parameter.
static int & msgType () noexcept
 Message tag of standard messages.
static int msgType (int val) noexcept
 Set the message tag for standard messages.
static int incrMsgType (int val=1) noexcept
 Increment the message tag for standard messages.
static void shutdown (int errNo=0)
 Shutdown (finalize) MPI as required.
static void abort (int errNo=1)
 Call MPI_Abort with no other checks or cleanup.
static void exit (int errNo=1)
 Shutdown (finalize) MPI as required and exit program with errNo.
static void allToAll (const UList< int32_t > &sendData, UList< int32_t > &recvData, const int communicator=UPstream::worldComm)
 Exchange int32_t data with all ranks in communicator.
static void allToAllConsensus (const UList< int32_t > &sendData, UList< int32_t > &recvData, const int tag, const int communicator=UPstream::worldComm)
 Exchange non-zero int32_t data between ranks [NBX].
static void allToAllConsensus (const Map< int32_t > &sendData, Map< int32_t > &recvData, const int tag, const int communicator=UPstream::worldComm)
 Exchange int32_t data between ranks [NBX].
static Map< int32_t > allToAllConsensus (const Map< int32_t > &sendData, const int tag, const int communicator=UPstream::worldComm)
 Exchange int32_t data between ranks [NBX].
static void allToAll (const UList< int64_t > &sendData, UList< int64_t > &recvData, const int communicator=UPstream::worldComm)
 Exchange int64_t data with all ranks in communicator.
static void allToAllConsensus (const UList< int64_t > &sendData, UList< int64_t > &recvData, const int tag, const int communicator=UPstream::worldComm)
 Exchange non-zero int64_t data between ranks [NBX].
static void allToAllConsensus (const Map< int64_t > &sendData, Map< int64_t > &recvData, const int tag, const int communicator=UPstream::worldComm)
 Exchange int64_t data between ranks [NBX].
static Map< int64_t > allToAllConsensus (const Map< int64_t > &sendData, const int tag, const int communicator=UPstream::worldComm)
 Exchange int64_t data between ranks [NBX].
template<class Type>
static void mpiGather (const Type *sendData, Type *recvData, int count, const int communicator=UPstream::worldComm)
 Receive identically-sized (contiguous) data from all ranks.
template<class Type>
static void mpiScatter (const Type *sendData, Type *recvData, int count, const int communicator=UPstream::worldComm)
 Send identically-sized (contiguous) data to all ranks.
template<class Type>
static void mpiAllGather (Type *allData, int count, const int communicator=UPstream::worldComm)
 Gather/scatter identically-sized data.
template<class Type>
static void mpiGatherv (const Type *sendData, int sendCount, Type *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, const int communicator=UPstream::worldComm)
 Receive variable length data from all ranks.
template<class Type>
static void mpiScatterv (const Type *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, Type *recvData, int recvCount, const int communicator=UPstream::worldComm)
 Send variable length data to all ranks.
template<class T>
static List< TallGatherValues (const T &localValue, const int communicator=UPstream::worldComm)
 Allgather individual values into list locations.
template<class T>
static List< TlistGatherValues (const T &localValue, const int communicator=UPstream::worldComm)
 Gather individual values into list locations.
template<class T>
static T listScatterValues (const UList< T > &allValues, const int communicator=UPstream::worldComm)
 Scatter individual values from list locations.
template<class Type>
static bool broadcast (Type *buffer, std::streamsize count, const int communicator, const int root=UPstream::masterNo())
 Broadcast buffer contents (contiguous types) to all ranks (default: from rank=0). The sizes must match on all processes.
template<class Type, unsigned N>
static bool broadcast (FixedList< Type, N > &list, const int communicator, const int root=UPstream::masterNo())
 Broadcast fixed-list content (contiguous types) to all ranks (default: from rank=0). The sizes must match on all processes.
template<class T>
static void mpiReduce (T values[], int count, const UPstream::opCodes opCodeId, const int communicator)
 MPI_Reduce (blocking) for known operators.
template<UPstream::opCodes opCode, class T>
static void mpiReduce (T values[], int count, const int communicator)
 MPI_Reduce (blocking) for known operators.
template<class T>
static void mpiAllReduce (T values[], int count, const UPstream::opCodes opCodeId, const int communicator)
 MPI_Allreduce (blocking) for known operators.
template<UPstream::opCodes opCode, class T>
static void mpiAllReduce (T values[], int count, const int communicator)
 MPI_Allreduce (blocking) for known operators.
template<class T>
static void mpiAllReduce (T values[], int count, const UPstream::opCodes opCodeId, const int communicator, UPstream::Request &req)
 MPI_Iallreduce (non-blocking) for known operators.
template<UPstream::opCodes opCode, class T>
static void mpiAllReduce (T values[], int count, const int communicator, UPstream::Request &req)
 MPI_Iallreduce (non-blocking) for known operators.
template<Foam::UPstream::opCodes opCode, class T>
static void mpiScan (T values[], int count, const int communicator, const bool exclusive=false)
 Inclusive/exclusive scan (in-place).
template<Foam::UPstream::opCodes opCode, class T>
static T mpiScan (const T &localValue, const int communicator, const bool exclusive=false)
 Inclusive/exclusive scan returning the result. In exclusive mode, the degenerate value on rank=0 has no meaning but is treated like non-exclusive mode (ie, original values).
template<class T>
static void mpiScan_min (T values[], int count, const int communicator, const bool exclusive=false)
 Inclusive/exclusive min scan (in-place).
template<class T>
static void mpiExscan_min (T values[], int count, const int communicator)
 Exclusive min scan (in-place).
template<class T>
static T mpiScan_min (const T &value, const int communicator, const bool exclusive=false)
 Inclusive/exclusive min scan returning result.
template<class T>
static T mpiExscan_min (const T &value, const int communicator)
 Exclusive min scan returning result.
template<class T>
static void mpiScan_max (T values[], int count, const int communicator, const bool exclusive=false)
 Inclusive/exclusive max scan (in-place).
template<class T>
static void mpiExscan_max (T values[], int count, const int communicator)
 Exclusive max scan (in-place).
template<class T>
static T mpiScan_max (const T &value, const int communicator, const bool exclusive=false)
 Inclusive/exclusive max scan returning result.
template<class T>
static T mpiExscan_max (const T &value, const int communicator)
 Exclusive max scan returning result.
template<class T>
static void mpiScan_sum (T values[], int count, const int communicator, const bool exclusive=false)
 Inclusive/exclusive sum scan (in-place).
template<class T>
static void mpiExscan_sum (T values[], int count, const int communicator)
 Exclusive sum scan (in-place).
template<class T>
static T mpiScan_sum (const T &value, const int communicator, const bool exclusive=false)
 Inclusive/exclusive sum scan returning result.
template<class T>
static T mpiExscan_sum (const T &value, const int communicator)
 Exclusive sum scan returning result.
static void reduceAnd (bool &value, const int communicator=worldComm)
 Logical (and) reduction (MPI_AllReduce).
static void reduceOr (bool &value, const int communicator=worldComm)
 Logical (or) reduction (MPI_AllReduce).
static int find_first (bool condition, int communicator)
 Locate the first rank for which the condition is true, or -1 if no ranks satisfy the condition.
static int find_last (bool condition, int communicator)
 Locate the last rank for which the condition is true, or -1 if no ranks satisfy the condition.
static label allocateCommunicator (const label parent, const labelRange &subRanks, const bool withComponents=true)
static label allocateCommunicator (const label parent, const labelUList &subRanks, const bool withComponents=true)
static label commInterHost () noexcept
 Communicator between nodes (respects any local worlds).
static label commIntraHost () noexcept
 Communicator within the node (respects any local worlds).
static void waitRequests ()
 Wait for all requests to finish.
template<class Type>
static void gather (const Type *send, int count, Type *recv, const UList< int > &counts, const UList< int > &offsets, const int comm=UPstream::worldComm)
template<class Type>
static void scatter (const Type *send, const UList< int > &counts, const UList< int > &offsets, Type *recv, int count, const int comm=UPstream::worldComm)
Static Public Member Functions inherited from IOstream
static unsigned int defaultPrecision () noexcept
 Return the default precision.
static unsigned int defaultPrecision (unsigned int prec) noexcept
 Reset the default precision.
static unsigned int minPrecision (unsigned int prec) noexcept
 Set the minimum default precision.
Static Public Member Functions inherited from IOstreamOption
static floatFormat floatFormatEnum (const word &fmtName, const floatFormat deflt=floatFormat::general)
 Lookup floatFormat enum corresponding to the string (general | fixed | scientific).
static floatFormat floatFormatEnum (const word &key, const dictionary &dict, const floatFormat deflt=floatFormat::general)
 getOrDefault floatFormat from dictionary, warn only on bad enumeration.
static streamFormat formatEnum (const word &fmtName, const streamFormat deflt=streamFormat::ASCII)
 Lookup streamFormat enum corresponding to the string (ascii | binary).
static streamFormat formatEnum (const word &key, const dictionary &dict, const streamFormat deflt=streamFormat::ASCII)
 getOrDefault streamFormat from dictionary, warn only on bad enumeration.
static compressionType compressionEnum (const word &compName, const compressionType deflt=compressionType::UNCOMPRESSED)
 The compression enum corresponding to the string.
static compressionType compressionEnum (const word &key, const dictionary &dict, const compressionType deflt=compressionType::UNCOMPRESSED)
 getOrDefault compressionType from dictionary, warn only on bad enumeration.
Static Public Attributes inherited from UPstream
static const Enum< commsTypescommsTypeNames
 Enumerated names for the communication types.
static int nodeCommsControl_
 Use of host/node topology-aware routines.
static int nodeCommsMin_
 Minimum number of nodes before topology-aware routines are enabled.
static int topologyControl_
 Selection of topology-aware routines as a bitmask combination of the topoControls enumerations.
static bool floatTransfer
 Should compact transfer be used in which floats replace doubles reducing the bandwidth requirement at the expense of some loss in accuracy.
static int nProcsSimpleSum
 Number of processors to change from linear to tree communication.
static int nProcsNonblockingExchange
 Number of processors to change to nonBlocking consensual exchange (NBX). Ignored for zero or negative values.
static int nPollProcInterfaces
 Number of polling cycles in processor updates.
static commsTypes defaultCommsType
 Default commsType.
static int maxCommsSize
 Optional maximum message size (bytes).
static int tuning_NBX_
 Tuning parameters for non-blocking exchange (NBX).
static const int mpiBufferSize
 MPI buffer-size (bytes).
static label worldComm
 Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static label warnComm
 Debugging: warn for use of any communicator differing from warnComm.
Static Public Attributes inherited from IOstream
static unsigned int precision_
 Default precision.
Static Public Attributes inherited from IOstreamOption
static const Enum< floatFormatfloatFormatNames
 Names for float formats (general, fixed, scientific).
static const Enum< streamFormatformatNames
 Stream format names (ascii, binary).
static const versionNumber currentVersion
 The current version number (2.0).
Static Protected Member Functions inherited from UPstream
static bool mpi_broadcast (void *buf, std::streamsize count, const UPstream::dataTypes dataTypeId, const int communicator, const int root=0)
 Broadcast buffer contents to all ranks (default: from rank=0). The sizes must match on all processes.
static void mpi_reduce (void *values, int count, const UPstream::dataTypes dataTypeId, const UPstream::opCodes opCodeId, const int communicator, UPstream::Request *req=nullptr)
 In-place reduction of values with result on rank 0.
static void mpi_allreduce (void *values, int count, const UPstream::dataTypes dataTypeId, const UPstream::opCodes opCodeId, const int communicator, UPstream::Request *req=nullptr)
 In-place reduction of values with same result on all ranks.
static void mpi_scan_reduce (void *values, int count, const UPstream::dataTypes dataTypeId, const UPstream::opCodes opCodeId, const int communicator, const bool exclusive)
 In-place scan/exscan reduction of values.
static bool mpi_send (const UPstream::commsTypes commsType, const void *buf, std::streamsize count, const UPstream::dataTypes dataTypeId, const int toProcNo, const int tag, const int communicator, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
 Send buffer contents of specified data type to given processor.
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.
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.
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 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 poorly).
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 Protected Attributes inherited from IOstream
static fileName staticName_
 Name for any generic stream - normally treat as readonly.

Detailed Description

Base class for input inter-processor communications stream (ie, parallel streams). Not to be used directly, thus contructors are protected.

Source files

Definition at line 55 of file UIPstream.H.

Constructor & Destructor Documentation

◆ UIPstreamBase() [1/3]

UIPstreamBase ( const UPstream::commsTypes commsType,
const int fromProcNo,
DynamicList< char > & receiveBuf,
label & receiveBufPosition,
const int tag = UPstream::msgType(),
const int communicator = UPstream::worldComm,
const bool clearAtEnd = false,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY )
protected

Construct given process index to read from using the given attached receive buffer, optional communication characteristics and IO format.

Definition at line 156 of file UIPstreamBase.C.

References clearAtEnd_, comm_, UPstream::commsType(), fromProcNo_, Istream::Istream(), messageSize_, recvBuf_, recvBufPos_, IOstream::setGood(), IOstream::setOpened(), storedRecvBufPos_, tag_, and UPstream::UPstream().

Referenced by UIPBstream::UIPBstream(), UIPstream::UIPstream(), UIPstream::UIPstream(), and UIPstream::UIPstream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UIPstreamBase() [2/3]

UIPstreamBase ( const int fromProcNo,
PstreamBuffers & buffers )
protected

◆ UIPstreamBase() [3/3]

UIPstreamBase ( const DynamicList< char > & receiveBuf,
IOstreamOption::streamFormat fmt )
protected

Construct for an externally obtained buffer.

The parameter is allowed to be const (since reading will not affect it), but must reference a concrete variable.

Definition at line 219 of file UIPstreamBase.C.

◆ ~UIPstreamBase()

~UIPstreamBase ( )
virtual

Destructor. Optionally clears external receive buffer.

Definition at line 247 of file UIPstreamBase.C.

Member Function Documentation

◆ flags() [1/2]

virtual std::ios_base::fmtflags flags ( ) const
inlineoverridevirtual

Return current stream flags. Dummy for parallel stream, returns 0.

Implements IOstream.

Definition at line 190 of file UIPstream.H.

◆ flags() [2/2]

virtual std::ios_base::fmtflags flags ( std::ios_base::fmtflags )
inlineoverridevirtual

Set stream flags, return old stream flags. Dummy for parallel stream, returns 0.

Implements IOstream.

Definition at line 199 of file UIPstream.H.

◆ remaining()

Foam::label remaining ( ) const
noexcept

The number of characters remaining in the get buffer.

//- The current get position (tellg) in the buffer label pos() const;

Foam::label Foam::UIPstreamBase::pos() const { return recvBufPos_; }

Definition at line 600 of file UIPstreamBase.C.

References messageSize_, Foam::noexcept, recvBuf_, and recvBufPos_.

◆ read() [1/11]

◆ read() [2/11]

Foam::Istream & read ( char & c)
overridevirtual

Read a character.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 483 of file UIPstreamBase.C.

References recvBuf_, and recvBufPos_.

◆ read() [3/11]

Foam::Istream & read ( word & str)
overridevirtual

Read a word.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 492 of file UIPstreamBase.C.

◆ read() [4/11]

Foam::Istream & read ( string & )
overridevirtual

Read a string (including enclosing double-quotes).

Implements Istream.

Reimplemented in UIPstream.

Definition at line 498 of file UIPstreamBase.C.

◆ read() [5/11]

Foam::Istream & read ( int32_t & val)
overridevirtual

Read int32_t.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 504 of file UIPstreamBase.C.

◆ read() [6/11]

Foam::Istream & read ( int64_t & val)
overridevirtual

Read int64_t.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 511 of file UIPstreamBase.C.

◆ read() [7/11]

Foam::Istream & read ( uint32_t & val)
overridevirtual

Read uint32_t.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 518 of file UIPstreamBase.C.

◆ read() [8/11]

Foam::Istream & read ( uint64_t & val)
overridevirtual

Read uint64_t.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 525 of file UIPstreamBase.C.

◆ read() [9/11]

Foam::Istream & read ( float & val)
overridevirtual

Read a float.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 532 of file UIPstreamBase.C.

◆ read() [10/11]

Foam::Istream & read ( double & val)
overridevirtual

Read a double.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 539 of file UIPstreamBase.C.

◆ read() [11/11]

Foam::Istream & read ( char * data,
std::streamsize count )
overridevirtual

Read binary block with 8-byte alignment. Reading into a null pointer behaves like a forward seek of count characters.

Implements Istream.

Reimplemented in UIPstream.

Definition at line 546 of file UIPstreamBase.C.

References beginRawRead(), endRawRead(), and readRaw().

Here is the call graph for this function:

◆ readRaw()

Foam::Istream & readRaw ( char * data,
std::streamsize count )
overridevirtual

Low-level raw binary read. Reading into a null pointer behaves like a forward seek of count characters.

Implements Istream.

Definition at line 561 of file UIPstreamBase.C.

Referenced by read().

Here is the caller graph for this function:

◆ beginRawRead()

bool beginRawRead ( )
overridevirtual

Start of low-level raw binary read.

Implements Istream.

Definition at line 572 of file UIPstreamBase.C.

References Foam::abort(), IOstreamOption::BINARY, Foam::FatalError, FatalErrorInFunction, and format().

Referenced by read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endRawRead()

virtual bool endRawRead ( )
inlineoverridevirtual

End of low-level raw binary read.

Implements Istream.

Definition at line 282 of file UIPstream.H.

References endRawRead().

Referenced by endRawRead(), and read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rewind()

void rewind ( )
overridevirtual

Rewind the receive stream position so that it may be read again.

Implements Istream.

Definition at line 613 of file UIPstreamBase.C.

References messageSize_, recvBuf_, recvBufPos_, Istream::rewind(), IOstream::setEof(), IOstream::setGood(), and IOstream::setOpened().

Here is the call graph for this function:

◆ print()

void print ( Ostream & os) const
overridevirtual

Print stream description to Ostream.

Reimplemented from IOstream.

Definition at line 627 of file UIPstreamBase.C.

References comm_, Foam::endl(), fromProcNo_, os(), and tag_.

Here is the call graph for this function:

Member Data Documentation

◆ fromProcNo_

const int fromProcNo_
protected

Source rank for the data.

Definition at line 99 of file UIPstream.H.

Referenced by print(), UIPstream::read(), UIPstream::read(), UIPstream::UIPstream(), UIPstreamBase(), and UIPstreamBase().

◆ tag_

const int tag_
protected

Message tag for communication.

Definition at line 104 of file UIPstream.H.

Referenced by print(), UIPstream::read(), UIPstream::read(), UIPstream::UIPstream(), UIPstreamBase(), and UIPstreamBase().

◆ comm_

const int comm_
protected

The communicator index.

Definition at line 109 of file UIPstream.H.

Referenced by print(), UIPstream::read(), UIPstream::UIPstream(), UIPstreamBase(), and UIPstreamBase().

◆ messageSize_

label messageSize_
protected

The message size, read on bufferIPCrecv or set directly.

Definition at line 114 of file UIPstream.H.

Referenced by UIPstream::read(), UIPstream::read(), remaining(), rewind(), UIPstream::UIPstream(), UIPstreamBase(), and UIPstreamBase().

◆ storedRecvBufPos_

label storedRecvBufPos_
protected

Receive position in buffer data, if ony If there is no external location for recvBufPos_.

Definition at line 120 of file UIPstream.H.

Referenced by IPBstream::IPBstream(), IPstream::IPstream(), UIPstream::read(), UIPstream::read(), UIPstreamBase(), and UIPstreamBase().

◆ clearAtEnd_

const bool clearAtEnd_
protected

Clear the receive buffer on termination (in the destructor).

Definition at line 125 of file UIPstream.H.

Referenced by UIPstream::read(), UIPstream::read(), UIPstreamBase(), and UIPstreamBase().

◆ recvBuf_

DynamicList<char>& recvBuf_
protected

Reference to the receive buffer data.

Definition at line 130 of file UIPstream.H.

Referenced by UIPstream::read(), UIPstream::read(), read(), remaining(), rewind(), UIPstream::UIPstream(), UIPstreamBase(), and UIPstreamBase().

◆ recvBufPos_

label& recvBufPos_
protected

Reference to the receive position in buffer data.

Definition at line 135 of file UIPstream.H.

Referenced by UIPstream::read(), read(), remaining(), rewind(), UIPstreamBase(), and UIPstreamBase().


The documentation for this class was generated from the following files: