mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: consolidate UPstream::commsStruct code
- make sizing of commsStruct List demand-driven as well for more robustness, fewer unneeded allocations. - fix potential latent bug with allBelow/allNotBelow for proc 0 (linear communication). ENH: remove unused/unusable UPstream::communicator optional parameter - had constructor option to avoid constructing the MPI backend, but this is not useful and inconsistent with what the reset or destructor expect. STYLE: local use of UPstream::communicator - automatically frees communicator when it leaves scope
This commit is contained in:
@ -64,6 +64,7 @@ int main(int argc, char *argv[])
|
||||
argList::noBanner();
|
||||
argList::noCheckProcessorDirectories();
|
||||
argList::addBoolOption("verbose", "Set debug level");
|
||||
argList::addBoolOption("print-tree", "Report tree(s) as graph");
|
||||
argList::addBoolOption("comm-split", "Test simple comm split");
|
||||
argList::addBoolOption("host-comm", "Test DIY host-comm split");
|
||||
|
||||
@ -81,6 +82,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool optPrintTree = args.found("print-tree");
|
||||
|
||||
Info<< nl
|
||||
<< "parallel:" << UPstream::parRun()
|
||||
<< "nProcs = " << UPstream::nProcs()
|
||||
@ -102,6 +105,13 @@ int main(int argc, char *argv[])
|
||||
labelList subRanks;
|
||||
UPstream::communicator newComm;
|
||||
|
||||
|
||||
if (UPstream::parRun() && optPrintTree)
|
||||
{
|
||||
Info<< "comms: " << UPstream::whichCommunication() << endl;
|
||||
UPstream::printCommTree(UPstream::commWorld());
|
||||
}
|
||||
|
||||
if (!args.found("comm-split") && !args.found("host-comm"))
|
||||
{
|
||||
#if 1
|
||||
@ -377,12 +387,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// From world to hostMaster
|
||||
const label hostMasterComm =
|
||||
UPstream::allocateCommunicator
|
||||
(
|
||||
UPstream::commGlobal(),
|
||||
subRanks,
|
||||
true
|
||||
);
|
||||
UPstream::allocateCommunicator(UPstream::commGlobal(), subRanks);
|
||||
|
||||
|
||||
const label myHostId =
|
||||
@ -400,12 +405,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// The intra-host ranks
|
||||
const label hostComm =
|
||||
UPstream::allocateCommunicator
|
||||
(
|
||||
UPstream::commGlobal(),
|
||||
subRanks,
|
||||
true
|
||||
);
|
||||
UPstream::allocateCommunicator(UPstream::commGlobal(), subRanks);
|
||||
|
||||
Pout<< nl << "[manual split]" << nl
|
||||
<< nl << "Host comm with "
|
||||
@ -419,8 +419,8 @@ int main(int argc, char *argv[])
|
||||
<< " sub-rank:" << UPstream::is_subrank(hostMasterComm)
|
||||
<< nl;
|
||||
|
||||
UPstream::freeCommunicator(hostMasterComm, true);
|
||||
UPstream::freeCommunicator(hostComm, true);
|
||||
UPstream::freeCommunicator(hostMasterComm);
|
||||
UPstream::freeCommunicator(hostComm);
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
Reference in New Issue
Block a user