Go to the documentation of this file.
48 { commsTypes::blocking,
"blocking" },
49 { commsTypes::scheduled,
"scheduled" },
50 { commsTypes::nonBlocking,
"nonBlocking" },
56 void Foam::UPstream::setParRun(
const label nProcs,
const bool haveThreads)
68 <<
"problem : comm:" << comm
88 <<
"problem : comm:" << comm
101 const label parentIndex,
107 if (!freeComms_.empty())
109 index = freeComms_.pop();
114 index = parentCommunicator_.size();
116 myProcNo_.append(-1);
118 parentCommunicator_.append(-1);
125 Pout<<
"Communicators : Allocating communicator " << index <<
endl
126 <<
" parent : " << parentIndex <<
endl
127 <<
" procs : " << subRanks <<
endl
132 myProcNo_[index] = 0;
135 procIDs_[index].setSize(subRanks.size());
136 forAll(procIDs_[index], i)
138 procIDs_[index][i] = subRanks[i];
141 if (i >= 1 && subRanks[i] <= subRanks[i-1])
144 <<
"subranks not sorted : " << subRanks
145 <<
" when allocating subcommunicator from parent "
150 parentCommunicator_[index] = parentIndex;
156 if (doPstream && parRun())
158 allocatePstreamCommunicator(parentIndex, index);
179 if (doPstream && parRun())
207 int procID = myProcID;
210 while (parent(comm) != -1)
213 procID = parentRanks[procID];
223 const List<int>& parentRanks = procID(myComm);
224 label parentComm = parent(myComm);
226 if (parentComm == -1)
228 return parentRanks.find(baseProcID);
232 const label parentRank = procNo(parentComm, baseProcID);
233 return parentRanks.find(parentRank);
241 const label currentComm,
242 const int currentProcID
246 return procNo(myComm, physProcID);
271 for (label procI = 1; procI < size(); procI++)
273 below[procI-1] = procI;
313 for (label step = 1; step < size(); step = mod)
319 above = procID - (procID % mod);
326 label j = procID + step;
327 j < size() && j < procID + mod;
335 label j = procID + step;
336 j < size() && j < procID + mod;
361 bool Foam::UPstream::parRun_(
false);
363 bool Foam::UPstream::haveThreads_(
false);
373 int Foam::UPstream::msgType_(1);
377 Foam::UPstream::linearCommunication_(10);
380 Foam::UPstream::treeCommunication_(10);
465 "nPollProcInterfaces",
virtual void readData(Foam::Istream &is)
Read.
int debug
Static debugging option.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
List< label > labelList
A List of labels.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static int baseProcNo(const label myComm, const int procID)
static bool haveThreads()
Have support for threads.
virtual ~addcommsTypeToOpt()=default
static constexpr const zero Zero
Global zero (0)
static label nProcs(const label communicator=0)
Number of processes in parallel run.
void append(const T &val)
Append an element at the end of the list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static commsTypes defaultCommsType
Default commsType.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
#define forAll(list, i)
Loop across all elements in list.
addcommsTypeToOpt(const char *name)
const labelList & allBelow() const
static const int mpiBufferSize
MPI buffer-size (bytes)
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
word name(const complex &c)
Return string representation of complex.
static bool floatTransfer
static List< int > & procID(label communicator)
Process ID of given process index.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
addcommsTypeToOpt addcommsTypeToOpt_("commsType")
static const Enum< commsTypes > commsTypeNames
Names of the communication types.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
const labelList & allNotBelow() const
registerOptSwitch("floatTransfer", bool, Foam::UPstream::floatTransfer)
errorManip< error > abort(error &err)
Structure for communicating between processors.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static int nProcsSimpleSum
prefixOSstream Perr
An Ostream wrapper for parallel output to std::cerr.
commsTypes
Types of communications.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void writeData(Foam::Ostream &os) const
Write.
static int maxCommsSize
Optional maximum message size (bytes)
static label worldComm
Default communicator (all processors)
T & operator[](const label i)
Return element of UList.
static label procNo(const label comm, const int baseProcID)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
static void freeCommunicators(const bool doPstream)
Free all communicators.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static label parent(const label communicator)
Helper class for allocating/freeing communicators.
A LIFO stack based on a singly-linked list.
Foam::UPstream::communicator serialComm(-1, Foam::labelList(1, Foam::Zero), false)
void setSize(const label newSize)
Alias for resize(const label)
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict(s).
EnumType read(Istream &is) const
Read a word from Istream and return the corresponding enumeration.
defineTypeNameAndDebug(combustionModel, 0)
const string & prefix() const
Return the stream prefix.
void addOptimisationObject(const char *name, simpleRegIOobject *obj)
Register optimisation switch read/write object.
Abstract base class for registered object with I/O. Used in debug symbol registration.
static int nPollProcInterfaces
Number of polling cycles in processor updates.