Skip to content

Commit

Permalink
Sets np correctly
Browse files Browse the repository at this point in the history
Determines np before tests are run then assigns np correctly in LauncherMTTTools.py.

Fixes #852

Signed-off-by: Deb Rezanka <[email protected]>
  • Loading branch information
DebRez committed Sep 3, 2019
1 parent 980e6b7 commit 41070fc
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions pylib/Tools/Launcher/SLURM.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def execute(self, log, keyvals, testDef):
status = self.allocateCluster(log, cmds, testDef)
if 0 != status:
self.resetPaths(log, testDef)
# something went wrong - error is in the log
return

# Add support for srun in --no-shell allocation
Expand All @@ -185,21 +186,11 @@ def execute(self, log, keyvals, testDef):
jobid = int(subprocess.check_output(['squeue', '--noheader', '--format', '%i', '--name', jobname]))
cmdargs.append('--jobid=%d' % (jobid))

# execute the tests
self.runTests(log, cmdargs, cmds, testDef)

# Deallocate cluster
self.deallocateCluster(log, cmds, testDef)

# reset our paths and return us to our cwd
self.resetPaths(log, testDef)

# handle case where srun is used instead of mpirun for number of processes (np)
if cmds['command'] == 'srun':
num_tasks = None
num_nodes = None
num_tasks_per_node = None

if '-n ' in cmds['options']:
num_tasks = str(cmds['options'].split('-n ')[1].split(' ')[0])
if '--ntasks=' in cmds['options']:
Expand All @@ -214,16 +205,17 @@ def execute(self, log, keyvals, testDef):
num_nodes = str(len(cmds['options'].split('--nodelist=')[1].split(' ')[0].split(',')))
if '--ntasks-per-node=' in cmds['options']:
num_tasks_per_node = str(cmds['options'].split('--ntasks-per-node=')[1].split(' ')[0])

if num_tasks is not None:
log['np'] = num_tasks
cmds['np'] = num_tasks

elif num_nodes is not None and num_tasks_per_node is not None:
try:
log['np'] = str(int(num_tasks_per_node)*int(num_nodes))
cmds['np'] = str(int(num_tasks_per_node)*int(num_nodes))
except:
log['np'] = None
cmds['np'] = None
else:
log['np'] = None
cmds['np'] = None

elif cmds['command'] == 'mpiexec' or cmds['command'] == 'mpiexec.hydra' or cmds['command'] == 'mpirun':
num_tasks = None
num_nodes = None
Expand All @@ -241,20 +233,24 @@ def execute(self, log, keyvals, testDef):
num_tasks_per_node = str(cmds['options'].split('-grr ')[1].split(' ')[0])
if '-perhost ' in cmds['options']:
num_tasks_per_node = str(cmds['options'].split('-perhost ')[1].split(' ')[0])

if num_tasks is not None:
log['np'] = num_tasks
cmds['np'] = num_tasks
elif num_nodes is not None and num_tasks_per_node is not None:
try:
log['np'] = str(int(num_tasks_per_node)*int(num_nodes))
cmds['np'] = str(int(num_tasks_per_node)*int(num_nodes))
except:
log['np'] = None
cmds['np'] = None
else:
log['np'] = None
else:
try:
log['np'] = cmds['np']
except KeyError:
log['np'] = None
cmds['np'] = None

# execute the tests
self.runTests(log, cmdargs, cmds, testDef)

# Deallocate cluster
self.deallocateCluster(log, cmds, testDef)

# reset our paths and return us to our cwd
self.resetPaths(log, testDef)


return

0 comments on commit 41070fc

Please sign in to comment.