-
Notifications
You must be signed in to change notification settings - Fork 0
/
goolf
executable file
·364 lines (274 loc) · 8.76 KB
/
goolf
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#!/bin/bash
# goolf toolchain (*) steps:
# 0. openmpi with gcc *
# 1. gompi toolchain
# 2. openblas with gcc *
# 3. scalapack with gompi *
# 4. fftw with gcc
# 5. fftw with gompi *
# 6. goolf toolchain *
#
# Ruoshi Sun
# 2021-09-30
GCC_VER=11.2.0
OPENMPI_VER=3.1.6
OPENBLAS_VER=0.3.17
SCALAPACK_VER=2.1.0
FFTW_VER=3.3.10
# toolchain version
GOMPI_VER=${GCC_VER}_${OPENMPI_VER}
GOOLF_VER=${GCC_VER}_${OPENMPI_VER}
# easyconfig filename
EB_OPENMPI="openmpi-${OPENMPI_VER}-gcc-${GCC_VER}.eb"
EB_GOMPI="gompi-${GOMPI_VER}.eb"
EB_OPENBLAS="openblas-${OPENBLAS_VER}-gcc-${GCC_VER}.eb"
EB_SCALAPACK="scalapack-${SCALAPACK_VER}-gompi-${GOMPI_VER}.eb"
EB_FFTW_GCC="fftw-${FFTW_VER}-gcc-${GCC_VER}.eb"
EB_FFTW="fftw-${FFTW_VER}-gompi-${GOMPI_VER}.eb"
EB_GOOLF="goolf-${GOOLF_VER}.eb"
DATE=$(date +%Y-%m-%d)
EB_HEADER="# $DATE generated by goolf script (Ruoshi Sun)"
# temporary file for appsync commands
APPSYNC_FILE="$(mktemp)"
APPSYNC=(
"compiler gcc/$GCC_VER openmpi/$OPENMPI_VER"
"toolchains gompi/$GOMPI_VER"
"compiler gcc/$GCC_VER openblas/$OPENBLAS_VER"
"mpi gcc/$GCC_VER openmpi/$OPENMPI_VER scalapack/$SCALAPACK_VER"
"compiler gcc/$GCC_VER fftw/$FFTW_VER"
"mpi gcc/$GCC_VER openmpi/$OPENMPI_VER fftw/$FFTW_VER"
"toolchains goolf/$GOOLF_VER"
)
echo "${APPSYNC[@]}"
exit
# menu and prompt
MESSAGE=(
"openmpi/$OPENMPI_VER with gcc/$GCC_VER"
"gompi/$GOMPI_VER toolchain"
"openblas/$OPENBLAS_VER with gcc/$GCC_VER"
"scalapack/$SCALAPACK_VER with gompi/$GOMPI_VER"
"fftw/$FFTW_VER with gcc/$GCC_VER"
"fftw/$FFTW_VER with gompi/$GOMPI_VER"
"goolf/$GOOLF_VER toolchain"
)
echo " <G>cc"
echo " <O>penmpi"
echo " <O>penblas"
echo "sca<L>apack"
echo " <F>ftw automatic installation (Ruoshi Sun)"
echo
for i in "${!MESSAGE[@]}"; do
echo "$i. ${MESSAGE[$i]}"
done
echo
read -p "Select initial step [0-6]: " step
if ! [[ "$step" =~ ^[0-6]$ ]]; then
echo "Invalid option."
exit 1
fi
#-----------------------------------------
# begin installation
module purge
module load easybuild
# 0. openmpi with gcc
if [ $step -eq 0 ]; then
cat > $EB_OPENMPI <<EOF
$EB_HEADER
easyblock = 'ConfigureMake'
name = 'openmpi'
version = '$OPENMPI_VER'
homepage = 'https://www.open-mpi.org/'
description = "The Open MPI Project is an open source MPI-3 implementation."
toolchain = {'name': 'gcc', 'version': '$GCC_VER'}
source_urls = ['https://download.open-mpi.org/release/open-mpi/v%(version_major_minor)s']
sources = [SOURCELOWER_TAR_GZ]
# needed for --with-verbs
osdependencies = [('zlib',)]
configopts = "--enable-shared --with-verbs --enable-mpirun-prefix-by-default --with-slurm --with-pmi=/opt/slurm/current --with-pmi-libdir=/opt/slurm/current/lib"
modextravars = {'SLURM_CPU_BIND_TYPE': 'cores', 'SLURM_MPI_TYPE': 'pmi2'}
sanity_check_paths = {
'files': ['bin/ompi_info', 'bin/opal_wrapper', 'bin/orterun', 'lib/libmpi_mpifh.so', 'lib/libmpi.so', 'lib/libompitrace.so', 'lib/libopen-pal.so', 'lib/libopen-rte.so', 'include/mpi-ext.h', 'include/mpif-config.h', 'include/mpif.h', 'include/mpi.h', 'include/mpi_portable_platform.h'],
'dirs': [],
}
moduleclass = 'mpi'
EOF
eb -f $EB_OPENMPI
fi
# 1. gompi toolchain
if [ $step -le 1 ]; then
cat > $EB_GOMPI <<EOF
$EB_HEADER
easyblock = 'Toolchain'
name = 'gompi'
gccver = '$GCC_VER'
mpiver = '$OPENMPI_VER'
version = '%s_%s' % (gccver, mpiver)
homepage = '(none)'
description = """GNU Compiler Collection (GCC) based compiler toolchain along with CUDA toolkit,
including OpenMPI for MPI support."""
toolchain = {'name': 'dummy', 'version': ''}
comp = ('gcc', gccver)
dependencies = [
comp,
('openmpi', mpiver, '', comp),
]
moduleclass = 'toolchain'
EOF
eb -f $EB_GOMPI
fi
# 2. openblas with gcc
if [ $step -le 2 ]; then
cat > $EB_OPENBLAS <<EOF
$EB_HEADER
easyblock = 'ConfigureMake'
name = 'openblas'
version = '$OPENBLAS_VER'
homepage = 'http://xianyi.github.com/OpenBLAS/'
description = "OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version."
toolchain = {'name': 'gcc', 'version': '$GCC_VER'}
source_urls = [
'http://www.netlib.org/lapack/timing/',
'https://github.com/xianyi/OpenBLAS/archive/',
]
sources = ['v%(version)s.tar.gz']
patches = [
('large.tgz', '.'),
('timing.tgz', '.'),
]
buildopts = 'TARGET=SANDYBRIDGE DYNAMIC_ARCH=1 BINARY=64 USE_THREAD=0 CC="\$CC" FC="\$F77" NO_AFFINITY=1'
installopts = 'USE_THREAD=0 PREFIX=%(installdir)s'
skipsteps = ['configure']
sanity_check_paths = {
'files': ['include/cblas.h', 'include/f77blas.h', 'include/lapacke_config.h', 'include/lapacke.h', 'include/lapacke_mangling.h', 'include/lapacke_utils.h', 'include/openblas_config.h', 'lib/libopenblas.a', 'lib/libopenblas.so'],
'dirs': [],
}
moduleclass = 'numlib'
EOF
eb -f $EB_OPENBLAS
fi
# 3. scalapack with gompi
if [ $step -le 3 ]; then
cat > $EB_SCALAPACK <<EOF
$EB_HEADER
easyblock = 'EB_ScaLAPACK'
name = 'scalapack'
version = '$SCALAPACK_VER'
homepage = 'http://www.netlib.org/scalapack/'
description = """The ScaLAPACK (or Scalable LAPACK) library includes a subset of LAPACK routines
redesigned for distributed memory MIMD parallel computers."""
gccver = '$GCC_VER'
mpiver = '$OPENMPI_VER'
toolchain = {'name': 'gompi', 'version': '%s_%s' % (gccver, mpiver)}
toolchainopts = {'pic': True, 'usempi': True}
source_urls = [homepage]
sources = [SOURCELOWER_TGZ]
blaslib = 'openblas'
blasver = '$OPENBLAS_VER'
dependencies = [
(blaslib, blasver, '', ('gcc', gccver)),
]
preconfigopts = [
'FCFLAGS="\$FCFLAGS -fallow-argument-mismatch" && '
]
# parallel build tends to fail, so disabling it
parallel = 1
moduleclass = 'numlib'
EOF
eb -f $EB_SCALAPACK
fi
# 4. fftw with gcc
if [ $step -le 4 ]; then
cat > $EB_FFTW_GCC <<EOF
$EB_HEADER
easyblock = 'ConfigureMake'
name = 'fftw'
#modaltsoftname = 'fftw'
version = '$FFTW_VER'
homepage = 'http://www.fftw.org'
description = """FFTW is a C subroutine library for computing the discrete Fourier transform (DFT)
in one or more dimensions, of arbitrary input size, and of both real and complex data."""
toolchain = {'name': 'gcc', 'version': '$GCC_VER'}
toolchainopts = {'optarch': True, 'pic': True}
source_urls = [homepage]
sources = ['%(name)s-%(version)s.tar.gz']
common_configopts = "--enable-threads --enable-openmp --enable-shared --with-pic"
configopts = [
common_configopts + " --enable-single --enable-avx ",
common_configopts + " --enable-long-double ",
common_configopts + " --enable-quad-precision",
common_configopts + " --enable-avx ", # default as last
]
moduleclass = 'numlib'
EOF
eb -f $EB_FFTW_GCC
fi
# 5. fftw with gompi
if [ $step -le 5 ]; then
cat > $EB_FFTW <<EOF
$EB_HEADER
easyblock = 'ConfigureMake'
name = 'fftw'
version = '$FFTW_VER'
homepage = 'http://www.fftw.org'
description = """FFTW is a C subroutine library for computing the discrete Fourier transform (DFT)
in one or more dimensions, of arbitrary input size, and of both real and complex data."""
toolchain = {'name': 'gompi', 'version': '$GOMPI_VER'}
toolchainopts = {'optarch': True, 'usempi': True, 'pic': True}
source_urls = [homepage]
#sources = [SOURCELOWER_TAR_GZ]
sources = ['%(name)s-%(version)s.tar.gz']
common_configopts = "--enable-threads --enable-openmp --enable-shared --with-pic"
configopts = [
common_configopts + " --enable-single --enable-avx --enable-mpi",
common_configopts + " --enable-long-double --enable-mpi",
common_configopts + " --enable-quad-precision",
common_configopts + " --enable-avx --enable-mpi", # default as last
]
moduleclass = 'numlib'
EOF
eb -f $EB_FFTW
fi
# 6. goolf
if [ $step -le 6 ]; then
cat > $EB_GOOLF <<EOF
$EB_HEADER
easyblock = 'Toolchain'
name = 'goolf'
gccver = '$GCC_VER'
mpiver = '$OPENMPI_VER'
version = '%s_%s' % (gccver,mpiver)
homepage = '(none)'
description = """GNU Compiler Collection (GCC) based compiler toolchain,
including OpenMPI for MPI support, OpenBLAS (BLAS and LAPACK support), FFTW and ScaLAPACK."""
toolchain = {'name': 'dummy', 'version': 'dummy'}
comp = ('gcc', gccver)
gompi_tc = ('gompi', '%s_%s' % (gccver, mpiver))
# compiler toolchain dependencies
dependencies = [
comp,
('openmpi', mpiver, '', comp),
('openblas', '$OPENBLAS_VER', '', comp),
('scalapack', '$SCALAPACK_VER', '', gompi_tc),
('fftw', '$FFTW_VER', '', gompi_tc),
]
moduleclass = 'toolchain'
EOF
eb -f $EB_GOOLF
fi
#-----------------------------------------
# write appsync commands
YYYYMM_SRC=`ls -l /apps | awk -F'/' '{print $NF}'`
YYYYMM_DEST=${YYYYMM_SRC/_build/}
cat > $APPSYNC_FILE <<EOF
for i in $YYYYMM_DEST; do
EOF
for i in "${!APPSYNC[@]}"; do
if [ $i -ge $step ]; then
echo " appsync $YYYYMM_DEST \$i ${APPSYNC[$i]}" >>$APPSYNC_FILE
fi
done
echo "done" >>$APPSYNC_FILE
chmod +x $APPSYNC_FILE
echo
echo "appsync commands in $APPSYNC_FILE"
cat $APPSYNC_FILE