MISC: additional -repeat option for testing MPI_Comm leakage (#1598)

This commit is contained in:
Mark Olesen
2023-06-12 13:05:23 +02:00
parent 60fc3906dc
commit 1c9ea038d0

View File

@ -121,17 +121,22 @@ scalar sumReduce
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noCheckProcessorDirectories();
argList::addVerboseOption();
argList::addOption("repeat", "count");
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H"
const label repeat = args.getOrDefault<label>("repeat", 1);
const int optVerbose = args.verbose();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Allocate a communicator // Allocate a communicator
label n = Pstream::nProcs(UPstream::worldComm); label n = Pstream::nProcs(UPstream::worldComm);
DynamicList<label> bottom; DynamicList<label> bottom(n/2);
DynamicList<label> top; DynamicList<label> top(n/2);
for (label i = 0; i < n/2; i++) for (label i = 0; i < n/2; i++)
{ {
@ -142,20 +147,27 @@ int main(int argc, char *argv[])
top.append(i); top.append(i);
} }
Info<< "repeating: " << repeat << " times" << endl;
if (optVerbose || repeat == 1)
{
//Pout<< "bottom:" << bottom << endl; //Pout<< "bottom:" << bottom << endl;
Pout<< "top :" << top << endl; Pout<< "top :" << top << endl;
}
for (label count = 0; count < repeat; ++count)
scalar localValue = 111*UPstream::myProcNo(UPstream::worldComm); {
Pout<< "localValue :" << localValue << endl;
label comm = UPstream::allocateCommunicator(UPstream::worldComm, top); label comm = UPstream::allocateCommunicator(UPstream::worldComm, top);
Pout<< "allocated comm :" << comm << endl; scalar localValue = 111*UPstream::myProcNo(UPstream::worldComm);
Pout<< "comm myproc :" << Pstream::myProcNo(comm)
<< endl;
if (optVerbose || (repeat == 1 && count == 0))
{
Pout<< "localValue :" << localValue << endl;
Pout<< "allocated comm :" << comm
<< " proci :" << UPstream::myProcNo(comm) << endl;
}
if (Pstream::myProcNo(comm) != -1) if (Pstream::myProcNo(comm) != -1)
{ {
@ -166,13 +178,18 @@ int main(int argc, char *argv[])
UPstream::msgType(), UPstream::msgType(),
comm comm
); );
if (optVerbose || (repeat == 1 && count == 0))
{
Pout<< "sum :" << sum << endl; Pout<< "sum :" << sum << endl;
} }
}
UPstream::freeCommunicator(comm); UPstream::freeCommunicator(comm);
}
Pout<< "End\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }