46 const int maxDepth = 1024
49 if (proci >= comms.
size())
56 const auto& below = comms[proci].below();
60 os <<
nl <<
"// communication graph:" <<
nl;
61 os.beginBlock(
"graph");
86 auto emit_range = [&]()
103 for (
const auto nbrProci : below)
105 const bool terminal = comms[nbrProci].below().
empty();
110 && (!
range.empty() && (
range.max()+1 == nbrProci))
123 range.reset(nbrProci, 1);
140 if (depth >= maxDepth && (proci != 0))
145 for (
const auto nbrProci : below)
154 os <<
"// end graph" <<
nl;
205 for (
int mod = 2, step = 1; step < numProcs; step = mod)
212 above = myProci - (myProci % mod);
219 int i = myProci + step;
220 i < numProcs && i < myProci + mod;
228 int i = myProci + step;
229 i < numProcs && i < myProci + mod;
255 below_(std::move(
below)),
273 allNotBelow_(numProcs - allBelow.size() - 1)
278 isNotBelow[myProcID] =
false;
283 isNotBelow[proci] =
false;
288 for (
int proci = 0; proci < numProcs; ++proci)
290 if (isNotBelow[proci])
292 allNotBelow_[nNotBelow++] = proci;
296 if (nNotBelow != allNotBelow_.size())
299 <<
"Problem: " << nNotBelow <<
" != " << allNotBelow_.size() <<
nl
328 return (1 +
int(allBelow_.size() + allNotBelow_.size()));
337 allNotBelow_.clear();
356 std::iota(below.
begin(), below.
end(), 1);
371 const int communicator
377 reset_linear(myProci, numProcs);
385 DynamicList<int> below;
386 DynamicList<int> allBelow;
412 static std::unique_ptr<commsStructList> singleton;
416 singleton = std::make_unique<commsStructList>();
430 const auto len = tree_.size();
481 if (tree_.size() < numProcs)
488 if (
entry.nProcs() != numProcs)
495 .reset_linear(proci, numProcs);
499 const_cast<UPstream::commsStruct&
>(entry)
500 .
reset(proci, numProcs, comm_);
530 os << comm.above() <<
nl;
531 os <<
" "; comm.below().writeList(
os) <<
nl;
532 os <<
" "; comm.allBelow().writeList(
os) <<
nl;
533 os <<
" "; comm.allNotBelow().writeList(
os);
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void push_back(const T &val)
Copy append an element to the end of this list.
An interval of (signed) integers defined by a start and a size.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of 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...
iterator begin() noexcept
Return an iterator to begin traversing the UList.
iterator end() noexcept
Return an iterator to end traversing the UList.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Collection of communication structures.
void init(int communicator)
Reset communicator index, fill tree with empty entries.
const UPstream::commsStruct & get(int proci) const
Get existing or create (demand-driven) entry.
bool linear() const noexcept
Linear (flat) communication instead of tree communication.
bool empty() const noexcept
True if the list is empty.
void reset(int communicator)
Reset communicator index, clear tree entries.
static const commsStructList & null()
An empty structure. Used for placeholders etc.
label size() const noexcept
The number of entries.
void printGraph(Ostream &os, int proci=0) const
Print un-directed graph in graphviz dot format.
Structure for communicating between processors.
bool operator!=(const commsStruct &) const
int nProcs() const noexcept
The number of processors addressed by the structure.
void reset_linear(const int myProci, const int numProcs)
Reset to linear (flat) communication.
const List< int > & below() const noexcept
The procIDs of the processors directly below.
bool operator==(const commsStruct &) const
commsStruct() noexcept
Default construct with above == -1.
const List< int > & allNotBelow() const noexcept
The procIDs of all processors not below myProcNo. The inverse set of allBelow without myProcNo.
void reset()
Reset to default constructed state.
int above() const noexcept
The procID of the processor directly above.
const List< int > & allBelow() const noexcept
The procIDs of all processors below (so not just directly below).
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
static bool init(int &argc, char **&argv, const bool needsThread)
Initialisation function called from main.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static bool usingNodeComms(const int communicator)
True if node topology-aware routines have been enabled, it is running in parallel,...
A keyword and a list of tokens is an 'entry'.
@ BEGIN_BLOCK
Begin block [isseparator].
@ END_BLOCK
End block [isseparator].
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
patchWriters resize(patchIds.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
static int simpleTree(const int myProci, const int numProcs, DynamicList< int > &below, DynamicList< int > &allBelow)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Ostream & indent(Ostream &os)
Indent stream.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
static void printGraph_impl(Ostream &os, const UPstream::commsStructList &comms, const int proci, int depth, const int maxDepth=1024)
constexpr char nl
The newline '\n' character (0x0a).