58 void Foam::UPstream::setParRun(
const label nProcs)
68 <<
"problem : comm:" << comm
83 label comm = allocateCommunicator(-1,
identity(nProcs),
true);
87 <<
"problem : comm:" << comm
112 linearCommunication[0] = commsStruct
122 for (
label procID = 1; procID < nProcs; procID++)
124 linearCommunication[procID] = commsStruct
133 return linearCommunication;
137 void Foam::UPstream::collectReceives
148 forAll(myChildren, childI)
150 allReceives.
append(myChildren[childI]);
151 collectReceives(myChildren[childI], receives, allReceives);
189 while ((1 << nLevels) < nProcs)
200 label childOffset = offset/2;
202 for (
label level = 0; level < nLevels; level++)
205 while (receiveID < nProcs)
208 label sendID = receiveID + childOffset;
212 receives[receiveID].
append(sendID);
213 sends[sendID] = receiveID;
226 for (
label procID = 0; procID < nProcs; procID++)
228 collectReceives(procID, receives, allReceives[procID]);
234 for (
label procID = 0; procID < nProcs; procID++)
236 treeCommunication[procID] = commsStruct
241 receives[procID].shrink(),
242 allReceives[procID].shrink()
245 return treeCommunication;
251 const label parentIndex,
257 if (!freeComms_.empty())
259 index = freeComms_.pop();
264 index = parentCommunicator_.size();
266 myProcNo_.append(-1);
268 parentCommunicator_.append(-1);
275 Pout<<
"Communicators : Allocating communicator " << index <<
endl 276 <<
" parent : " << parentIndex <<
endl 277 <<
" procs : " << subRanks <<
endl 282 myProcNo_[index] = 0;
285 procIDs_[index].setSize(subRanks.
size());
286 forAll(procIDs_[index], i)
288 procIDs_[index][i] = subRanks[i];
291 if (i >= 1 && subRanks[i] <= subRanks[i-1])
294 <<
"subranks not sorted : " << subRanks
295 <<
" when allocating subcommunicator from parent " 300 parentCommunicator_[index] = parentIndex;
302 linearCommunication_[index] = calcLinearComm(procIDs_[index].size());
303 treeCommunication_[index] = calcTreeComm(procIDs_[index].size());
306 if (doPstream && parRun())
308 allocatePstreamCommunicator(parentIndex, index);
317 const label communicator,
323 Pout<<
"Communicators : Freeing communicator " << communicator <<
endl 324 <<
" parent : " << parentCommunicator_[communicator] <<
endl 325 <<
" myProcNo : " << myProcNo_[communicator] <<
endl 329 if (doPstream && parRun())
331 freePstreamCommunicator(communicator);
333 myProcNo_[communicator] = -1;
335 parentCommunicator_[communicator] = -1;
336 linearCommunication_[communicator].clear();
337 treeCommunication_[communicator].clear();
339 freeComms_.push(communicator);
345 forAll(myProcNo_, communicator)
347 if (myProcNo_[communicator] != -1)
349 freeCommunicator(communicator, doPstream);
357 int procID = myProcID;
360 while (parent(comm) != -1)
363 procID = parentRanks[procID];
373 const List<int>& parentRanks = procID(myComm);
374 label parentComm = parent(myComm);
376 if (parentComm == -1)
378 return findIndex(parentRanks, baseProcID);
382 label parentRank = procNo(parentComm, baseProcID);
383 return findIndex(parentRanks, parentRank);
391 const label currentComm,
392 const int currentProcID
396 return procNo(myComm, physProcID);
402 bool Foam::UPstream::parRun_(
false);
412 int Foam::UPstream::msgType_(1);
416 Foam::UPstream::linearCommunication_(10);
419 Foam::UPstream::treeCommunication_(10);
440 Foam::UPstream::floatTransfer
451 Foam::UPstream::nProcsSimpleSum
503 "nPollProcInterfaces",
505 Foam::UPstream::nPollProcInterfaces
A LIFO stack based on a singly-linked list.
static bool floatTransfer
Should compact transfer be used in which floats replace doubles.
Abstract base class for registered object with I/O. Used in debug symbol registration.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
addcommsTypeToOpt addcommsTypeToOpt_("commsType")
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Foam::UPstream::communicator serialComm(-1, Foam::labelList(1, Foam::label(0)), false)
commsTypes
Types of communications.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
static int nProcsSimpleSum
Number of processors at which the sum algorithm changes from linear.
Ostream & endl(Ostream &os)
Add newline and flush stream.
int optimisationSwitch(const char *name, const int defaultValue=0)
Lookup optimisation switch or add default value.
static label procNo(const label comm, const int baseProcID)
Return processor number in communicator (given physical processor.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static label worldComm
Default communicator (all processors)
Initialise the NamedEnum HashTable from the static list of names.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static void freeCommunicators(const bool doPstream)
Free all communicators.
const string & prefix() const
Return the prefix of the stream.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static label parent(const label communicator)
virtual void writeData(Foam::Ostream &os) const
Write.
virtual void readData(Foam::Istream &is)
Read.
void append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
registerOptSwitch("floatTransfer", bool, Foam::UPstream::floatTransfer)
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
static int baseProcNo(const label myComm, const int procID)
Return physical processor number (i.e. processor number in.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Perr(cerr, "Perr")
static const NamedEnum< commsTypes, 3 > commsTypeNames
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
Helper class for allocating/freeing communicators.
static commsTypes defaultCommsType
Default commsType.
prefixOSstream Pout(cout, "Pout")
Enum read(Istream &) const
Read a word from Istream and return the corresponding.
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict.
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
void addOptimisationObject(const char *name, simpleRegIOobject *obj)
Register optimisation switch read/write object.
addcommsTypeToOpt(const char *name)
virtual ~addcommsTypeToOpt()
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
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.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.