-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathrun.sh
298 lines (273 loc) · 8.53 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#!/bin/bash -eu
###############################################################################
# Helper functions
###############################################################################
function quit {
echo "$1" >&2
exit 1
}
###############################################################################
# Derived options
###############################################################################
# We build the command line in a string before executing it, and it's very hard
# to get this to work if the executable name contains spaces, so we punt.
if [[ "$EXECUTABLE" != "${EXECUTABLE%[[:space:]]*}" ]]; then
quit "Cannot handle spaces in executable name"
fi
# Command-line arguments are passed directly to the job script. We need to
# accept multiple arguments separated by whitespace, and pass them through the
# environment. It is very hard to properly handle spaces in arguments in this
# mode, so we punt.
for (( i = 1; i <= $#; i++ )); do
if [[ "${!i}" != "${!i%[[:space:]]*}" ]]; then
quit "Cannot handle spaces in command line arguments"
fi
done
export ARGS=$@
export WALLTIME="$(printf "%02d:%02d:00" $((MINUTES/60)) $((MINUTES%60)))"
if [ "$(uname)" == "Darwin" ]; then
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:-}:$LEGION_DIR/bindings/regent/"
if [[ ! -z "${HDF_ROOT:-}" ]]; then
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:-}:$HDF_ROOT/lib"
fi
else
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:$LEGION_DIR/bindings/regent/"
if [[ ! -z "${HDF_ROOT:-}" ]]; then
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:$HDF_ROOT/lib"
fi
fi
# Make sure the number of requested ranks is divisible by the number of nodes.
export NUM_NODES=$(( NUM_RANKS / RANKS_PER_NODE ))
if (( NUM_RANKS % RANKS_PER_NODE > 0 )); then
export NUM_NODES=$(( NUM_NODES + 1 ))
fi
export NUM_RANKS=$(( NUM_NODES * RANKS_PER_NODE ))
export LOCAL_RUN=0
export LEGION_FREEZE_ON_ERROR="$DEBUG"
###############################################################################
# Machine-specific handling
###############################################################################
function run_lassen {
GROUP="${GROUP:-stanford}"
export QUEUE="${QUEUE:-pbatch}"
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-w done($AFTER)"
fi
CI_FLAGS=
if [[ "$CI_RUN" == 1 ]]; then
CI_FLAGS="-K"
fi
bsub -G "$GROUP" $CI_FLAGS \
-nnodes "$NUM_NODES" -W "$MINUTES" -q "$QUEUE" $DEPS \
"$HTR_DIR"/jobscripts/lassen.lsf
}
function run_yellowstone {
export QUEUE="${QUEUE:-gpu-maxwell}"
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-d afterok:$AFTER"
fi
CI_FLAGS=
if [[ "$CI_RUN" == 1 ]]; then
CI_FLAGS="--wait"
fi
EXCLUDED="$(paste -sd ',' "$HTR_DIR"/jobscripts/blacklist/yellowstone.txt)"
sbatch $CI_FLAGS --export=ALL \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" $DEPS \
--exclude="$EXCLUDED" \
"$HTR_DIR"/jobscripts/yellowstone.slurm
}
function run_armstrong {
export QUEUE="${QUEUE:-compute}"
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-d afterok:$AFTER"
fi
CI_FLAGS=
if [[ "$CI_RUN" == 1 ]]; then
CI_FLAGS="--wait"
fi
sbatch $CI_FLAGS --export=ALL \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" $DEPS \
"$HTR_DIR"/jobscripts/armstrong.slurm
}
function run_sapling {
if [[ "$USE_CUDA" == 1 ]]; then
export QUEUE="${QUEUE:-gpu}"
else
export QUEUE="${QUEUE:-cpu}"
fi
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-d afterok:$AFTER"
fi
CI_FLAGS=
if [[ "$CI_RUN" == 1 ]]; then
CI_FLAGS="--wait"
fi
sbatch $CI_FLAGS --export=ALL --exclusive \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" $DEPS \
"$HTR_DIR"/jobscripts/sapling.slurm
}
function run_quartz {
export QUEUE="${QUEUE:-pbatch}"
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-d afterok:$AFTER"
fi
CI_FLAGS=
if [[ "$CI_RUN" == 1 ]]; then
CI_FLAGS="--wait"
fi
sbatch $CI_FLAGS --export=ALL \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" $DEPS \
-J prometeo \
"$HTR_DIR"/jobscripts/quartz.slurm
# Resources:
# 128GB RAM per node
# 2 NUMA domains per node
# 18 cores per NUMA domain
}
function run_solo {
export QUEUE="${QUEUE:-pbatch}"
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-d afterok:$AFTER"
fi
if [[ "$CI_RUN" == 1 ]]; then
quit "CI is not suportted on this system yet"
fi
sbatch --export=ALL \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" $DEPS \
-J prometeo \
--account="$ACCOUNT" \
"$HTR_DIR"/jobscripts/solo.slurm
# Resources:
# 128GB RAM per node
# 2 NUMA domains per node
# 18 cores per NUMA domain
}
function run_m100 {
export QUEUE="${QUEUE:-m100_usr_prod}"
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-w done($AFTER)"
fi
SPECIALQ=
if [ $NUM_NODES -gt 16 ]; then
SPECIALQ="--qos=m100_qos_bprod"
fi
if [[ "$CI_RUN" == 1 ]]; then
quit "CI is not suportted on this system yet"
fi
CORES_PER_RANK=$(( 128/$RANKS_PER_NODE ))
sbatch --export=ALL \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" --gres=gpu:4 $DEPS $SPECIALQ \
--ntasks-per-node="$RANKS_PER_NODE" --cpus-per-task="$CORES_PER_RANK" \
--account="$ACCOUNT" \
"$HTR_DIR"/jobscripts/m100.slurm
# Resources:
# 256GB RAM per node
# 2 NUMA domains per node
# 64 cores per NUMA domain
# 4 nVidia Volta V100
}
function run_kraken {
export QUEUE="${QUEUE:-gpua30}"
DEPS=
RESOURCES=
if [[ "$QUEUE" == "gpua30" ]]; then
RESOURCES="--gres=gpu:a30:4"
fi
if [[ ! -z "$AFTER" ]]; then
DEPS="-d afterok:$AFTER"
fi
if [[ "$CI_RUN" == 1 ]]; then
quit "CI is not suportted on this system yet"
fi
sbatch --export=ALL \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" $RESOURCES $DEPS \
"$HTR_DIR"/jobscripts/kraken.slurm
}
function run_agave {
export QUEUE="${QUEUE:-parallel}"
export PART="${PART:-normal}"
DEPS=
if [[ ! -z "$AFTER" ]]; then
DEPS="-d afterok:$AFTER"
fi
sbatch --export=ALL \
-N "$NUM_NODES" -t "$WALLTIME" -p "$QUEUE" -q "$PART" $DEPS \
"$HTR_DIR"/jobscripts/agave.slurm
}
function run_local {
if (( NUM_NODES > 1 )); then
quit "Too many nodes requested"
fi
# Overrides for local, non-GPU run
LOCAL_RUN=1
USE_CUDA=0
RESERVED_CORES=2
# Determine available resources
CORES_PER_NODE=
THREADS_PER_NODE=
RAM_PER_NODE=
NUMA_PER_RANK=
if [ "$(uname)" == "Darwin" ]; then
CORES_PER_NODE="$(sysctl -a | grep machdep.cpu | awk -F ":" '/core_count/ { print $2; };')"
THREADS_PER_NODE="$(sysctl -a | grep machdep.cpu | awk -F ":" '/thread_count/ { print $2; };')"
RAM_PER_NODE="$(sysctl hw.memsize | awk '{ print $2/1048576; }')"
NUMA_PER_RANK=1
else
CORES_PER_NODE="$(lscpu | awk -F ":" '/Core/ { c=$2; }; /Socket/ { print c*$2 }')"
THREADS_PER_NODE="$(grep --count ^processor /proc/cpuinfo)"
RAM_PER_NODE="$(free -m | head -2 | tail -1 | awk '{print $2}')"
NUMA_PER_RANK="$(lscpu | awk -F ":" '/NUMA node\(s\)/ { gsub(/ /,""); print $2 }')"
fi
RAM_PER_NODE=$(( RAM_PER_NODE / 2 / RANKS_PER_NODE ))
# Do not use more than one util or bgwork
UTIL_THREADS=1
BGWORK_THREADS=1
# If the machine uses hyperthreading we do not need to reserve any core
if (( CORES_PER_NODE != THREADS_PER_NODE )); then
RESERVED_CORES=2
fi
# If we have multiple ranks per node, just set RESERVED_CORES to one
if (( RANKS_PER_NODE > 1 )); then
RESERVED_CORES=1
fi
# Generate command
source "$HTR_DIR"/jobscripts/jobscript_shared.sh
# Run
if ((RANKS_PER_NODE > 1 )); then
mpirun -n "$NUM_RANKS" --bind-to none $COMMAND
else
$COMMAND
fi
}
###############################################################################
# Switch on machine
###############################################################################
if [[ "$(uname -n)" == *"lassen"* ]]; then
run_lassen
elif [[ "$(uname -n)" == *"yellowstone"* ]]; then
run_yellowstone
elif [[ "$(uname -n)" == *"armstrong"* ]]; then
run_armstrong
elif [[ "$(uname -n)" == *"sapling"* ]]; then
run_sapling
elif [[ "$(uname -n)" == *"quartz"* ]]; then
run_quartz
elif [[ "$(uname -n)" == *"solo"* ]]; then
run_solo
elif [[ "$(hostname -d)" == *"m100"* ]]; then
run_m100
elif [[ "$(uname -n)" == *"kraken"* ]]; then
run_kraken
elif [[ "$(uname -n)" == *"agave"* ]]; then
run_agave
else
echo 'Hostname not recognized; assuming local machine run w/o GPUs'
run_local
fi