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);
125 procIDs_.append(List<int>());
126 parentCommunicator_.append(-1);
127 linearCommunication_.append(List<commsStruct>());
128 treeCommunication_.append(List<commsStruct>());
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;
161 linearCommunication_[index] = List<commsStruct>(procIDs_[index].size());
162 treeCommunication_[index] = List<commsStruct>(procIDs_[index].size());
164 if (doPstream && parRun())
166 allocatePstreamCommunicator(parentIndex, index);
175 const label communicator,
181 Pout<<
"Communicators : Freeing communicator " << communicator <<
endl
182 <<
" parent : " << parentCommunicator_[communicator] <<
endl
183 <<
" myProcNo : " << myProcNo_[communicator] <<
endl
187 if (doPstream && parRun())
189 freePstreamCommunicator(communicator);
191 myProcNo_[communicator] = -1;
193 parentCommunicator_[communicator] = -1;
203 forAll(myProcNo_, communicator)
205 if (myProcNo_[communicator] != -1)
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;
353 t = UPstream::commsStruct(size(), procID, above, below, allBelow);
363 return const_cast<UList<UPstream::commsStruct>&
>(*this).operator[](procID);
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)
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)
Ostream & endl(Ostream &os)
static commsTypes defaultCommsType
static bool haveThreads() noexcept
addcommsTypeToOpt(const char *name)
static const int mpiBufferSize
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
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)
static bool floatTransfer
static List< int > & procID(label communicator)
static void freeCommunicator(const label communicator, const bool doPstream=true)
addcommsTypeToOpt addcommsTypeToOpt_("commsType")
static const Enum< commsTypes > commsTypeNames
int optimisationSwitch(const char *name, const int deflt=0)
OBJstream os(runTime.globalPath()/outputName)
registerOptSwitch("floatTransfer", bool, Foam::UPstream::floatTransfer)
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
static int nProcsSimpleSum
#define FatalErrorInFunction
virtual void writeData(Foam::Ostream &os) const
static int myProcNo(const label communicator=worldComm)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
T & operator[](const label i)
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)
static void freeCommunicators(const bool doPstream)
const labelList & allBelow() const noexcept
word name(const expressions::valueTypeCode typeCode)
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)
dictionary & optimisationSwitches()
EnumType read(Istream &is) const
defineTypeNameAndDebug(combustionModel, 0)
void addOptimisationObject(const char *name, simpleRegIOobject *obj)
Abstract base class for registered object with I/O. Used in debug symbol registration.
static label nProcs(const label communicator=worldComm)
static int nPollProcInterfaces
const string & prefix() const noexcept