50 void Foam::UPstream::setParRun(
const label nProcs,
const bool haveThreads)
62 <<
"problem : comm:" << comm
82 <<
"problem : comm:" << comm
98 List<commsStruct> linearCommunication(nProcs);
107 linearCommunication[0] = commsStruct
117 for (
label procID = 1; procID < nProcs; procID++)
119 linearCommunication[procID] = commsStruct
128 return linearCommunication;
132 void Foam::UPstream::collectReceives
135 const List<DynamicList<label>>& receives,
136 DynamicList<label>& allReceives
141 const DynamicList<label>& myChildren = receives[procID];
143 forAll(myChildren, childI)
145 allReceives.append(myChildren[childI]);
146 collectReceives(myChildren[childI], receives, allReceives);
184 while ((1 << nLevels) < nProcs)
189 List<DynamicList<label>> receives(nProcs);
197 for (
label level = 0; level < nLevels; level++)
200 while (receiveID < nProcs)
203 label sendID = receiveID + childOffset;
207 receives[receiveID].append(sendID);
208 sends[sendID] = receiveID;
220 List<DynamicList<label>> allReceives(nProcs);
221 for (
label procID = 0; procID < nProcs; procID++)
223 collectReceives(procID, receives, allReceives[procID]);
227 List<commsStruct> treeCommunication(nProcs);
229 for (
label procID = 0; procID < nProcs; procID++)
231 treeCommunication[procID] = commsStruct
236 receives[procID].shrink(),
237 allReceives[procID].shrink()
240 return treeCommunication;
246 const label parentIndex,
252 if (!freeComms_.empty())
254 index = freeComms_.pop();
259 index = parentCommunicator_.size();
261 myProcNo_.append(-1);
263 parentCommunicator_.append(-1);
270 Pout<<
"Communicators : Allocating communicator " << index <<
endl
271 <<
" parent : " << parentIndex <<
endl
272 <<
" procs : " << subRanks <<
endl
277 myProcNo_[index] = 0;
280 procIndices_[index].setSize(subRanks.
size());
281 forAll(procIndices_[index], i)
283 procIndices_[index][i] = subRanks[i];
286 if (i >= 1 && subRanks[i] <= subRanks[i-1])
289 <<
"subranks not sorted : " << subRanks
290 <<
" when allocating subcommunicator from parent "
295 parentCommunicator_[index] = parentIndex;
297 linearCommunication_[index] = calcLinearComm(procIndices_[index].size());
298 treeCommunication_[index] = calcTreeComm(procIndices_[index].size());
301 if (doPstream && parRun())
303 allocatePstreamCommunicator(parentIndex, index);
324 if (doPstream && parRun())
352 int procID = myProcID;
355 while (parent(comm) != -1)
358 procID = parentRanks[procID];
368 const List<int>& parentRanks = procID(myComm);
369 label parentComm = parent(myComm);
371 if (parentComm == -1)
373 return findIndex(parentRanks, baseProcID);
377 label parentRank = procNo(parentComm, baseProcID);
378 return findIndex(parentRanks, parentRank);
386 const label currentComm,
387 const int currentProcID
391 return procNo(myComm, physProcID);
397 bool Foam::UPstream::parRun_(
false);
399 bool Foam::UPstream::haveThreads_(
false);
409 int Foam::UPstream::msgType_(1);
413 Foam::UPstream::linearCommunication_(10);
416 Foam::UPstream::treeCommunication_(10);
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(1, Foam::label(0)), false)
#define forAll(list, i)
Loop across all elements in list.
A LIFO stack based on a singly-linked list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
Initialise the NamedEnum HashTable from the static list of names.
Helper class for allocating/freeing communicators.
Inter-processor communications stream.
static bool haveThreads()
Have support for threads.
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 void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
static bool floatTransfer
Should compact transfer be used in which floats replace doubles.
static List< int > & procID(label communicator)
Process ID of given process index.
static const NamedEnum< commsTypes, 3 > commsTypeNames
static label worldComm
Default communicator (all processors)
static label parent(const label communicator)
static int nProcsSimpleSum
Number of processors at which the sum algorithm changes from linear.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
static label procNo(const label comm, const int baseProcID)
Return processor number in communicator (given physical processor.
static commsTypes defaultCommsType
Default commsType.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static int baseProcNo(const label myComm, const int procID)
Return physical processor number (i.e. processor number in.
const string & prefix() const
Return the prefix of the stream.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int optimisationSwitch(const char *name, const int defaultValue=0)
Lookup optimisation switch or add default value.
Enum namedEnumOptimisationSwitch(const char *name, const NamedEnum< Enum, nEnum > &enumNames, const Enum defaultValue)
Lookup optimisation switch or add default value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
prefixOSstream Perr(cerr, "Perr")
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
defineTypeNameAndDebug(combustionModel, 0)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void offset(label &lst, const label o)