10 from mpi4py
import MPI
12 from optparse
import OptionParser
13 from optparse
import HelpFormatter
14 from optparse
import IndentedHelpFormatter
24 """Suppress helps on except rank=0.""" 31 HelpFormatter.__init__(
32 self, indent_increment, max_help_position, width, short_first)
34 def format_option(self, option):
37 def format_heading(self, heading):
40 def format_text(self, text):
43 def format_usage(self, usage):
47 options = OptionParser()
51 options.add_option(
"-t",
"--trace",
52 dest=
"trace", action=
"store_true", default=
False,
53 help=
"prints traces of invoking commands to stderr")
54 options.add_option(
"-m",
"--per-core",
55 dest=
"percore", action=
"store_true", default=
False,
56 help=
"invokes commands per core")
58 def read_commands(arg):
59 k00 = kmr0.make_kvs(value=
"cstring")
64 for i, line
in zip(range(len(lines)), lines):
65 k00.add(i,
"sh\0-c\0" + line.rstrip())
69 def identitymap(kv, kvi, kvo, i, *_data):
76 (opts, args) = options.parse_args()
79 sys.stderr.write(
"eprun needs more than one rank; abort.\n")
84 sys.stderr.write(
"Usage: python3 eprun.py [options] input-file.\n")
88 kmr0.set_option(
"trace_map_ms",
"1")
89 threading = (opts.percore)
94 k20 = read_commands(args[0])
95 k21 = k20.map_ms_commands(identitymap, nothreading=(
not threading),
96 separator_space=
False, value=
"cstring")