Skip to content

Commit

Permalink
Print --report-bindings to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
vitduck committed Mar 26, 2022
1 parent e2fa6d5 commit b85a2b4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import subprocess

def module_list():
logging.info(f'{"Modules":<7} : {" ".join(os.environ["LOADEDMODULES"].split(os.pathsep))}')
if 'LOADEDMODULES' in os.environ:
logging.info(f'{"Modules":<7} : {" ".join(os.environ["LOADEDMODULES"].split(os.pathsep))}')

def module_purge():
cmd = subprocess.run(['modulecmd', 'python', 'purge'], stdout=subprocess.PIPE).stdout.decode('utf-8')
Expand Down
9 changes: 5 additions & 4 deletions src/gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, input='stmv.tpr', nsteps=10000, resetstep=0, nstlist=0, pin='

self.src = ['http://ftp.gromacs.org/pub/gromacs/gromacs-2021.3.tar.gz']

self.header = ['input', 'node', 'task', 'omp', 'gpu', 'perf(ns/day)', 'time(s)']
self.header = ['input', 'node', 'task', 'omp', 'gpu', 'nstlist', 'perf(ns/day)', 'time(s)']

# cmdline option
self.parser.usage = '%(prog)s -i stmv.tpr --nsteps 4000'
Expand Down Expand Up @@ -102,7 +102,8 @@ def run(self):
f'{os.path.splitext(os.path.basename(self.input))[0]}-'
f'n{self.mpi.node}-'
f't{self.mpi.task}-'
f'o{self.mpi.omp}.log' )
f'o{self.mpi.omp}-'
f'l{self.nstlist}.log' )

if self.mpi.gpu:
self.output = re.sub(r'(-o\d+)', rf'\1-g{self.mpi.gpu}', self.output, 1)
Expand All @@ -119,7 +120,7 @@ def run(self):
os.remove('ener.edr')

def parse(self):
key = ",".join(map(str, [self.mpi.node, self.mpi.task, self.mpi.omp, self.gpu]))
key = ",".join(map(str, [self.mpi.node, self.mpi.task, self.mpi.omp, self.gpu, self.nstlist]))

with open(self.output, 'r') as fh:
for line in fh:
Expand Down Expand Up @@ -161,7 +162,7 @@ def mdrun(self):
def parse(self):
key = ",".join(map(str, [
os.path.basename(self.input),
self.mpi.node, self.mpi.task, self.mpi.omp, self.mpi.gpu ]))
self.mpi.node, self.mpi.task, self.mpi.omp, self.mpi.gpu, self.nstlist ]))

with open('md.log', 'r') as fh:
for line in fh:
Expand Down
33 changes: 16 additions & 17 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,22 @@ def sync(nodelist=[]):
def syscmd(cmd, output=None):
logging.debug(cmd)

pout = ''
pipe = subprocess.run(cmd, shell=True, text=True, capture_output=True)

try:
pout = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode('utf-8').rstrip()
except subprocess.CalledProcessError as e:
# Work around required for QE/6.8
# https://forums.developer.nvidia.com/t/unusual-behavior/136392/2
if e.returncode == 2:
if output:
with open(output, "w") as output_fh:
output_fh.write(f'{e.stdout.decode("utf-8").rstrip()}')
else:
logging.error(f'{e.stderr.decode("utf-8").rstrip()}')
sys.exit()
else:
if output:
# Work around required for QE/6.8
# https://forums.developer.nvidia.com/t/unusual-behavior/136392/2
if pipe.returncode == 0 or pipe.returncode == 2:
if output:
with open(output, "w") as output_fh:
output_fh.write(pout)
# openmpi --report-bindings
if pipe.stderr:
for line in pipe.stderr.splitlines():
if re.search('^\[.+?\] MCW', line):
logging.error(line)

output_fh.write(pipe.stdout)
else:
return pout
return pipe.stdout
else:
logging.error(pipe.stderr)
sys.exit()

0 comments on commit b85a2b4

Please sign in to comment.