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
99 Pout<<
"UPstream::setParRun :"
109 const label parentIndex,
115 if (!freeComms_.empty())
117 index = freeComms_.remove();
122 index = parentCommunicator_.size();
124 myProcNo_.append(-1);
126 parentCommunicator_.append(-1);
133 Pout<<
"Communicators : Allocating communicator " << index <<
endl
134 <<
" parent : " << parentIndex <<
endl
135 <<
" procs : " << subRanks <<
endl
140 myProcNo_[index] = 0;
143 procIDs_[index].setSize(subRanks.size());
144 forAll(procIDs_[index], i)
146 procIDs_[index][i] = subRanks[i];
149 if (i >= 1 && subRanks[i] <= subRanks[i-1])
152 <<
"subranks not sorted : " << subRanks
153 <<
" when allocating subcommunicator from parent "
158 parentCommunicator_[index] = parentIndex;
164 if (doPstream && parRun())
166 allocatePstreamCommunicator(parentIndex, index);
187 if (doPstream && parRun())
215 int procID = myProcID;
218 while (parent(comm) != -1)
221 procID = parentRanks[procID];
231 const List<int>& parentRanks = procID(myComm);
232 label parentComm = parent(myComm);
234 if (parentComm == -1)
236 return parentRanks.find(baseProcID);
240 const label parentRank = procNo(parentComm, baseProcID);
241 return parentRanks.find(parentRank);
249 const label currentComm,
250 const int currentProcID
254 return procNo(myComm, physProcID);
279 for (label procI = 1; procI < size(); procI++)
281 below[procI-1] = procI;
321 for (label step = 1; step < size(); step = mod)
327 above = procID - (procID % mod);
334 label j = procID + step;
335 j < size() && j < procID + mod;
343 label j = procID + step;
344 j < size() && j < procID + mod;
369 bool Foam::UPstream::parRun_(
false);
371 bool Foam::UPstream::haveThreads_(
false);
373 int Foam::UPstream::msgType_(1);
388 Foam::UPstream::linearCommunication_(10);
391 Foam::UPstream::treeCommunication_(10);
476 "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)
virtual ~addcommsTypeToOpt()=default
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
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
OSstream wrapped stdout (std::cout) with parallel prefix.
static bool haveThreads() noexcept
Have support for threads.
#define forAll(list, i)
Loop across all elements in list.
addcommsTypeToOpt(const char *name)
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.
const labelList & allNotBelow() const noexcept
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void setSize(const label n)
Alias for resize()
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.
OBJstream os(runTime.globalPath()/outputName)
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 nProcsSimpleSum
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
commsTypes
Types of communications.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void writeData(Foam::Ostream &os) const
Write.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
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.
const labelList & allBelow() const noexcept
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Foam::UPstream::communicator serialComm(-1, Foam::labelList(Foam::one{}, 0), false)
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.
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)
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 label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
const string & prefix() const noexcept
Return the stream prefix.