diff --git a/etc/controlDict b/etc/controlDict index 77a630c3fb8cfd1635a0d22245abc31546adfe95..37ebba2b46e81fcb5e06591d6edd6b6b0626e7e2 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -38,21 +38,24 @@ InfoSwitches // The default ASCII write precision writePrecision 6; - // Enable job info - writeJobInfo 0; - writeDictionaries 0; writeOptionalEntries 0; // Write lagrangian "positions" file in v1706 format (at earlier) writeLagrangianPositions 0; - // Report list of slaves/pids used (parallel) - writeSlaves 1; + // Report hosts used (parallel) + // - 0 = none + // - 1 = per-host-count, but unsorted + // - 2 = long output of "slave.pid" ... + writeHosts 1; // Report list of roots used (parallel) writeRoots 1; + // Enable job info + writeJobInfo 0; + // Allow profiling allowProfiling 1; diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 20d4bffbc7174611340fdd006ee6444d47f4923a..d832a6d7f257549eb1b0ee0e5cf26fc5e5007976 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -102,6 +102,53 @@ Foam::argList::initValidTables::initValidTables() Foam::argList::initValidTables dummyInitValidTables; +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Counted per machine name +// Does not include any sorting since we wish to know the ordering according to +// mpi rank. +// +// Always include the master too. +// This provides a better overview of the subscription +static void printHostsSubscription(const UList<string>& slaveProcs) +{ + Info<< "Hosts :" << nl << "(" << nl; + + std::string prev = hostName(); + int count = 1; + + for (const auto& str : slaveProcs) + { + const auto dot = str.rfind('.'); + const std::string curr(std::move(str.substr(0, dot))); + + if (prev != curr) + { + if (count) + { + // Finish previous + Info<<" (" << prev.c_str() << " " << count << ")" << nl; + count = 0; + } + + prev = std::move(curr); + } + ++count; + } + + if (count) + { + // Finished last one + Info<<" (" << prev.c_str() << " " << count << ")" << nl; + } + + Info<< ")" << nl; +} + +} // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -931,6 +978,7 @@ void Foam::argList::parse } stringList slaveProcs; + const int writeHostsSwitch = debug::infoSwitch("writeHosts", 1); // Collect slave machine/pid, and check that the build is identical if (parRunControl_.parRun()) @@ -981,8 +1029,9 @@ void Foam::argList::parse // Keep or discard slave and root information for reporting: if (Pstream::master() && parRunControl_.parRun()) { - if (!debug::infoSwitch("writeSlaves", 1)) + if (!writeHostsSwitch) { + // Clear here to ensures it doesn't show in the jobInfo slaveProcs.clear(); } if (!debug::infoSwitch("writeRoots", 1)) @@ -1000,7 +1049,16 @@ void Foam::argList::parse { if (slaveProcs.size()) { - Info<< "Slaves : " << slaveProcs << nl; + if (writeHostsSwitch == 1) + { + // Compact output (see etc/controlDict) + printHostsSubscription(slaveProcs); + } + else + { + // Full output of "slave.pid" + Info<< "Slaves : " << slaveProcs << nl; + } } if (roots.size()) {