Mercurial > hg > cc > cirrus_work
comparison bin/_runme.sh @ 68:235004978b22
add support for multiple calls to srun with a counter
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Fri, 21 Jul 2023 11:37:47 +0100 |
parents | 316495371bbc |
children | 39c3835716f3 |
comparison
equal
deleted
inserted
replaced
67:b8d4a5ede7a3 | 68:235004978b22 |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # This runs on the compute nodes... | 2 # This runs on the compute nodes... |
3 # Args: wd [-d] [-t nthreads] [-b CMDS] [-i input] CMDS | 3 # Args: [-a i] wd [-d] [-t nthreads] [-b CMDS] [-i input] CMDS |
4 # See ug4/azure/notes.txt for documentation | 4 # See ug4/azure/notes.txt for documentation |
5 | 5 |
6 N=$SLURM_JOB_NUM_NODES | 6 N=$SLURM_JOB_NUM_NODES |
7 n=$SLURM_NTASKS | 7 n=$SLURM_NTASKS |
8 c=$SLURM_CPUS_PER_TASK | 8 c=$SLURM_CPUS_PER_TASK |
9 nodename=$SLURMD_NODENAME | 9 nodename=$SLURMD_NODENAME |
10 local=$SLURM_LOCALID | 10 local=$SLURM_LOCALID |
11 node=$SLURM_NODEID | 11 node=$SLURM_NODEID |
12 task=$SLURM_PROCID | 12 task=$SLURM_PROCID |
13 | 13 |
14 if [ "$1" = "-a" ] | |
15 then | |
16 shift | |
17 xarg="$1" | |
18 shift | |
19 else | |
20 xarg= | |
21 fi | |
22 | |
14 cd "$1" | 23 cd "$1" |
15 shift | 24 shift |
16 | 25 |
17 if [ "$1" = "-d" ] | 26 if [ "$1" = "-d" ] |
18 then | 27 then |
32 pjobs=$((c / $threadsPerTask)) | 41 pjobs=$((c / $threadsPerTask)) |
33 | 42 |
34 echo $(date) task $n.$task on $nodename:$N.$node start $pjobs jobs 1>&2 | 43 echo $(date) task $n.$task on $nodename:$N.$node start $pjobs jobs 1>&2 |
35 | 44 |
36 PATH=$W/$USER/bin:$W/shared/bin:$PATH | 45 PATH=$W/$USER/bin:$W/shared/bin:$PATH |
37 export task PATH n | 46 export task PATH n xarg |
38 | 47 |
39 if [ "$1" = "-b" ] | 48 if [ "$1" = "-b" ] |
40 then | 49 then |
41 shift | 50 shift |
42 eval "$1" | 51 eval "$1" |
43 shift | 52 shift |
44 fi | 53 fi |
54 | |
55 input="seq 1 $pjobs" # default to make sure something runs | |
45 | 56 |
46 if [ "$1" = "-i" ] | 57 if [ "$1" = "-i" ] |
47 then | 58 then |
48 shift | 59 shift |
49 input="$1" | 60 input="$1" |
57 export cmd="$1" | 68 export cmd="$1" |
58 shift | 69 shift |
59 | 70 |
60 doit () { | 71 doit () { |
61 arg="$1" | 72 arg="$1" |
62 echo $(date) start $task $PARALLEL_SEQ "|$cmd|$arg|" | 73 echo $(date) start $task $PARALLEL_SEQ "|$cmd|$xarg|$arg|" |
63 eval "$cmd" | 74 eval "$cmd" |
64 echo $(date) end $task $PARALLEL_SEQ | 75 echo $(date) end $task $PARALLEL_SEQ |
65 } | 76 } |
66 | 77 |
67 export -f doit | 78 export -f doit |