Inter-processor communications stream. More...
Public Member Functions | |
ClassName ("Pstream") | |
Pstream (const commsTypes commsType, const label bufSize=0) | |
Construct given optional buffer size. More... | |
![]() | |
ClassName ("UPstream") | |
UPstream (const commsTypes commsType) | |
Construct for given communication type. More... | |
commsTypes | commsType () const noexcept |
Get the communications type of the stream. More... | |
commsTypes | commsType (const commsTypes ct) noexcept |
Set the communications type of the stream. More... | |
template<class T > | |
Foam::List< T > | listGatherValues (const T &localValue, const label comm) |
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) |
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 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) |
static label | procNo (const label comm, const int baseProcID) |
static label | procNo (const label myComm, const label currentComm, const int currentProcID) |
static void | addValidParOptions (HashTable< string > &validParOptions) |
static bool | init (int &argc, char **&argv, const bool needsThread) |
Initialisation function called from main. More... | |
static bool | initNull () |
Special purpose initialisation function. 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 (const bool on) noexcept |
Set as parallel run on/off. More... | |
static bool & | parRun () noexcept |
Test if this a parallel run. More... | |
static bool | haveThreads () noexcept |
Have support for threads. More... | |
static label | nProcs (const label communicator=worldComm) |
Number of processes in parallel run, and 1 for serial run. More... | |
static constexpr int | masterNo () noexcept |
Process index of the master (always 0) More... | |
static bool | master (const label communicator=worldComm) |
Am I the master process. More... | |
static int | myProcNo (const label communicator=worldComm) |
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 const wordList & | allWorlds () noexcept |
All worlds. More... | |
static const labelList & | worldIDs () noexcept |
worldID (index in allWorlds) of all processes More... | |
static label | myWorldID () |
My worldID. More... | |
static const word & | myWorld () |
My world. More... | |
static rangeType | allProcs (const label communicator=worldComm) |
Range of process indices for all processes. More... | |
static rangeType | subProcs (const label communicator=worldComm) |
Range of process indices for sub-processes. More... | |
static const List< commsStruct > & | linearCommunication (const label communicator=worldComm) |
Communication schedule for linear all-to-master (proc 0) More... | |
static const List< commsStruct > & | treeCommunication (const label communicator=worldComm) |
Communication schedule for tree all-to-master (proc 0) More... | |
static int & | msgType () noexcept |
Message tag of standard messages. More... | |
static void | shutdown (int errNo=0) |
Shutdown (finalize) MPI as required. More... | |
static void | abort () |
Call MPI_Abort with no other checks or cleanup. More... | |
static void | exit (int errNo=1) |
Shutdown (finalize) MPI as required and exit program with errNo. More... | |
static void | allToAll (const labelUList &sendData, labelUList &recvData, const label communicator=worldComm) |
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=worldComm) |
Exchange data with all processors (in the communicator) More... | |
static void | mpiGather (const char *sendData, int sendSize, char *recvData, int recvSize, const label communicator=worldComm) |
Receive data from all processors on the master (low-level) More... | |
static void | mpiScatter (const char *sendData, int sendSize, char *recvData, int recvSize, const label communicator=worldComm) |
Send data to all processors from master (low-level) More... | |
static void | gather (const char *sendData, int sendSize, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=worldComm) |
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=worldComm) |
Send data to all processors from the root of the communicator. More... | |
template<class T > | |
static List< T > | listGatherValues (const T &localValue, const label communicator=worldComm) |
Individual values into list locations. More... | |
template<class T > | |
static T | listScatterValues (const UList< T > &allValues, const label communicator=worldComm) |
Individual values into list locations. More... | |
static constexpr int | firstSlave () noexcept |
Process index of first sub-process. More... | |
static int | lastSlave (const label communicator=worldComm) |
Process index of last sub-process. More... | |
Protected Attributes | |
DynamicList< char > | transferBuf_ |
Allocated transfer buffer (can be used for send or receive) More... | |
![]() | |
commsTypes | commsType_ |
Communications type of this stream. More... | |
Additional Inherited Members | |
![]() | |
enum | commsTypes : char { blocking, scheduled, nonBlocking } |
Types of communications. More... | |
typedef IntRange< int > | rangeType |
Int ranges are used for MPI ranks (processes) More... | |
![]() | |
static const Enum< commsTypes > | commsTypeNames |
Names of the communication types. More... | |
static bool | floatTransfer |
static int | nProcsSimpleSum |
static commsTypes | defaultCommsType |
Default commsType. More... | |
static int | nPollProcInterfaces |
Number of polling cycles in processor updates. More... | |
static int | maxCommsSize |
Optional maximum message size (bytes) More... | |
static const int | mpiBufferSize |
MPI buffer-size (bytes) More... | |
static label | worldComm |
Default communicator (all processors) More... | |
static label | warnComm |
Debugging: warn for use of any communicator differing from warnComm. More... | |
Inter-processor communications stream.
|
inlineexplicit |
Construct given optional buffer size.
Definition at line 110 of file Pstream.H.
References DynamicList< T, SizeMin >::setCapacity(), and Pstream::transferBuf_.
ClassName | ( | "Pstream" | ) |
|
static |
Gather data. Apply bop to combine Value from different processors
Definition at line 50 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 Foam::reduce().
|
static |
Like above but switches between linear/tree communication.
Definition at line 130 of file gatherScatter.C.
References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().
|
static |
Scatter data. Distribute without modification. Reverse of gather.
Definition at line 150 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(), multiWorldConnections::createComms(), masterUncollatedFileOperation::dirPath(), systemCall::dispatch(), abort::execute(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), meshRefinement::findRegions(), masterUncollatedFileOperation::findTimes(), masterUncollatedFileOperation::findWatch(), masterUncollatedFileOperation::getFile(), masterUncollatedFileOperation::getState(), Random::globalGaussNormal(), Random::globalPosition(), Random::globalRandomise01(), Random::globalSample01(), surfaceNoise::initialise(), fileOperation::lookupAndCacheProcessorsPath(), fvMeshTools::newMesh(), fileOperation::nProcs(), InflationInjection< CloudType >::parcelsToInject(), masterUncollatedFileOperation::read(), lumpedPointState::readData(), masterUncollatedFileOperation::readHeader(), masterUncollatedFileOperation::readObjects(), masterUncollatedFileOperation::readStream(), Foam::reduce(), masterUncollatedFileOperation::removeWatch(), Pstream::scatter(), rigidBodyMotion::solve(), ParSortableList< Type >::sort(), surfaceNoise::surfaceAverage(), hexRef8Data::sync(), triSurfaceMesh::triSurfaceMesh(), sixDoFRigidBodyMotion::update(), turbulentDigitalFilterInletFvPatchVectorField::updateCoeffs(), fileMonitor::updateStates(), externalFileCoupler::waitForMaster(), externalFileCoupler::waitForSlave(), OFstreamCollator::write(), decomposedBlockData::writeData(), sampledSets::writeSampleFile(), surfaceNoise::writeSurfaceData(), and streamLineBase::writeToFile().
|
static |
Like above but switches between linear/tree communication.
Definition at line 226 of file gatherScatter.C.
References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, Pstream::scatter(), and UPstream::treeCommunication().
|
static |
Definition at line 48 of file combineGatherScatter.C.
References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), forAll, Foam::Pout, Foam::blockMeshTools::read(), T, and Foam::vtk::write().
Referenced by Foam::combineReduce(), multiWorldConnections::createComms(), and parProfiling::report().
|
static |
Like above but switches between linear/tree communication.
Definition at line 149 of file combineGatherScatter.C.
|
static |
Scatter data. Reverse of combineGather.
Definition at line 183 of file combineGatherScatter.C.
References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), forAllReverse, Foam::Pout, Foam::blockMeshTools::read(), T, and Foam::vtk::write().
Referenced by Foam::combineReduce().
|
static |
Like above but switches between linear/tree communication.
Definition at line 271 of file combineGatherScatter.C.
|
static |
Definition at line 290 of file combineGatherScatter.C.
References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), forAll, Foam::Pout, Foam::blockMeshTools::read(), and Foam::vtk::write().
Referenced by lumpedPointMovement::areas(), meshRefinement::balance(), forces::calcForcesMoment(), viewFactor::calculate(), extractEulerianParticles::calculateAddressing(), NURBS3DVolume::computeControlPointSensitivities(), patchInjection::correct(), cellCellStencil::count(), meshRefinement::createZoneBaffles(), Curle::execute(), patchProbes::findElements(), mappedPatchBase::findSamples(), lumpedPointMovement::forcesAndMoments(), injectionModelList::info(), transferModelList::info(), propellerInfo::interpolate(), patchInjection::patchInjectedMassTotals(), meshRefinement::printMeshInfo(), probes::sample(), patchProbes::sample(), fvMeshSubset::setCellSubset(), cellVolumeWeight::update(), inverseDistance::update(), patchInjectionBase::updateMesh(), propellerInfo::updateSampleDiskCells(), fileMonitor::updateStates(), and histogram::write().
|
static |
Like above but switches between linear/tree communication.
Definition at line 398 of file combineGatherScatter.C.
|
static |
Scatter data. Reverse of combineGather.
Definition at line 432 of file combineGatherScatter.C.
References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), forAllReverse, Foam::Pout, Foam::blockMeshTools::read(), and Foam::vtk::write().
Referenced by lumpedPointMovement::areas(), meshRefinement::balance(), forces::calcForcesMoment(), viewFactor::calculate(), extractEulerianParticles::calculateAddressing(), NURBS3DVolume::computeControlPointSensitivities(), meshRefinement::createZoneBaffles(), Curle::execute(), patchProbes::findElements(), mappedPatchBase::findSamples(), lumpedPointMovement::forcesAndMoments(), propellerInfo::interpolate(), meshRefinement::printMeshInfo(), probes::sample(), patchProbes::sample(), fvMeshSubset::setCellSubset(), cellVolumeWeight::update(), inverseDistance::update(), patchInjectionBase::updateMesh(), propellerInfo::updateSampleDiskCells(), and fileMonitor::updateStates().
|
static |
Like above but switches between linear/tree communication.
Definition at line 520 of file combineGatherScatter.C.
|
static |
Definition at line 551 of file combineGatherScatter.C.
References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), forAll, and Foam::Pout.
Referenced by areaWrite::write(), and meshRefinement::zonify().
|
static |
Like above but switches between linear/tree communication.
Definition at line 632 of file combineGatherScatter.C.
|
static |
Scatter data. Reverse of combineGather.
Definition at line 666 of file combineGatherScatter.C.
References UPstream::commsStruct::above(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), forAllReverse, and Foam::Pout.
Referenced by areaWrite::write(), and meshRefinement::zonify().
|
static |
Like above but switches between linear/tree communication.
Definition at line 724 of file combineGatherScatter.C.
|
static |
Gather data but keep individual values separate.
Definition at line 52 of file gatherScatterList.C.
References Foam::abort(), UPstream::commsStruct::above(), UPstream::commsStruct::allBelow(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, and UOPstream::write().
Referenced by surfaceZonesInfo::addCellZonesToMesh(), surfaceZonesInfo::addFaceZonesToMesh(), sensitivitySurfacePoints::assembleSensitivities(), meshRefinement::checkCoupledFaceZones(), polyBoundaryMesh::checkParallelSync(), mappedPatchBase::collectSamples(), fieldValue::combineFields(), sizeDistribution::combineFields(), distributedTriSurfaceMesh::distribute(), distributedTriSurfaceMesh::distributedTriSurfaceMesh(), meshRefinement::findRegions(), mappedPatchBase::findSamples(), externalCoupled::gatherAndCombine(), Pstream::gatherList(), InjectedParticleInjection< CloudType >::initialise(), viewFactor::initialise(), InjectedParticleDistributionInjection< CloudType >::initialise(), distributedTriSurfaceMesh::localQueries(), masterUncollatedFileOperation::NewIFstream(), InflationInjection< CloudType >::parcelsToInject(), pointHistory::pointHistory(), masterUncollatedFileOperation::readHeader(), masterUncollatedFileOperation::readStream(), globalIndex::reset(), fvMeshSubset::setCellSubset(), ParSortableList< Type >::sort(), trackingInverseDistance::update(), inverseDistance::update(), externalCoupled::writeGeometry(), and isoAdvection::writeIsoFaces().
|
static |
Like above but switches between linear/tree communication.
Definition at line 200 of file gatherScatterList.C.
References Pstream::gatherList(), UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, and UPstream::treeCommunication().
|
static |
Scatter data. Reverse of gatherList.
Definition at line 215 of file gatherScatterList.C.
References Foam::abort(), UPstream::commsStruct::above(), UPstream::commsStruct::allNotBelow(), UPstream::commsStruct::below(), Foam::expressions::patchExpr::debug, Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, forAllReverse, UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::Pout, UIPstream::read(), UPstream::scheduled, and UOPstream::write().
Referenced by surfaceZonesInfo::addCellZonesToMesh(), surfaceZonesInfo::addFaceZonesToMesh(), sensitivitySurfacePoints::assembleSensitivities(), meshRefinement::checkCoupledFaceZones(), polyBoundaryMesh::checkParallelSync(), mappedPatchBase::collectSamples(), fieldValue::combineFields(), distributedTriSurfaceMesh::distribute(), distributedTriSurfaceMesh::distributedTriSurfaceMesh(), mappedPatchBase::findSamples(), InjectedParticleInjection< CloudType >::initialise(), InjectedParticleDistributionInjection< CloudType >::initialise(), distributedTriSurfaceMesh::localQueries(), pointHistory::pointHistory(), globalIndex::reset(), Pstream::scatterList(), fvMeshSubset::setCellSubset(), trackingInverseDistance::update(), and inverseDistance::update().
|
static |
Like above but switches between linear/tree communication.
Definition at line 342 of file gatherScatterList.C.
References UPstream::linearCommunication(), UPstream::nProcs(), UPstream::nProcsSimpleSum, Pstream::scatterList(), and UPstream::treeCommunication().
|
static |
Helper: exchange contiguous data. Sends sendData, receives into.
recvData. If block=true will wait for all transfers to finish.
Definition at line 187 of file exchange.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::max(), UPstream::maxCommsSize, Foam::min(), UPstream::myProcNo(), UPstream::nProcs(), UPstream::parRun(), Foam::reduce(), List< T >::setSize(), UList< T >::size(), Foam::T(), and Foam::Zero.
|
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 349 of file exchange.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, forAll, UPstream::nProcs(), and List< T >::setSize().
Referenced by distributedTriSurfaceMesh::distribute(), PstreamBuffers::finishedSends(), and mapDistributeBase::mapDistributeBase().
|
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 376 of file exchange.C.
|
protected |
Allocated transfer buffer (can be used for send or receive)
Definition at line 97 of file Pstream.H.
Referenced by Pstream::Pstream().