Skip to content

Commit fbfdc2d

Browse files
committed
ENH: Provide base interface for MPI capable command line software.
1 parent 5d11fbd commit fbfdc2d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

nipype/interfaces/base.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,29 @@ def _gen_filename(self, name):
12561256
def _gen_outfilename(self):
12571257
raise NotImplementedError
12581258

1259+
class MpiCommandLineInputSpec(CommandLineInputSpec):
1260+
use_mpi = traits.Bool(False,
1261+
desc="Whether or not to run the command with mpiexec",
1262+
usedefault=True)
1263+
n_procs = traits.Int(desc="Num processors to specify to mpiexec. Do not "
1264+
"specify if this is managed externally (e.g. through "
1265+
"SGE)")
1266+
1267+
1268+
class MpiCommandLine(CommandLine):
1269+
input_spec = MpiCommandLineInputSpec
1270+
1271+
@property
1272+
def cmdline(self):
1273+
"""Adds 'mpiexec' to begining of command"""
1274+
result = []
1275+
if self.inputs.use_mpi:
1276+
result.append('mpiexec')
1277+
if self.inputs.n_procs:
1278+
result.append('-n %d' % self.inputs.n_procs)
1279+
result.append(super(MpiCommandLine, self).cmdline)
1280+
return ' '.join(result)
1281+
12591282
class SEMLikeCommandLine(CommandLine):
12601283
"""By default in SEM derived interface all outputs have corresponding inputs.
12611284
However, some SEM commands create outputs that are not defined in the XML.

0 commit comments

Comments
 (0)