-
Notifications
You must be signed in to change notification settings - Fork 7
/
compile.sh
executable file
·314 lines (286 loc) · 7.55 KB
/
compile.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#!/usr/bin/env bash
COMPILE=""
GPU=0
JURECA=0
P100=0
GPU_CC="cc35"
CUDA_VERSION=11.1
BUILDTYPE=Release
YELLOW='\033[1;33m'
NC='\033[0;m'
DESCRIPTION="Script for compiling ARTSS. Select one or multiple executables for compiling (default: all executables). Specify CUDA version (default: $CUDA_VERSION) and GPU model (default: $GPU_CC). For a parallel execution choose --jobs, if there is no integer after the --jobs option, the number of processing units available to the current process will be used.
"
OPTIONS="
Available Options:
Load modules:
${YELLOW}--jureca${NC} \t load modules for JURECA
${YELLOW}--p100${NC} \t setup for P100
Executables:
Production (with data output, visualization and analysis):
${YELLOW}-s${NC}
${YELLOW}--serial${NC}
${YELLOW}--artss_serial${NC} \t Executable: artss
${YELLOW} -m${NC}
${YELLOW}--multicore${NC}
${YELLOW}--artss_multicore_cpu${NC} \t Executable: artss_multicore_cpu
${YELLOW}-g${NC}
${YELLOW}--gpu${NC}
${YELLOW}--artss_gpu${NC} \t Executable: artss_gpu
${YELLOW}--mpi${NC} \t Executable: artss_data_assimilation_serial
----
Benchmarking (without output, visualization, analysis):
${YELLOW}--sb${NC}
${YELLOW}--serial_benchmark${NC}
${YELLOW}--artss_benchmark${NC} \t Executable artss_serial_benchmark
${YELLOW}--mb${NC}
${YELLOW}--multicore_benchmark${NC}
${YELLOW}--artss_multicore_cpu_benchmark${NC} \t Executable artss_multicore_cpu_benchmark
${YELLOW}--gb${NC}
${YELLOW}--gpu_benchmark${NC}
${YELLOW}--artss_gpu_benchmark${NC} \t Executable artss_gpu_benchmark
Other:
${YELLOW}-c${NC}
${YELLOW}--cudaversion${NC} \t set CUDA Version
${YELLOW}--cc${NC}
${YELLOW}--computecompatibility${NC} \t set compute compability of the GPU (35|50|60|62|70|72|75|80)
${YELLOW}--checkout${NC} \t set libraries in external folder to a specific version (spdlog v1.9.2, fmt 8.0.1, googletest release-1.8.1)
${YELLOW}-d${NC}
${YELLOW}--debugmode${NC} \t set debug flag for build type (default: ${BUILDTYPE})
${YELLOW}--jobs${NC} \t set the number of recipes to execute at once (-j/--jobs flag in make)
${YELLOW}--gcc${NC} \t use gcc as compiler (optional: specify version)
${YELLOW}--pgi${NC} \t use pgcc ac compiler (optional: specify version)
Docker - ! cannot be combined with other commands ! (more information about docker commands in docker/README.md):
${YELLOW}--docker-build${NC} \t build docker image
${YELLOW}--docker-hostname${NC} \t set hostname for docker image (default: docker_\$(hostname))
${YELLOW}--docker-run${NC} \t run docker with gpu support
${YELLOW}--docker-run-cpu${NC} \t run docker without gpu support
"
HELP="$DESCRIPTION$OPTIONS"
COMPILE=""
DOCKERRUN=0
DOCKERBUILD=0
DOCKERHOST=docker-$(hostname)
DOCKERRUNCPU=0
PROCS=-1
MPI=0
CHECKOUT=0
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-c|--cuda)
CUDA_VERSION="$2"
shift
shift
;;
--cc|--computecompatibility)
GPU_CC="cc$2"
shift
shift
;;
--checkout)
CHECKOUT=1
shift
;;
-d|--debug|--debugmode)
BUILDTYPE=Debug
shift
;;
--docker-build)
DOCKERBUILD=1
shift
;;
--docker-hostname)
DOCKERHOST=$2
shift
shift
;;
--docker-run)
DOCKERRUN=1
shift
;;
--docker-run-cpu)
DOCKERRUNCPU=1
shift
;;
-g|--gpu|--artss_gpu)
COMPILE="$COMPILE artss_gpu"
GPU=1
shift
;;
--gb|--gpu_benchmark|--artss_gpu_benchmark)
COMPILE="$COMPILE artss_gpu_benchmark "
GPU=1
shift
;;
--gcc)
COMPILER="GCC"
if [[ $2 != -* ]]
then
GCC_VERSION="$2"
shift
fi
shift
;;
-h|--help)
echo -e "$HELP"
exit
;;
-j|--jobs)
if [[ $2 =~ ^-?[0-9]+$ ]]
then
PROCS=$2
shift
else
PROCS=$(nproc)
fi
shift
;;
-m|--multicore|--artss_multicore_cpu)
COMPILE="$COMPILE artss_multicore_cpu"
GPU=1
shift
;;
--mb|--multicore_benchmark|--artss_multicore_cpu_benchmark)
COMPILE="$COMPILE artss_multicore_cpu_benchmark"
GPU=1
shift
;;
--mpi)
MPI=1
shift
;;
--pgi)
COMPILER="PGI"
if [[ $2 != -* ]]
then
PGI_VERSION="$2"
shift
fi
shift
;;
-s|--serial|--artss_serial)
COMPILE="$COMPILE artss_serial"
shift
;;
--sb|--serial_benchmark|--artss_serial_benchmark)
COMPILE="$COMPILE artss_serial_benchmark"
shift
;;
--jureca)
JURECA=1
shift
;;
--p100)
P100=1
shift
;;
*)
POSITIONAL+=("$1")
echo "unknown option: $1"
shift
;;
esac
done
if [ $CHECKOUT -eq 1 ]
then
cd external/fmt || exit
git checkout 8.0.1
cd ../spdlog || exit
git checkout v1.9.2
cd ../googletest || exit
# gtest is pinned to this commit because older versions do not build warning
# free on GCC11 and gtest insists on using -Werror. No release version was
# available that builds without warnings on GCC11 at this time [2022-07-27]
git checkout 7735334a46da480a749945c0f645155d90d73855
cd ../..
fi
if [ $DOCKERBUILD -eq 1 ]
then
cd docker || exit
docker build -t artss_docker --no-cache .
cd ..
fi
if [ $DOCKERRUN -eq 1 ]
then
docker run --gpus all -it --rm --hostname=${DOCKERHOST} -p7777:7777 -v "$(pwd)":/host_pwd -w /host_pwd artss_docker bash
fi
if [ $DOCKERRUNCPU -eq 1 ]
then
docker run -it --rm --hostname=${DOCKERHOST} -p7777:7777 -v "$(pwd)":/host_pwd -w /host_pwd artss_docker bash # /bin/bash -c "./compile.sh"
fi
if [[ $DOCKERRUN -eq 1 || $DOCKERRUNCPU -eq 1 || $DOCKERBUILD -eq 1 ]]
then
exit
fi
if [[ $JURECA -eq 0 && $P100 -eq 0 ]]
then
HOSTNAME=$(hostname)
if [[ $HOSTNAME = jrl* ]]; then JURECA=1; fi
if [ "$HOSTNAME" = "ias7139" ]; then P100=1; fi
fi
if [ "$COMPILE" = "" ]
then
GPU=1
fi
if [ -z $COMPILER ]
then
COMPILER="PGI"
fi
if [ $JURECA -eq 1 ]
then
module load CMake
module load NVHPC/20.9-GCC-9.3.0
module load CUDA/11.0
export CUDA_LIB=${CUDA_ROOT}/lib64/
export CUDA_INC=${CUDA_ROOT}/include/
CUDA_VERSION=11.0
GPU_CC=cc80
GPU=0
fi
if [ ${P100} -eq 1 ]
then
if [ -z "${PGI_VERSION}" ]
then
PGI_VERSION=19.4
fi
if [ -z ${CUDA_VERSION} ]
then
CUDA_VERSION=10.2
fi
GPU_CC=cc60
fi
if [ $GPU -eq 1 ]
then
export CUDA_LIB=$CUDA_ROOT/lib64
export CUDA_INC=$CUDA_ROOT/include
fi
rm -rf build/
mkdir build
cd build || exit
if [[ $MPI -eq 1 ]]
then
CCOMPILER=mpicc
CXXCOMPILER=mpiCC
COMPILE=artss_data_assimilation_serial
elif [[ $GPU -eq 1 ]] || [[ $COMPILER = "PGI" ]]
then
CCOMPILER=nvc
CXXCOMPILER=nvc++
else
CCOMPILER=gcc
CXXCOMPILER=g++
fi
if [ -z ${CUDA_VERSION} ]
then
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=${BUILDTYPE} -DCMAKE_C_COMPILER=${CCOMPILER} -DCMAKE_CXX_COMPILER=${CXXCOMPILER} ..
else
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=${BUILDTYPE} -DCMAKE_C_COMPILER=${CCOMPILER} -DCMAKE_CXX_COMPILER=${CXXCOMPILER} -DGPU_CC=${GPU_CC} -DCUDA_VERSION=${CUDA_VERSION} ..
fi
if [ "$PROCS" -le 0 ]
then
make $COMPILE
else
echo "-- Parallel execution with $PROCS processing units"
make $COMPILE -j"$PROCS"
fi