Pstream Class Reference

Inter-processor communications stream. More...

Inheritance diagram for Pstream:
Collaboration diagram for Pstream:

Public Member Functions

 ClassName ("Pstream")
 
 Pstream (const commsTypes commsType, const label bufSize=0)
 Construct given optional buffer size. More...
 
- Public Member Functions inherited from UPstream
 ClassName ("UPstream")
 
 UPstream (const commsTypes commsType)
 Construct given optional buffer size. More...
 
commsTypes commsType () const
 Get the communications type of the stream. More...
 
commsTypes commsType (const commsTypes ct)
 Set the communications type of the stream. More...
 

Static Public Member Functions

template<class T , class BinaryOp >
static void gather (const List< commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
 Gather data. Apply bop to combine Value. More...
 
template<class T , class BinaryOp >
static void gather (T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void scatter (const List< commsStruct > &comms, T &Value, const int tag, const label comm)
 Scatter data. Distribute without modification. Reverse of gather. More...
 
template<class T >
static void scatter (T &Value, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T , class CombineOp >
static void combineGather (const List< commsStruct > &comms, T &Value, const CombineOp &cop, const int tag, const label comm)
 
template<class T , class CombineOp >
static void combineGather (T &Value, const CombineOp &cop, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void combineScatter (const List< commsStruct > &comms, T &Value, const int tag, const label comm)
 Scatter data. Reverse of combineGather. More...
 
template<class T >
static void combineScatter (T &Value, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T , class CombineOp >
static void listCombineGather (const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
 
template<class T , class CombineOp >
static void listCombineGather (List< T > &Value, const CombineOp &cop, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void listCombineScatter (const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
 Scatter data. Reverse of combineGather. More...
 
template<class T >
static void listCombineScatter (List< T > &Value, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class Container , class CombineOp >
static void mapCombineGather (const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
 
template<class Container , class CombineOp >
static void mapCombineGather (Container &Values, const CombineOp &cop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class Container >
static void mapCombineScatter (const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
 Scatter data. Reverse of combineGather. More...
 
template<class Container >
static void mapCombineScatter (Container &Values, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void gatherList (const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
 Gather data but keep individual values separate. More...
 
template<class T >
static void gatherList (List< T > &Values, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class T >
static void scatterList (const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
 Scatter data. Reverse of gatherList. More...
 
template<class T >
static void scatterList (List< T > &Values, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
 Like above but switches between linear/tree communication. More...
 
template<class Container , class T >
static void exchange (const UList< Container > &sendData, const labelUList &recvSizes, List< Container > &recvData, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool block=true)
 Helper: exchange contiguous data. Sends sendData, receives into. More...
 
template<class Container >
static void exchangeSizes (const Container &sendData, labelList &sizes, const label comm=UPstream::worldComm)
 Helper: exchange sizes of sendData. sendData is the data per. More...
 
template<class Container , class T >
static void exchange (const UList< Container > &sendData, List< Container > &recvData, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool block=true)
 Exchange contiguous data. Sends sendData, receives into. More...
 
- Static Public Member Functions inherited from UPstream
static label allocateCommunicator (const label parent, const labelList &subRanks, const bool doPstream=true)
 Allocate a new communicator. More...
 
static void freeCommunicator (const label communicator, const bool doPstream=true)
 Free a previously allocated communicator. More...
 
static void freeCommunicators (const bool doPstream)
 Free all communicators. More...
 
static int baseProcNo (const label myComm, const int procID)
 Return physical processor number (i.e. processor number in. More...
 
static label procNo (const label comm, const int baseProcID)
 Return processor number in communicator (given physical processor. More...
 
static label procNo (const label myComm, const label currentComm, const int currentProcID)
 Return processor number in communicator (given processor number. More...
 
static void addValidParOptions (HashTable< string > &validParOptions)
 Add the valid option this type of communications library. More...
 
static bool init (int &argc, char **&argv, const bool needsThread)
 Initialisation function called from main. More...
 
static label nRequests ()
 Get number of outstanding requests. More...
 
static void resetRequests (const label sz)
 Truncate number of outstanding requests. More...
 
static void waitRequests (const label start=0)
 Wait until all requests (from start onwards) have finished. More...
 
static void waitRequest (const label i)
 Wait until request i has finished. More...
 
static bool finishedRequest (const label i)
 Non-blocking comms: has request i finished? More...
 
static int allocateTag (const char *)
 
static int allocateTag (const word &)
 
static void freeTag (const char *, const int tag)
 
static void freeTag (const word &, const int tag)
 
static bool & parRun ()
 Is this a parallel run? More...
 
static bool haveThreads ()
 Have support for threads. More...
 
static label nProcs (const label communicator=0)
 Number of processes in parallel run. More...
 
static int masterNo ()
 Process index of the master. More...
 
static bool master (const label communicator=0)
 Am I the master process. More...
 
static int myProcNo (const label communicator=0)
 Number of this process (starting from masterNo() = 0) More...
 
static label parent (const label communicator)
 
static List< int > & procID (label communicator)
 Process ID of given process index. More...
 
static int firstSlave ()
 Process index of first slave. More...
 
static int lastSlave (const label communicator=0)
 Process index of last slave. More...
 
static const List< commsStruct > & linearCommunication (const label communicator=0)
 Communication schedule for linear all-to-master (proc 0) More...
 
static const List< commsStruct > & treeCommunication (const label communicator=0)
 Communication schedule for tree all-to-master (proc 0) More...
 
static int & msgType ()
 Message tag of standard messages. More...
 
static void exit (int errnum=1)
 Exit program. More...
 
static void abort ()
 Abort program. More...
 
static void allToAll (const labelUList &sendData, labelUList &recvData, const label communicator=0)
 Exchange label with all processors (in the communicator). More...
 
static void allToAll (const char *sendData, const UList< int > &sendSizes, const UList< int > &sendOffsets, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=0)
 Exchange data with all processors (in the communicator) More...
 
static void gather (const char *sendData, int sendSize, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=0)
 Receive data from all processors on the master. More...
 
static void scatter (const char *sendData, const UList< int > &sendSizes, const UList< int > &sendOffsets, char *recvData, int recvSize, const label communicator=0)
 Send data to all processors from the root of the communicator. More...
 

Protected Attributes

DynamicList< char > buf_
 Transfer buffer. More...
 
- Protected Attributes inherited from UPstream
commsTypes commsType_
 Communications type of this stream. More...
 

Additional Inherited Members

- Public Types inherited from UPstream
enum class  commsTypes { blocking , scheduled , nonBlocking }
 Types of communications. More...
 
- Static Public Attributes inherited from UPstream
static const NamedEnum< commsTypes, 3 > commsTypeNames
 
static bool floatTransfer
 Should compact transfer be used in which floats replace doubles. More...
 
static int nProcsSimpleSum
 Number of processors at which the sum algorithm changes from linear. More...
 
static commsTypes defaultCommsType
 Default commsType. More...
 
static int nPollProcInterfaces
 Number of polling cycles in processor updates. More...
 
static label worldComm
 Default communicator (all processors) More...
 
static label warnComm
 Debugging: warn for use of any communicator differing from warnComm. More...
 

Detailed Description

Inter-processor communications stream.

Source files

Definition at line 53 of file Pstream.H.

Constructor & Destructor Documentation

◆ Pstream()

Pstream ( const commsTypes  commsType,
const label  bufSize = 0 
)
inline

Construct given optional buffer size.

Definition at line 74 of file Pstream.H.

References Pstream::buf_, and DynamicList< T, SizeInc, SizeMult, SizeDiv >::setCapacity().

Here is the call graph for this function:

Member Function Documentation

◆ ClassName()

ClassName ( "Pstream"  )

◆ gather() [1/2]

void gather ( const List< commsStruct > &  comms,
T Value,
const BinaryOp &  bop,
const int  tag,
const label  comm 
)
static

Gather data. Apply bop to combine Value.

from different processors

Definition at line 46 of file gatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), UIPstream::read(), UPstream::scheduled, Foam::T(), and UOPstream::write().

Referenced by Pstream::gather(), and Foam::reduce().

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

◆ gather() [2/2]

void gather ( T Value,
const BinaryOp &  bop,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 126 of file gatherScatter.C.

References Pstream::gather(), UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ scatter() [1/2]

void scatter ( const List< commsStruct > &  comms,
T Value,
const int  tag,
const label  comm 
)
static

Scatter data. Distribute without modification. Reverse of gather.

Definition at line 146 of file gatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), forAllReverse, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), UIPstream::read(), UPstream::scheduled, Foam::T(), and UOPstream::write().

Referenced by regIOobject::addWatch(), masterUncollatedFileOperation::addWatch(), masterUncollatedFileOperation::dirPath(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), masterUncollatedFileOperation::findTimes(), masterUncollatedFileOperation::findWatch(), masterUncollatedFileOperation::getFile(), masterUncollatedFileOperation::getState(), injectionModel::globalScalar01(), fileOperation::nProcs(), masterUncollatedFileOperation::read(), uncollatedFileOperation::read(), decomposedBlockData::readBlocks(), masterUncollatedFileOperation::readHeader(), regIOobject::readHeaderOk(), masterUncollatedFileOperation::readObjects(), masterUncollatedFileOperation::readStream(), Foam::reduce(), masterUncollatedFileOperation::removeWatch(), Pstream::scatter(), rigidBodyMotion::solve(), ParSortableList< Type >::sort(), hexRef8Data::sync(), IOobject::typeHeaderOk(), sixDoFRigidBodyMotion::update(), fileMonitor::updateStates(), OFstreamCollator::write(), decomposedBlockData::writeBlocks(), decomposedBlockData::writeData(), and masterOFstream::~masterOFstream().

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

◆ scatter() [2/2]

void scatter ( T Value,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 223 of file gatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, Pstream::scatter(), and UPstream::treeCommunication().

Here is the call graph for this function:

◆ combineGather() [1/2]

void combineGather ( const List< commsStruct > &  comms,
T Value,
const CombineOp &  cop,
const int  tag,
const label  comm 
)
static

Definition at line 44 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, Foam::T(), and UOPstream::write().

Referenced by Foam::combineReduce().

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

◆ combineGather() [2/2]

void combineGather ( T Value,
const CombineOp &  cop,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 145 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ combineScatter() [1/2]

void combineScatter ( const List< commsStruct > &  comms,
T Value,
const int  tag,
const label  comm 
)
static

Scatter data. Reverse of combineGather.

Definition at line 179 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAllReverse, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, Foam::T(), and UOPstream::write().

Referenced by Foam::combineReduce().

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

◆ combineScatter() [2/2]

void combineScatter ( T Value,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 267 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ listCombineGather() [1/2]

◆ listCombineGather() [2/2]

void listCombineGather ( List< T > &  Value,
const CombineOp &  cop,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 394 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ listCombineScatter() [1/2]

◆ listCombineScatter() [2/2]

void listCombineScatter ( List< T > &  Value,
const int  tag = Pstream::msgType(),
const label  comm = Pstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 516 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ mapCombineGather() [1/2]

void mapCombineGather ( const List< commsStruct > &  comms,
Container &  Values,
const CombineOp &  cop,
const int  tag,
const label  comm 
)
static

Definition at line 547 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, and UPstream::scheduled.

Referenced by regionSizeDistribution::regionSum(), and meshRefinement::zonify().

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

◆ mapCombineGather() [2/2]

void mapCombineGather ( Container &  Values,
const CombineOp &  cop,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 628 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ mapCombineScatter() [1/2]

void mapCombineScatter ( const List< commsStruct > &  comms,
Container &  Values,
const int  tag,
const label  comm 
)
static

Scatter data. Reverse of combineGather.

Definition at line 662 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAllReverse, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, and UPstream::scheduled.

Referenced by regionSizeDistribution::regionSum(), and meshRefinement::zonify().

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

◆ mapCombineScatter() [2/2]

void mapCombineScatter ( Container &  Values,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 720 of file combineGatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ gatherList() [1/2]

void gatherList ( const List< commsStruct > &  comms,
List< T > &  Values,
const int  tag,
const label  comm 
)
static

Gather data but keep individual values separate.

Definition at line 48 of file gatherScatterList.C.

References Foam::abort(), UPstream::commsStruct::above(), UPstream::commsStruct::allBelow(), UList< T >::begin(), UPstream::commsStruct::below(), UList< T >::byteSize(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, List< T >::size(), and UOPstream::write().

Referenced by surfaceZonesInfo::addCellZonesToMesh(), surfaceZonesInfo::addFaceZonesToMesh(), mappedInternalPatchBase::calcMapping(), mappedPatchBase::calcMapping(), lineFace::calcSamples(), meshRefinement::checkCoupledFaceZones(), polyBoundaryMesh::checkParallelSync(), collatedFileOperation::collatedFileOperation(), fieldValue::combineFields(), fvMeshDistribute::distribute(), distributedTriSurfaceMesh::distribute(), distributedTriSurfaceMesh::distributedTriSurfaceMesh(), coordSet::gather(), Foam::gatherAndFlatten(), PatchTools::gatherAndMerge(), Pstream::gatherList(), globalIndex::globalIndex(), hostCollatedFileOperation::hostCollatedFileOperation(), masterUncollatedFileOperation::masterOp(), masterUncollatedFileOperation::NewIFstream(), powerLawLopesdaCostaZone::powerLawLopesdaCostaZone(), processorTopology::processorTopology(), masterUncollatedFileOperation::readHeader(), masterUncollatedFileOperation::readStream(), sampledSurfaces::sampleType(), fvMeshSubset::setLargeCellSubset(), ParSortableList< Type >::sort(), cellsToCells::tgtMeshSendCells(), patchToPatch::tgtPatchSendFaces(), externalCoupledMixedFvPatchField< Type >::transferData(), externalCoupledTemperatureMixedFvPatchScalarField::transferData(), loadBalancer::update(), and masterOFstream::~masterOFstream().

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

◆ gatherList() [2/2]

void gatherList ( List< T > &  Values,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 197 of file gatherScatterList.C.

References Pstream::gatherList(), UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().

Here is the call graph for this function:

◆ scatterList() [1/2]

◆ scatterList() [2/2]

void scatterList ( List< T > &  Values,
const int  tag = Pstream::msgType(),
const label  comm = UPstream::worldComm 
)
static

Like above but switches between linear/tree communication.

Definition at line 339 of file gatherScatterList.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, Pstream::scatterList(), and UPstream::treeCommunication().

Here is the call graph for this function:

◆ exchange() [1/2]

void exchange ( const UList< Container > &  sendData,
const labelUList recvSizes,
List< Container > &  recvData,
const int  tag = UPstream::msgType(),
const label  comm = UPstream::worldComm,
const bool  block = true 
)
static

Helper: exchange contiguous data. Sends sendData, receives into.

recvData. If block=true will wait for all transfers to finish.

Definition at line 37 of file exchange.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, forAll, UPstream::myProcNo(), UPstream::nonBlocking, UPstream::nProcs(), UPstream::nRequests(), UPstream::parRun(), UIPstream::read(), List< T >::setSize(), UList< T >::size(), Foam::T(), UPstream::waitRequests(), and UOPstream::write().

Here is the call graph for this function:

◆ exchangeSizes()

void exchangeSizes ( const Container &  sendData,
labelList sizes,
const label  comm = UPstream::worldComm 
)
static

Helper: exchange sizes of sendData. sendData is the data per.

processor (in the communicator). Returns sizes of sendData on the sending processor.

Definition at line 136 of file exchange.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, forAll, UPstream::nProcs(), List< T >::setSize(), and List< T >::size().

Referenced by PstreamBuffers::finishedSends().

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

◆ exchange() [2/2]

void exchange ( const UList< Container > &  sendData,
List< Container > &  recvData,
const int  tag = UPstream::msgType(),
const label  comm = UPstream::worldComm,
const bool  block = true 
)
static

Exchange contiguous data. Sends sendData, receives into.

recvData. Determines sizes to receive. If block=true will wait for all transfers to finish.

Definition at line 163 of file exchange.C.

Member Data Documentation

◆ buf_

DynamicList<char> buf_
protected

Transfer buffer.

Definition at line 63 of file Pstream.H.

Referenced by Pstream::Pstream().


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