ENH: add convenience handling of "roots" when the slave roots are identical

- a single root entry is interpreted as being the same for all slaves
This commit is contained in:
Mark Olesen
2011-04-15 13:32:59 +02:00
parent 8687d00c2d
commit e1137fe8e2
2 changed files with 42 additions and 17 deletions

View File

@ -55,15 +55,25 @@ timestamps as before or the (linux-specific) 'inotify' system framework
- the slave processor directories have no system directory and the - the slave processor directories have no system directory and the
constant directory only contains the mesh. constant directory only contains the mesh.
- start the job in distributed mode by specifying the slave roots - start the job in distributed mode by specifying the slave roots
(so one less than the number of processors) with (so one fewer than the number of processors) with
the -roots command line option: the -roots command-line option:
mpirun -np 2 icoFoam -roots '("/tmp")' -parallel mpirun -np 4 icoFoam -roots '("/tmp" "/tmp" "/tmp")' -parallel
- the alternative to the -roots option is to have a - the alternative to the -roots option is to have a
cavity/system/decomposeParDict on the master with cavity/system/decomposeParDict on the master with
distributed yes; distributed yes;
roots ("/tmp"); roots ("/tmp" "/tmp" "/tmp");
- as a convenience for cases when the slave roots are identical,
a single root entry is interpreted as being the same for all slaves.
With the -roots command-line option, this can take one of two forms:
mpirun -np 4 icoFoam -roots '("/tmp")' -parallel
or simply
mpirun -np 4 icoFoam -roots '"/tmp"' -parallel
Details: Details:

View File

@ -549,10 +549,14 @@ Foam::argList::argList
if (options_.found("roots")) if (options_.found("roots"))
{ {
source = "'-roots' option"; source = "'-roots' option";
IStringStream str(options_["roots"]); IStringStream is(options_["roots"]);
str >> roots; roots = readList<fileName>(is);
if (roots.size() != 1)
{
dictNProcs = roots.size()+1; dictNProcs = roots.size()+1;
} }
}
else else
{ {
source = rootPath_/globalCase_/"system/decomposeParDict"; source = rootPath_/globalCase_/"system/decomposeParDict";
@ -579,6 +583,21 @@ Foam::argList::argList
} }
} }
// convenience:
// when a single root is specified, use it for all processes
if (roots.size() == 1)
{
const fileName rootName(roots[0]);
roots.setSize(Pstream::nProcs()-1, rootName);
// adjust dictNProcs for command-line '-roots' option
if (dictNProcs < 0)
{
dictNProcs = roots.size()+1;
}
}
// Check number of processors. // Check number of processors.
// nProcs => number of actual procs // nProcs => number of actual procs
// dictNProcs => number of procs specified in decompositionDict // dictNProcs => number of procs specified in decompositionDict
@ -602,11 +621,6 @@ Foam::argList::argList
// distributed data // distributed data
if (roots.size()) if (roots.size())
{ {
forAll(roots, i)
{
roots[i].expand();
}
if (roots.size() != Pstream::nProcs()-1) if (roots.size() != Pstream::nProcs()-1)
{ {
FatalError FatalError
@ -617,6 +631,11 @@ Foam::argList::argList
<< exit(FatalError); << exit(FatalError);
} }
forAll(roots, i)
{
roots[i].expand();
}
// Distribute the master's argument list (with new root) // Distribute the master's argument list (with new root)
bool hadCaseOpt = options_.found("case"); bool hadCaseOpt = options_.found("case");
for for
@ -626,11 +645,7 @@ Foam::argList::argList
slave++ slave++
) )
{ {
options_.set options_.set("case", roots[slave-1]/globalCase_);
(
"case",
fileName(roots[slave-1])/globalCase_
);
OPstream toSlave(Pstream::scheduled, slave); OPstream toSlave(Pstream::scheduled, slave);
toSlave << args_ << options_; toSlave << args_ << options_;