/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/nikhef-torque-prologue-epilogue/mom_priv/prologue
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/nikhef-torque-prologue-epilogue/mom_priv/prologue

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2678 - (show annotations) (download)
Fri Oct 11 10:57:20 2013 UTC (8 years, 3 months ago) by ronalds
File size: 1418 byte(s)
use /bin/bash and full hostname
1 #!/bin/bash
2
3 # Torque prologue script to limit the processes in a job to the assigned
4 # CPU list
5 # Note: this assumes that the number of CPUs in the system matches the number
6 # of job slots that Torque considers on the node
7 # This assumption is not verified!
8 #
9 # Author: Ronald Starink < ronalds AT nikhef.nl >
10 #
11 # This prologue script is invoked with arguments
12 # <id> <user> <group> <name> <resource-reqs> <queue> <account>
13
14 jobid=$(echo $1 | sed -re 's/\[|\]//g')
15
16 # set debug=1 to write debug output to $debugfile
17 debug=1
18 debugfile=/tmp/prologue.log
19
20 # Determine the job slot(s)
21 # The result is a single number or comma-separated list of numbers
22 # that will be used as the CPU numbers which can be used by the job
23 slot=$(pbsnodes -a $(hostname -f) | \
24 perl -ne 'if ( m/^\s*jobs/ ) { s/\[|\]//g ; @a = m!(\d+)/'$jobid'!g ; print join(",",@a)."\n"; }')
25 [ $debug -gt 0 ] && echo jobid=$jobid, slot=$slot >> $debugfile
26
27 # Determine the ID of the parent process of this prologue script,
28 # which is the MOM for the job
29 ppid=$(ps -o ppid -p $$ | sed -n 's/^[ ]*\([0-9][0-9]*\)[ ]*$/\1/p' 2>> $debugfile )
30
31 # Assign the CPU(s) to the MOM of the current job
32 # This setting affects all child processes that will be started later
33 [ $debug -gt 0 ] && echo Setting taskset to CPU $slot for pid=$ppid >> $debugfile
34 res=$(taskset -cp $slot $ppid 2>&1)
35 [ $debug -gt 0 ] && echo $res >> $debugfile
36
37 exit 0

Properties

Name Value
svn:executable *

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28