-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pkgs.sh
executable file
·349 lines (309 loc) · 10.6 KB
/
azure-pkgs.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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
#!/bin/bash
################################################################################
#
# Spack Package Installation Script for Azure CentOS HPC Images
# Author Mike Kiernan, Microsoft
# Tested On: CentOS-HPC 7.9
# PREREQ: make sure you've installed spack with azure-spack.sh first
#
################################################################################
# KNOWN ISSUES:
################################################################################
#-- ensure spack env is set
source ~/.bashrc
usage()
{
echo -e "\nUsage: $(basename $0) [--silent,-s <non-interactive mode: for automated installs.>]\n"
echo -e "eg: $(basename $0) --silent\n"
exit 1
} #-- end of usage() --#
silent=0; dryrun=1 #-- default to interactive
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--silent)
silent=1; dryrun=0
shift; shift
;;
*)
usage
;;
esac
done
function goto { eval "$(sed -n "/$1:/{:a;n;p;ba};" $0 |grep -v ':$')";exit;};start=${1:-"start"}; goto $start
start:
#-- script and all globals start here
function red { echo -e "\033[31;7m$1\e[0m"; } #-- red
function green { echo -e "\033[32;7m$1\e[0m"; } #-- green
function amber { echo -e "\033[33;7m$1\e[0m"; } #-- amber
function info { echo -e "\033[36;7m$1\e[0m"; } #-- cyan
if [ $dryrun -eq 1 ]; then
info "*** THIS IS A DRY RUN ***"
else
info "*** LIVE INSTALLATION STARTING ***"
fi
#-- global counters
pass=0; fail=0
declare -a passed
declare -a failed
################################################################################
# ADMINISTRATOR/USER EDITABLE SECTION: Change versions required here
################################################################################
#-- note: just hash out the lines you don't want
#-- duplicate lines if you want multiple package versions
compilers=(
)
#-- mpi: use the Azure HPC image pre-installed modules were possible - see packages.yaml
#-- using azure modules from /opt: openmpi, mvapich2, hpcx, intelmpi
mpis=(
)
maths=(
[email protected] #-- [email protected] install for hpl+hpcx
)
declare -A foundations=(
[[email protected]]=serial
[[email protected]]=parallel
[[email protected]]=parallel
[[email protected]]=parallel
)
declare -A benchmarks=(
[[email protected]]=serial
[[email protected]]=parallel
[[email protected]]=parallel
[[email protected]]=parallel
)
declare -A quantum_espresso=(
[[email protected]]=parallel
[[email protected]]=parallel
)
#-- apply these only to specific codes
arch=`spack arch -t`
#if [[ "$arch" == "zen" || "$arch" == "zen2" ]]; then
if [ "$arch" == "zen" ]; then
#opt='cflags="-O3 -march=core-avx2" cxxflags="-O3 -march=core-avx2" fflags="-O3 -march=core-avx2"'
#opt="cflags='-O3 -march=core-avx2' cxxflags='-O3 -march=core-avx2' fflags='-O3 -march=core-avx2'"
#-- gcc options
#opt="cflags='-O3 -march=native -fopenmp' cxxflags='-O3 -march=native -fopenmp' fflags='-O3 -march=native -fopenmp'"
opt="cflags='-O3 -march=znver1 -fopenmp' cxxflags='-O3 -march=znver1 -fopenmp' fflags='-O3 -march=znver1 -fopenmp'"
elif [ "$arch" == "zen2" ]; then
#opt="cflags='-O3 -march=znver2 -fopenmp' cxxflags='-O3 -march=znver2 -fopenmp' fflags='-O3 -march=znver2 -fopenmp'"
opt="cflags='-O3 -march=native -fopenmp' cxxflags='-O3 -march=native -fopenmp' fflags='-O3 -march=native -fopenmp'"
elif [ "$arch" == "skylake" ]; then
opt='cflags="-O3 -march=skylake-avx512 -mtune=skylake-avx512"'
fi
amber "optimization for $arch: $opt"
################################################################################
# END ADMINISTRATOR/USER EDITABLE SECTION
################################################################################
SECONDS=0 #-- use builtin shell var to record function times
WALLTIME=0 #-- record wall time of script
functiontimer()
{
echo "Function $1 took $SECONDS seconds";
let WALLTIME+=$SECONDS
SECONDS=0
} #--- end of functiontimer() ---#
#-- execute & echo full command so we can re-run by hand if needed.
execho()
{
cmd=$1
#echo -e "\033[32;7m$cmd\e[0m";
green "$cmd"
if [ $dryrun -eq 0 ]; then
$cmd
rc=$?
if [ $rc -eq 0 ]; then
#passed[$pass] = "$cmd"
passed+=("$cmd")
pass=$((pass+1))
else
#failed[$fail] = "$cmd"
failed+=("$cmd")
fail=$((fail+1))
fi
if [ $fail -gt 0 ]; then
amber "pass: $pass, fail: $fail"
else
info "pass: $pass, fail: $fail"
fi
fi
} #-- end of execho() --#
install_compilers()
{
echo "################## compilers ######################"
#ARCH=`spack arch`
#spack load [email protected] arch=${ARCH}
#-- install AMD compiler from spack package
AWD=`pwd`
spack install [email protected]
spack cd -i [email protected]
spack compiler add $PWD
cd $AWD
cmd="spack compiler find"; execho "$cmd"
if [ $dryrun -eq 0 ]; then spack compilers; fi
if [ $dryrun -eq 0 ]; then functiontimer "install_compilers()"; fi
} #-- install_compilers() --#
install_mpis()
{
echo "################ mpi packages ####################"
#-- installing mpi's only for default [email protected]
compiler="%[email protected]"
for mpi in "${mpis[@]}"
do
cmd="spack install $mpi $compiler $opt"; execho "$cmd"
done
if [ $dryrun -eq 0 ]; then functiontimer "install_mpis()"; fi
} #-- end of install_mpis() --#
install_mathlibs()
{
echo "############## mathlib packages ##################"
#-- installing mpi's only for default [email protected]
compiler="%[email protected]"
for mathlib in "${maths[@]}"
do
cmd="spack install $mathlib $compiler $opt"; execho "$cmd"
done
if [ $dryrun -eq 0 ]; then functiontimer "install_mathlibs()"; fi
} #-- end of install_mathlibs() --#
install_amdlibs()
{
#-- https://developer.amd.com/spack/amd-optimized-cpu-libraries/
compiler="%[email protected]"
echo "############# amd aocl packages ##################"
cmd="spack install [email protected] $compiler"; execho "$cmd"
cmd="spack install [email protected] ^[email protected] $compiler"; execho "$cmd"
cmd="spack install [email protected]+amd-fast-planner precision=float,double $compiler"; execho "$cmd"
cmd="spack install [email protected] ^[email protected] ^[email protected] $compiler"; execho "$cmd"
cmd="spack install [email protected] $compiler"; execho "$cmd"
cmd="spack install [email protected] $compiler"; execho "$cmd"
if [ $dryrun -eq 0 ]; then functiontimer "install_amdlibs()"; fi
} #-- end of install_amdlibs() --#
install_microbenchmarks()
{
echo "############### benchmark packages ###############"
for compiler in "${compilers[@]}"
do
#-- serial (no mpi)
info "$compiler"
for benchmark in "${!benchmarks[@]}"; do
if [ ${benchmarks[$benchmark]} == "serial" ]; then
cmd="spack install $benchmark $compiler $opt"; execho "$cmd"
fi
done
#-- parallel (with mpi)
for mpi in "${mpis[@]}"
do
info "$compiler && $mpi"
for benchmark in "${!benchmarks[@]}"; do
if [ ${benchmarks[$benchmark]} == "parallel" ]; then
#-- hpl with hpcx does not work with mkl, so use amdblis
if [ $benchmark == "[email protected]" ] && [ $mpi == [email protected] ]; then
cmd="spack install $benchmark $compiler $opt ^$mpi ^[email protected]"; execho "$cmd"
else
cmd="spack install $benchmark $compiler $opt ^$mpi"; execho "$cmd"
fi
fi
done
done
done
if [ $dryrun -eq 0 ]; then functiontimer "install_microbenchmarks()"; fi
} #-- end of install_microbenchmarks() --#
install_foundation_libraries()
{
echo "############## hdf5/netcdf packages ##############"
for compiler in "${compilers[@]}"
do
#-- serial (no mpi)
info "$compiler"
for library in "${!foundations[@]}"; do
if [ ${foundations[$library]} == "serial" ]; then
cmd="spack install $library $compiler $opt"; execho "$cmd"
fi
done
#-- parallel (with mpi)
for mpi in "${mpis[@]}"
do
info "$compiler && $mpi"
for library in "${!foundations[@]}"; do
if [ ${foundations[$library]} == "parallel" ]; then
cmd="spack install $library $compiler $opt ^$mpi"; execho "$cmd"
fi
done
done
done
if [ $dryrun -eq 0 ]; then functiontimer "install_foundation_libraries()"; fi
} #-- end of install_foundation_libraries() --#
install_quantum_espresso()
{
echo "############## quantum espresso ##############"
for compiler in "${compilers[@]}"
do
for mpi in "${mpis[@]}"
do
for mathlib in "${maths[@]}"
do
info "$compiler && $mpi && $mathlib"
cmd="spack install [email protected] $compiler $opt ^$mathlib ^$mpi"; execho "$cmd"
cmd="spack install [email protected] $compiler $opt +elpa+scalapack ^$mathlib ^$mpi"; execho "$cmd"
done
done
done
if [ $dryrun -eq 0 ]; then functiontimer "install_quantum_espresso()"; fi
} #-- install_quantum_espresso() --#
summarize()
{
echo "$pass commands succeeded:"
for cmd in "${passed[@]}"
do
green "$cmd"
done
echo "$fail commands failed:"
for cmd in "${failed[@]}"
do
red "$cmd"
done
echo "###################### complete ######################"
if [ $dryrun -eq 0 ]; then echo "Script ran for $WALLTIME seconds."; fi
if [ $fail -ne 0 ]; then
exit 1
else
exit 0
fi
} #-- end of summarize() --#
################################################################################
# MAIN PROGRAM
################################################################################
install_compilers
install_mpis
install_mathlibs
#install_amdlibs
install_microbenchmarks
install_foundation_libraries
#install_quantum_espresso
#-- if live run complete, summarize & exit
if [ $dryrun -eq 0 ]; then summarize; fi
#-- if running in interactive mode, challenge before installing
if [ $silent -eq 0 ]; then
info " *** DRY RUN COMPLETE *** "
read -n 1 -p "Do you want to execute? [Y/n] " ans; echo
if [ "$ans" != "${ans#[Yy]}" ]; then
echo "$(basename $0): executing install..."
dryrun=0
goto start
fi
else
dryrun=0
goto start
fi