Skip to content

Commit 1b91d6f

Browse files
authored
Merge pull request #862 from DebRez/topic/Launcher_fix
Sets np correctly
2 parents 980e6b7 + 41070fc commit 1b91d6f

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

pylib/Tools/Launcher/SLURM.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def execute(self, log, keyvals, testDef):
169169
status = self.allocateCluster(log, cmds, testDef)
170170
if 0 != status:
171171
self.resetPaths(log, testDef)
172+
# something went wrong - error is in the log
172173
return
173174

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

188-
# execute the tests
189-
self.runTests(log, cmdargs, cmds, testDef)
190-
191-
# Deallocate cluster
192-
self.deallocateCluster(log, cmds, testDef)
193-
194-
# reset our paths and return us to our cwd
195-
self.resetPaths(log, testDef)
196-
197189
# handle case where srun is used instead of mpirun for number of processes (np)
198190
if cmds['command'] == 'srun':
199191
num_tasks = None
200192
num_nodes = None
201193
num_tasks_per_node = None
202-
203194
if '-n ' in cmds['options']:
204195
num_tasks = str(cmds['options'].split('-n ')[1].split(' ')[0])
205196
if '--ntasks=' in cmds['options']:
@@ -214,16 +205,17 @@ def execute(self, log, keyvals, testDef):
214205
num_nodes = str(len(cmds['options'].split('--nodelist=')[1].split(' ')[0].split(',')))
215206
if '--ntasks-per-node=' in cmds['options']:
216207
num_tasks_per_node = str(cmds['options'].split('--ntasks-per-node=')[1].split(' ')[0])
217-
218208
if num_tasks is not None:
219-
log['np'] = num_tasks
209+
cmds['np'] = num_tasks
210+
220211
elif num_nodes is not None and num_tasks_per_node is not None:
221212
try:
222-
log['np'] = str(int(num_tasks_per_node)*int(num_nodes))
213+
cmds['np'] = str(int(num_tasks_per_node)*int(num_nodes))
223214
except:
224-
log['np'] = None
215+
cmds['np'] = None
225216
else:
226-
log['np'] = None
217+
cmds['np'] = None
218+
227219
elif cmds['command'] == 'mpiexec' or cmds['command'] == 'mpiexec.hydra' or cmds['command'] == 'mpirun':
228220
num_tasks = None
229221
num_nodes = None
@@ -241,20 +233,24 @@ def execute(self, log, keyvals, testDef):
241233
num_tasks_per_node = str(cmds['options'].split('-grr ')[1].split(' ')[0])
242234
if '-perhost ' in cmds['options']:
243235
num_tasks_per_node = str(cmds['options'].split('-perhost ')[1].split(' ')[0])
244-
245236
if num_tasks is not None:
246-
log['np'] = num_tasks
237+
cmds['np'] = num_tasks
247238
elif num_nodes is not None and num_tasks_per_node is not None:
248239
try:
249-
log['np'] = str(int(num_tasks_per_node)*int(num_nodes))
240+
cmds['np'] = str(int(num_tasks_per_node)*int(num_nodes))
250241
except:
251-
log['np'] = None
242+
cmds['np'] = None
252243
else:
253-
log['np'] = None
254-
else:
255-
try:
256-
log['np'] = cmds['np']
257-
except KeyError:
258-
log['np'] = None
244+
cmds['np'] = None
245+
246+
# execute the tests
247+
self.runTests(log, cmdargs, cmds, testDef)
248+
249+
# Deallocate cluster
250+
self.deallocateCluster(log, cmds, testDef)
251+
252+
# reset our paths and return us to our cwd
253+
self.resetPaths(log, testDef)
254+
259255

260256
return

0 commit comments

Comments
 (0)