46 const int maxDepth = 1024
49 if (proci >= comms.
size())
56 const auto& below = comms[proci].below();
60 os <<
nl <<
"// communication graph:" <<
nl;
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;
256 allBelow_(
std::move(allBelow)),
257 allNotBelow_(
std::move(allNotBelow))
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_);
514 (above() == comm.
above())
515 && (below() == comm.
below())
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);
Begin block [isseparator].
commsStruct() noexcept
Default construct with above == -1.
void size(const label n)
Older name for setAddressableSize.
int above() const noexcept
The procID of the processor directly above.
void printGraph(Ostream &os, int proci=0) const
Print un-directed graph in graphviz dot format.
Ostream & indent(Ostream &os)
Indent stream.
static bool usingNodeComms(const int communicator)
True if node topology-aware routines have been enabled, it is running in parallel, the starting point is the world-communicator and it is not an odd corner case (ie, all processes on one node, all processes on different nodes)
patchWriters resize(patchIds.size())
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const List< int > & allBelow() const noexcept
The procIDs of all processors below (so not just directly below)
label size() const noexcept
The number of entries.
An interval of (signed) integers defined by a start and a size.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
static int simpleTree(const int myProci, const int numProcs, DynamicList< int > &below, DynamicList< int > &allBelow)
void init(int communicator)
Reset communicator index, fill tree with empty entries.
void reset()
Reset to default constructed state.
void reset(int communicator)
Reset communicator index, clear tree entries.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static bool init(int &argc, char **&argv, const bool needsThread)
Initialisation function called from main.
virtual Ostream & endBlock()
Write end block group.
bool linear() const noexcept
Linear (flat) communication instead of tree communication.
static const commsStructList & null()
An empty structure. Used for placeholders etc.
errorManip< error > abort(error &err)
Structure for communicating between processors.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool operator==(const commsStruct &) const
const List< int > & below() const noexcept
The procIDs of the processors directly below.
OBJstream os(runTime.globalPath()/outputName)
Collection of communication structures.
bool operator!=(const commsStruct &) const
void push_back(const T &val)
Copy append an element to the end of this list.
void reset_linear(const int myProci, const int numProcs)
Reset to linear (flat) communication.
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
static void printGraph_impl(Ostream &os, const UPstream::commsStructList &comms, const int proci, int depth, const int maxDepth=1024)
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
iterator end() noexcept
Return an iterator to end traversing the UList.
int nProcs() const noexcept
The number of processors addressed by the structure.
bool empty() const noexcept
True if the list is empty.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
const UPstream::commsStruct & get(int proci) const
Get existing or create (demand-driven) entry.
A keyword and a list of tokens is an 'entry'.