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;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,7 +59,7 @@ void printRecvCount_gatherList
|
||||
labelList nMesg;
|
||||
labelList nRecv;
|
||||
|
||||
if (UPstream::parRun() && np > 1 && Pstream::master(comm))
|
||||
if (UPstream::parRun() && np > 1 && UPstream::master(comm))
|
||||
{
|
||||
nMesg.resize(np, Zero);
|
||||
nRecv.resize(np, Zero);
|
||||
@ -99,7 +99,7 @@ void printSendCount_scatterList
|
||||
labelList nMesg;
|
||||
labelList nSend;
|
||||
|
||||
if (UPstream::parRun() && np > 1 && Pstream::master(comm))
|
||||
if (UPstream::parRun() && np > 1 && UPstream::master(comm))
|
||||
{
|
||||
nMesg.resize(np, Zero);
|
||||
nSend.resize(np, Zero);
|
||||
@ -139,7 +139,7 @@ void printWidths
|
||||
labelList maxBelow;
|
||||
labelList maxNotBelow;
|
||||
|
||||
if (UPstream::parRun() && np > 1 && Pstream::master(comm))
|
||||
if (UPstream::parRun() && np > 1 && UPstream::master(comm))
|
||||
{
|
||||
maxBelow.resize(np, Zero);
|
||||
maxNotBelow.resize(np, Zero);
|
||||
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Info<< "allComms: " << comms << nl;
|
||||
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
OFstream os("treeComm.dot");
|
||||
|
||||
@ -204,9 +204,9 @@ int main(int argc, char *argv[])
|
||||
printConnection(os, 0, myComm.below());
|
||||
// Pout<< flatOutput(myComm.allBelow()) << nl;
|
||||
|
||||
for (const int proci : Pstream::subProcs())
|
||||
for (const int proci : UPstream::subProcs())
|
||||
{
|
||||
IPstream fromProc(Pstream::commsTypes::scheduled, proci);
|
||||
IPstream fromProc(UPstream::commsTypes::scheduled, proci);
|
||||
labelList below(fromProc);
|
||||
|
||||
printConnection(os, proci, below);
|
||||
|
||||
Reference in New Issue
Block a user