-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_deps.sh
executable file
·339 lines (276 loc) · 8.82 KB
/
install_deps.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
#!/bin/bash
#
# This script installs some compiled dependencies needed by TOAST. You should edit
# the values in this script to match your system and what dependencies you would like
# to build from scratch.
#
# See the README for more details.
#
# Install prefix
#==============================
PREFIX="$(pwd)/toast_stack"
# Serial compilers
#==============================
# Example for the GNU compilers:
CC="gcc"
CXX="g++"
FC="gfortran"
# Example for the Intel compilers:
# CC="${INTEL_PATH}/linux/bin/intel64/icc"
# CXX="${INTEL_PATH}/linux/bin/intel64/icpc"
# FC="${INTEL_PATH}/linux/bin/intel64/ifort"
# Example for OSX with clang (fortran disabled):
# CC="clang"
# CXX="clang++"
# FC=
# Compile flags
#==============================
# Example for GNU compilers
CFLAGS="-O3 -fPIC -pthread"
CXXFLAGS="-O3 -fPIC -pthread -std=c++11"
FCFLAGS="-O3 -fPIC -pthread"
OPENMP_CFLAGS="-fopenmp"
OPENMP_CXXFLAGS="-fopenmp"
LDFLAGS="-lpthread -fopenmp"
# Example for Intel compilers, building "fat" binaries that have object code for both
# ivybridge and newer processors as well as KNL with AVX512.
# CFLAGS="-O3 -g -fPIC -xcore-avx2 -axmic-avx512 -pthread"
# CXXFLAGS="-O3 -g -fPIC -xcore-avx2 -axmic-avx512 -pthread -std=c++11"
# FCFLAGS="-O3 -g -fPIC -xcore-avx2 -axmic-avx512 -fexceptions -pthread -heap-arrays 16"
# OPENMP_CFLAGS="-qopenmp"
# OPENMP_CXXFLAGS="-qopenmp"
# LDFLAGS="-lpthread -liomp5"
# Parallel builds
MAKEJ=4
# Environment: put the install prefix into our environment while
# running this script.
pysite=$(python3 --version 2>&1 | sed -e "s#Python \(.*\)\.\(.*\)\..*#\1.\2#")
mkdir -p "${PREFIX}/bin"
mkdir -p "${PREFIX}/include"
mkdir -p "${PREFIX}/lib"
if [ ! -e "${PREFIX}/lib64" ]; then
ln -s "${PREFIX}/lib" "${PREFIX}/lib64"
fi
if [ "x${CPATH}" = "x" ]; then
export CPATH="${PREFIX}/include"
else
export CPATH="${PREFIX}/include:${CPATH}"
fi
if [ "x${LD_LIBRARY_PATH}" = "x" ]; then
export LD_LIBRARY_PATH="${PREFIX}/lib"
else
export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}"
fi
if [ "x${PYTHONPATH}" = "x" ]; then
export PYTHONPATH="${PREFIX}/lib"
else
export PYTHONPATH="${PREFIX}/lib/python${pysite}/site-packages:${PYTHONPATH}"
fi
# PACKAGES
#==============================
# For each of the packages below, you can either tweak the build command or comment out
# the lines completely if you are using some external package.
# GMP / MPFR
#---------------------
# Most Linux systems already have these development libraries installed (needed by
# SuiteSparse below). They are commented out here by default. If you are installing
# on a truly bare-bones system or in a container you may need to install these from
# scratch with your custom compilers.
# # libgmp
#
# gmp_version=6.2.0
# gmp_dir=gmp-${gmp_version}
# gmp_pkg=${gmp_dir}.tar.xz
#
# echo "Fetching libgmp"
#
# if [ ! -e ${gmp_pkg} ]; then
# curl -SL https://ftp.gnu.org/gnu/gmp/${gmp_pkg} -o ${gmp_pkg}
# fi
#
# echo "Building libgmp..."
#
# rm -rf ${gmp_dir}
# tar xf ${gmp_pkg} \
# && pushd ${gmp_dir} >/dev/null 2>&1 \
# && CC="${CC}" CFLAGS="${CFLAGS}" \
# ./configure \
# --disable-static \
# --enable-shared \
# --with-pic \
# --prefix="${PREFIX}" \
# && make -j ${MAKEJ} \
# && make install \
# && popd >/dev/null 2>&1
#
# # libmpfr
#
# mpfr_version=4.1.0
# mpfr_dir=mpfr-${mpfr_version}
# mpfr_pkg=${mpfr_dir}.tar.xz
#
# echo "Fetching libmpfr"
#
# if [ ! -e ${mpfr_pkg} ]; then
# curl -SL https://www.mpfr.org/mpfr-current/${mpfr_pkg} -o ${mpfr_pkg}
# fi
#
# echo "Building libmpfr..."
#
# rm -rf ${mpfr_dir}
# tar xf ${mpfr_pkg} \
# && pushd ${mpfr_dir} >/dev/null 2>&1 \
# && CC="${CC}" CFLAGS="${CFLAGS}" \
# ./configure \
# --disable-static \
# --enable-shared \
# --with-pic \
# --with-gmp="${PREFIX}" \
# --prefix="${PREFIX}" \
# && make -j ${MAKEJ} \
# && make install \
# && popd >/dev/null 2>&1
# BLAS / LAPACK
#---------------------
# Here we install OpenBLAS by default, but you might use any BLAS / LAPACK
# implementation. HOWEVER, see the note in the README about MKL conflicts between
# versions used to build TOAST and those installed along with Numpy.
# Install Openblas
openblas_version=0.3.10
openblas_dir=OpenBLAS-${openblas_version}
openblas_pkg=${openblas_dir}.tar.gz
echo "Fetching OpenBLAS..."
if [ ! -e ${openblas_pkg} ]; then
curl -SL https://github.com/xianyi/OpenBLAS/archive/v${openblas_version}.tar.gz -o ${openblas_pkg}
fi
echo "Building OpenBLAS..."
rm -rf ${openblas_dir}
tar xzf ${openblas_pkg} \
&& pushd ${openblas_dir} >/dev/null 2>&1 \
&& make USE_OPENMP=1 NO_SHARED=0 \
MAKE_NB_JOBS=${MAKEJ} \
CC="${CC}" FC="${FC}" DYNAMIC_ARCH=1 \
COMMON_OPT="${CFLAGS}" FCOMMON_OPT="${FCFLAGS}" \
LDFLAGS="${LDFLAGS}" \
&& make NO_SHARED=0 PREFIX="${PREFIX}" install \
&& popd >/dev/null 2>&1
# If you commented out the above installation of OpenBLAS, set these lines to the
# link command for BLAS and LAPACK for use by future dependencies below.
BLAS="-L${PREFIX}/lib -lopenblas -lm ${LDFLAGS}"
LAPACK="-L${PREFIX}/lib -lopenblas -lm ${LDFLAGS}"
# Example: Use MKL instead (and comment out the install of OpenBLAS above)
# BLAS="-L${MKLROOT}/lib/intel64 -lmkl_rt -lm ${LDFLAGS} -ldl"
# LAPACK="-L${MKLROOT}/lib/intel64 -lmkl_rt -lm ${LDFLAGS} -ldl"
# FFTW
#---------------------
fftw_version=3.3.8
fftw_dir=fftw-${fftw_version}
fftw_pkg=${fftw_dir}.tar.gz
echo "Fetching FFTW..."
if [ ! -e ${fftw_pkg} ]; then
curl -SL http://www.fftw.org/${fftw_pkg} -o ${fftw_pkg}
fi
echo "Building FFTW..."
rm -rf ${fftw_dir}
tar xzf ${fftw_pkg} \
&& pushd ${fftw_dir} >/dev/null 2>&1 \
&& CC="${CC}" CFLAGS="${CFLAGS}" \
./configure \
--enable-threads \
--disable-static \
--enable-shared \
--prefix="${PREFIX}" \
&& make -j ${MAKEJ} \
&& make install \
&& popd >/dev/null 2>&1
# libaatm
# ---------------------
aatm_version=1.0.9
aatm_dir=libaatm-${aatm_version}
aatm_pkg=${aatm_dir}.tar.gz
echo "Fetching libaatm..."
if [ ! -e ${aatm_pkg} ]; then
curl -SL "https://github.com/hpc4cmb/libaatm/archive/${aatm_version}.tar.gz" -o "${aatm_pkg}"
fi
echo "Building libaatm..."
rm -rf ${aatm_dir}
tar xzf ${aatm_pkg} \
&& pushd ${aatm_dir} >/dev/null 2>&1 \
&& mkdir -p build \
&& pushd build >/dev/null 2>&1 \
&& cmake \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
.. \
&& make -j ${MAKEJ} install \
&& popd >/dev/null 2>&1 \
&& popd >/dev/null 2>&1
# SuiteSparse
# ---------------------
ssparse_version=5.8.1
ssparse_dir=SuiteSparse-${ssparse_version}
ssparse_pkg=${ssparse_dir}.tar.gz
echo "Fetching SuiteSparse..."
if [ ! -e ${ssparse_pkg} ]; then
curl -SL https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v${ssparse_version}.tar.gz -o ${ssparse_pkg}
fi
echo "Building SuiteSparse..."
rm -rf ${ssparse_dir}
tar xzf ${ssparse_pkg} \
&& pushd ${ssparse_dir} >/dev/null 2>&1 \
&& make library JOBS=${MAKEJ} \
CC="${CC}" CXX="${CXX}" \
CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" AUTOCC=no \
GPU_CONFIG="" CFOPENMP="${OPENMP_CXXFLAGS}" \
LAPACK="${LAPACK}" BLAS="${BLAS}" \
&& cp -a ./include/* "${PREFIX}/include/" \
&& cp -a ./lib/* "${PREFIX}/lib/" \
&& find . -name "*.a" -exec cp -a '{}' "${PREFIX}/lib/" \; \
&& popd >/dev/null 2>&1
# Install some python packages to ensure we have them and that
# they are recent.
python3 -m pip install --prefix "${PREFIX}" astropy healpy ephem
# Make a shell snippet to load the tools
echo "
# Load this software stack into your environment by sourcing this file:
#
# %> . init.sh
# %> load_toast
#
prepend_env () {
# This function is needed since trailing colons
# on some environment variables can cause major
# problems...
local envname=\$1
local envval=\$2
if [ \"x\${!envname}\" = \"x\" ]; then
export \${envname}=\"\${envval}\"
else
export \${envname}=\"\${envval}\":\${!envname}
fi
}
load_toast () {
# Location of the software stack
prefix=${PREFIX}
# Python major/minor version for site-packages
pysite=\$(python3 --version 2>&1 | sed -e \"s#Python \(.*\)\.\(.*\)\..*#\1.\2#\")
# Add software stack to the environment
prepend_env \"PATH\" \"\${prefix}/bin\"
prepend_env \"CPATH\" \"\${prefix}/include\"
prepend_env \"LD_LIBRARY_PATH\" \"\${prefix}/lib\"
prepend_env \"PYTHONPATH\" \"\${prefix}/lib/python\${pysite}/site-packages\"
}
" > "${PREFIX}/init.sh"
# Now print out some reminder information about loading these tools
echo "
TOAST dependencies have been installed to:
${PREFIX}
You need to load this location into your environment before
installing TOAST. You can do this by sourcing the generated
shell file:
%> . ${PREFIX}/init.sh
"