Mercurial > hg > cc > cirrus_work
annotate bin/_runme.sh @ 40:316495371bbc
add lots more debugging output,
reinstate -t for thread allocation
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Wed, 05 Jul 2023 15:12:07 +0100 |
parents | e3c440666f1a |
children | 235004978b22 |
rev | line source |
---|---|
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
1 #!/bin/bash |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
2 # This runs on the compute nodes... |
40
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
3 # Args: wd [-d] [-t nthreads] [-b CMDS] [-i input] CMDS |
38 | 4 # See ug4/azure/notes.txt for documentation |
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 N=$SLURM_JOB_NUM_NODES |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 n=$SLURM_NTASKS |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 c=$SLURM_CPUS_PER_TASK |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
9 nodename=$SLURMD_NODENAME |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
10 local=$SLURM_LOCALID |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
11 node=$SLURM_NODEID |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
12 task=$SLURM_PROCID |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
13 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
14 cd "$1" |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
15 shift |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
16 |
40
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
17 if [ "$1" = "-d" ] |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
18 then |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
19 shift |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
20 debug=1 |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
21 fi |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
22 |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
23 if [ "$1" = "-t" ] |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
24 then |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
25 shift |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
26 threadsPerTask=$1 |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
27 shift |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
28 else |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
29 threadsPerTask=2 |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
30 fi |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
31 |
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
32 pjobs=$((c / $threadsPerTask)) |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
33 |
40
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
34 echo $(date) task $n.$task on $nodename:$N.$node start $pjobs jobs 1>&2 |
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
35 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
36 PATH=$W/$USER/bin:$W/shared/bin:$PATH |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
37 export task PATH n |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
38 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
39 if [ "$1" = "-b" ] |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
40 then |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
41 shift |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
42 eval "$1" |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
43 shift |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
44 fi |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
45 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
46 if [ "$1" = "-i" ] |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
47 then |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
48 shift |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
49 input="$1" |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
50 shift |
40
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
51 if [ "$debug" ] |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
52 then |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
53 echo $(date) task $n.$task input "|$input|" |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
54 fi |
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
55 fi |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
56 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
57 export cmd="$1" |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
58 shift |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
59 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
60 doit () { |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
61 arg="$1" |
40
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
62 echo $(date) start $task $PARALLEL_SEQ "|$cmd|$arg|" |
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
63 eval "$cmd" |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
64 echo $(date) end $task $PARALLEL_SEQ |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
65 } |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
66 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
67 export -f doit |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
68 |
40
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
69 if [ "$debug" ] |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
70 then |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
71 echo $(date) task $n.$task cmd "|$cmd|" doit $(type doit) |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
72 fi |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
73 |
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
74 eval "$input" | \ |
40
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
75 if [ "$debug" ] |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
76 then |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
77 tee >(cat 1>&2) |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
78 else |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
79 cat |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
80 fi | \ |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
81 if [ $pjobs -le 1 ] |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
82 then |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
83 xargs -I ^ -n 1 bash -c "doit ^" |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
84 else |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
85 parallel --line-buffer -j $pjobs doit '{}' |
316495371bbc
add lots more debugging output,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
38
diff
changeset
|
86 fi |
2
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
87 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
88 echo $(date) task $n.$task on $nodename:$N.$node end 1>&2 |
b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
89 |