MCPcopy Create free account
hub / github.com/LBANN/lbann / add_parallel_command

Method add_parallel_command

python/lbann/launcher/openmpi.py:45–91  ·  view source on GitHub ↗

Add command to be executed in parallel. The command is launched with mpiexec. Parallel processes are distributed evenly amongst the compute nodes. Args: command (`str` or `Iterable` of `str`s): Command to be executed in parallel. work

(self,
                             command,
                             work_dir=None,
                             nodes=None,
                             procs_per_node=None,
                             launcher=None,
                             launcher_args=None)

Source from the content-addressed store, hash-verified

43 self.launcher_args = launcher_args
44
45 def add_parallel_command(self,
46 command,
47 work_dir=None,
48 nodes=None,
49 procs_per_node=None,
50 launcher=None,
51 launcher_args=None):
52 """Add command to be executed in parallel.
53
54 The command is launched with mpiexec. Parallel processes are
55 distributed evenly amongst the compute nodes.
56
57 Args:
58 command (`str` or `Iterable` of `str`s): Command to be
59 executed in parallel.
60 work_dir (str, optional): Working directory.
61 nodes (int, optional): Number of compute nodes.
62 procs_per_node (int, optional): Number of parallel
63 processes per compute node.
64 launcher (str, optional): mpiexec executable.
65 launcher_args (`Iterable` of `str`s, optional):
66 Command-line arguments to mpiexec.
67
68 """
69
70 # Use default values if needed
71 if work_dir is None:
72 work_dir = self.work_dir
73 if nodes is None:
74 nodes = self.nodes
75 if procs_per_node is None:
76 procs_per_node = self.procs_per_node
77 if launcher is None:
78 launcher = self.launcher
79 if launcher_args is None:
80 launcher_args = self.launcher_args
81
82 # Construct mpiexec invocation
83 args = [launcher]
84 args.extend(make_iterable(launcher_args))
85 args.extend([
86 f'-n {nodes*procs_per_node}',
87 f'--map-by ppr:{procs_per_node}:node',
88 f'-wdir {work_dir}'
89 ])
90 args.extend(make_iterable(command))
91 self.add_command(args)
92
93 def submit(self, overwrite=False):
94 """Submit batch job.

Callers

nothing calls this directly

Calls 2

make_iterableFunction · 0.90
add_commandMethod · 0.80

Tested by

no test coverage detected