Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Pstream Class Reference

Inter-processor communications stream. More...

Inheritance diagram for Pstream:
Inheritance graph
[legend]
Collaboration diagram for Pstream:
Collaboration graph
[legend]

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  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

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 47 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::Pstream(), 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 127 of file gatherScatter.C.

References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, Pstream::scatter(), 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 147 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 unwatchedIOdictionary::addWatch(), regIOobject::addWatch(), masterUncollatedFileOperation::addWatch(), masterUncollatedFileOperation::dirPath(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), masterUncollatedFileOperation::findTimes(), masterUncollatedFileOperation::findWatch(), Pstream::gather(), masterUncollatedFileOperation::getFile(), masterUncollatedFileOperation::getState(), Random::globalScalar01(), fileOperation::nProcs(), InflationInjection< CloudType >::parcelsToInject(), Pstream::Pstream(), uncollatedFileOperation::read(), masterUncollatedFileOperation::read(), decomposedBlockData::readBlocks(), masterUncollatedFileOperation::readHeader(), 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 45 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAll, Foam::Pout, Foam::blockMeshTools::read(), T, and Foam::blockMeshTools::write().

Referenced by Foam::combineReduce(), and Pstream::Pstream().

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 146 of file combineGatherScatter.C.

References Pstream::combineScatter().

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 180 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAllReverse, Foam::Pout, Foam::blockMeshTools::read(), T, and Foam::blockMeshTools::write().

Referenced by Pstream::combineGather(), Foam::combineReduce(), and Pstream::Pstream().

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 268 of file combineGatherScatter.C.

References Pstream::listCombineGather().

Here is the call graph for this function:

◆ listCombineGather() [1/2]

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

◆ 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 395 of file combineGatherScatter.C.

References Pstream::listCombineScatter().

Here is the call graph for this function:

◆ listCombineScatter() [1/2]

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

◆ 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 517 of file combineGatherScatter.C.

References Pstream::mapCombineGather().

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

◆ 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 629 of file combineGatherScatter.C.

References Pstream::mapCombineScatter().

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 663 of file combineGatherScatter.C.

References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::endl(), forAllReverse, and Foam::Pout.

Referenced by extrudePatchMesh::extrudePatchMesh(), Pstream::mapCombineGather(), ListPlusEqOp< T, Size >::operator()(), Pstream::Pstream(), 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 721 of file combineGatherScatter.C.

◆ 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 49 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(), meshRefinement::checkCoupledFaceZones(), polyBoundaryMesh::checkParallelSync(), collatedFileOperation::collatedFileOperation(), mappedPatchBase::collectSamples(), fieldValue::combineFields(), fvMeshDistribute::distribute(), distributedTriSurfaceMesh::distribute(), distributedTriSurfaceMesh::distributedTriSurfaceMesh(), Pstream::gatherList(), globalIndex::globalIndex(), hostCollatedFileOperation::hostCollatedFileOperation(), NamedEnum< directionType, 3 >::names(), masterUncollatedFileOperation::NewIFstream(), lessProcPatches::operator()(), InflationInjection< CloudType >::parcelsToInject(), powerLawLopesdaCostaZone::powerLawLopesdaCostaZone(), Pstream::Pstream(), masterUncollatedFileOperation::readHeader(), masterUncollatedFileOperation::readStream(), fvMeshSubset::setLargeCellSubset(), ParSortableList< Type >::sort(), externalCoupledTemperatureMixedFvPatchScalarField::transferData(), 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, Pstream::scatterList(), and UPstream::treeCommunication().

Here is the call graph for this function:

◆ scatterList() [1/2]

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

◆ 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 38 of file exchange.C.

References Foam::abort(), Pstream::exchangeSizes(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::blockMeshTools::read(), List< T >::setSize(), UList< T >::size(), T, and Foam::blockMeshTools::write().

Referenced by Pstream::exchangeSizes(), and Pstream::Pstream().

Here is the call graph for this function:
Here is the caller 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 139 of file exchange.C.

References Foam::abort(), Pstream::exchange(), Foam::FatalError, FatalErrorInFunction, forAll, and List< T >::setSize().

Referenced by Pstream::exchange(), PstreamBuffers::finishedSends(), and Pstream::Pstream().

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 166 of file exchange.C.

Member Data Documentation

◆ buf_

DynamicList<char> buf_
protected

Transfer buffer.

Definition at line 63 of file Pstream.H.


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