ENH: print node/topology information in human-readable form at startup

This commit is contained in:
Mark Olesen 2025-02-21 10:09:26 +01:00
parent 533d3b58f8
commit d655c2d343
4 changed files with 91 additions and 13 deletions

View File

@ -85,7 +85,8 @@ int main(int argc, char *argv[])
if (UPstream::parRun() && optPrintTree)
{
Info<< "comms: " << UPstream::whichCommunication() << endl;
Info<< "comms: "
<< UPstream::whichCommunication(UPstream::worldComm) << nl;
UPstream::printCommTree(UPstream::commWorld());
}

View File

@ -58,6 +58,58 @@ Foam::UPstream::commsTypeNames
});
// * * * * * * * * * * * * * Controls Information * * * * * * * * * * * * * //
void Foam::UPstream::printNodeCommsControl(Ostream& os)
{
if (UPstream::nodeCommsControl_ > 0)
{
if (UPstream::usingNodeComms(UPstream::worldComm))
{
os << "on [";
}
else
{
os << "off [";
}
if (UPstream::nodeCommsMin_ > 2)
{
os << "min=" << UPstream::nodeCommsMin_ << ",";
}
os << "type=";
// 1: split by hostname [default]
// 2: split by shared
// >=4: (debug/manual) split with given number per node
if (UPstream::nodeCommsControl_ >= 4)
{
os << UPstream::nodeCommsControl_;
}
else if (UPstream::nodeCommsControl_ == 2)
{
os << "shared";
}
else
{
os << "host";
}
os << "]";
}
else
{
os << "disabled";
}
os << " (" << UPstream::nProcs(UPstream::worldComm) << " ranks, "
<< UPstream::numNodes() << " nodes)";
}
void Foam::UPstream::printTopoControl(Ostream& os)
{
os << "none";
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::UPstream::setParRun(const label nProcs, const bool haveThreads)
@ -789,6 +841,17 @@ registerOptSwitch
);
int Foam::UPstream::topologyControl_
(
Foam::debug::optimisationSwitch("topoControl", 0)
);
registerOptSwitch
(
"topoControl",
int,
Foam::UPstream::topologyControl_
);
bool Foam::UPstream::floatTransfer
(
Foam::debug::optimisationSwitch("floatTransfer", 0)

View File

@ -404,6 +404,15 @@ public:
// >= 3 : when there are more than N nodes
static int nodeCommsMin_;
//- Selection of topology-aware routines
static int topologyControl_;
//- Test for selection of given topology-aware routine (bitmask)
static bool usingTopoControl(int routine = 0) noexcept
{
return static_cast<bool>(topologyControl_ & routine);
}
//- Should compact transfer be used in which floats replace doubles
//- reducing the bandwidth requirement at the expense of some loss
//- in accuracy
@ -757,6 +766,15 @@ public:
);
// Information
//- Report the node-communication settings
static void printNodeCommsControl(Ostream& os);
//- Report the topology routines settings
static void printTopoControl(Ostream& os);
// Requests (non-blocking comms).
// Pending requests are usually handled as an internal (global) list,
// since this simplifies the overall tracking and provides a convenient

View File

@ -2094,21 +2094,17 @@ void Foam::argList::parse
}
}
Info<< "Pstream initialized with:" << nl
<< " node communication : ";
if (UPstream::nodeCommsControl_ > 0)
Info<< "Pstream initialized with:" << nl;
{
Info<< Switch::name(UPstream::usingNodeComms())
<< " [min=" << UPstream::nodeCommsMin_
<< ", type=" << UPstream::nodeCommsControl_
<< "]";
Info<< " node communication : ";
UPstream::printNodeCommsControl(Info);
Info<< nl;
}
else
{
Info<< "disabled";
Info<< " topology controls : ";
UPstream::printTopoControl(Info);
Info<< nl;
}
Info<< " (" << UPstream::nProcs() << " ranks, "
<< UPstream::numNodes() << " nodes)" << nl;
if (UPstream::floatTransfer)
{
@ -2128,7 +2124,7 @@ void Foam::argList::parse
const auto& commsType =
UPstream::commsTypeNames[UPstream::defaultCommsType];
Info<< " nonBlockingExchange: "
Info<< " consensus exchange : "
<< UPstream::nProcsNonblockingExchange
<< " (tuning: " << UPstream::tuning_NBX_ << ')' << nl
<< " exchange algorithm : "