48 { commsTypes::blocking,
"blocking" },
49 { commsTypes::scheduled,
"scheduled" },
50 { commsTypes::nonBlocking,
"nonBlocking" },
56void 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)
220 const List<int>& parentRanks = UPstream::procID(comm);
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;
369bool Foam::UPstream::parRun_(
false);
371bool Foam::UPstream::haveThreads_(
false);
373int Foam::UPstream::msgType_(1);
388Foam::UPstream::linearCommunication_(10);
391Foam::UPstream::treeCommunication_(10);
476 "nPollProcInterfaces",
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::UPstream::communicator serialComm(-1, Foam::labelList(Foam::one{}, 0), false)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
EnumType read(Istream &is) const
Read a word from Istream and return the corresponding enumeration.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void setSize(const label n)
Alias for resize()
void append(const T &val)
Append an element at the end of the list.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
T & operator[](const label i)
Return element of UList.
Structure for communicating between processors.
const labelList & allBelow() const noexcept
const labelList & allNotBelow() const noexcept
Helper class for allocating/freeing communicators.
Inter-processor communications stream.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
commsTypes
Types of communications.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static void freeCommunicators(const bool doPstream)
Free all communicators.
static const Enum< commsTypes > commsTypeNames
Names of the communication types.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
static bool floatTransfer
static const int mpiBufferSize
MPI buffer-size (bytes)
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
static label worldComm
Default communicator (all processors)
static bool haveThreads() noexcept
Have support for threads.
static int nProcsSimpleSum
Number of processors to change from linear to tree communication.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
static int maxCommsSize
Optional maximum message size (bytes)
static label procNo(const label comm, const int baseProcID)
static commsTypes defaultCommsType
Default commsType.
static int baseProcNo(const label myComm, const int procID)
virtual void readData(Foam::Istream &is)
Read.
virtual void writeData(Foam::Ostream &os) const
Write.
virtual ~addcommsTypeToOpt()=default
addcommsTypeToOpt(const char *name)
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
const string & prefix() const noexcept
Return the stream prefix.
Abstract base class for registered object with I/O. Used in debug symbol registration.
splitCell * parent() const
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict(s).
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
Ostream & endl(Ostream &os)
Add newline and flush stream.
addcommsTypeToOpt addcommsTypeToOpt_("commsType")
errorManip< error > abort(error &err)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define registerOptSwitch(Name, Type, SwitchVar)
#define forAll(list, i)
Loop across all elements in list.