-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·70 lines (62 loc) · 1.36 KB
/
run
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
#!/usr/bin/env bash
# Initialize our own variables:
machines="1"
release_mode="Release"
bench=""
queue="amd-shortq"
tasks="0"
usage() {
echo "Usage: $0 [-n <machines> -q <queue>] BINARY" 1>&2;
exit 1;
}
while getopts "h?n:db:t:q:" opt; do
case "$opt" in
h|\?)
usage
;;
n)
machines=${OPTARG}
;;
d)
release_mode="Debug"
;;
b)
bench=${OPTARG}
;;
t)
tasks=${OPTARG}
;;
q)
queue=${OPTARG}
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
;;
esac
done
shift $((OPTIND-1))
binary=${1:-all}
shift
module load intel/mpi/64
if [[ ! ${bench} ]]; then
mkdir -p build
cd build
module load cmake
echo -e "\e[32mBuilding ${binary}\e[0m"
cmake -DCMAKE_BUILD_TYPE=${release_mode} .. > /dev/null 2>&1
make ${binary}
cd ..
fi
rc=$?; if [[ ${rc} != 0 ]] || [[ ${binary} == "all" ]]; then exit ${rc}; fi
echo -e "\e[32mRunning ${binary} on ${machines} machine(s) with args ${@}\e[0m"
if [ $tasks == "0" ]; then
tasks=$machines
fi
if [ ! ${bench} ]; then
srun --partition=${queue} -N ${machines} -n ${tasks} --mpi=pmi2 build/${binary} ${@}
else
srun --partition=${queue} -N ${machines} -n ${tasks} --mpi=pmi2 build/${binary} ${@} | tee ${bench}
fi