/
petsc.sh
executable file
·203 lines (192 loc) · 5.71 KB
/
petsc.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
#!/bin/sh
#
# Build and install the PETSc library.
#
# Copyright 2019, 2020, 2021 Hewlett Packard Enterprise Development LP.
####
PACKAGE=petsc
VERSIONS='
3.10.3:f03650ea5592313dd2b8be7ae9cc498369da660185b58f9e98689a9bc355e982
3.10.5:6fa0574aebc6e6cb4eea206ef9a3a6037e20e8b54ca91346628a37f79af1407f
3.11.4:006177b4059cd40310a3e9a4bf475f3a8c276b62d8cca4df272ef88bdfc2f83a
3.12.5:b4e9aae06b1a343bc5a7fee975f391e7dbc7086fccc684068b5e0204ffa3ecad
3.13.6:67ca2cf3040d08fdc51d27f660ea3157732b24c2f47aae1b19d63f62a39842c2
3.14.4:b030969816e02c251a6d010c07a90b69ade44932f9ddfac3090ff5e95ab97d5c
'
_pwd(){ CDPATH= cd -- $1 && pwd; }
_dirname(){ _d=`dirname -- "$1"`; _pwd $_d; }
top_dir=`_dirname "$0"`
. $top_dir/.preamble.sh
##
## Requirements:
## - cmake
## - MPI
## - BLAS
## - ScaLAPACK
## - TPSL (superlu, superlu-dist, metis, parmetis, ptscotch, mumps, hypre, sundials)
## - hdf5
##
fn_check_includes()
{
cat >conftest.c <<EOF
#include <$2>
EOF
{ cc -E -I$prefix/include conftest.c >/dev/null 2>&1 && rm conftest.* ; } \
|| fn_error "requires $1"
}
fn_check_link()
{
cat >conftest.c <<EOF
int $2();
int main(){ $2(); }
EOF
{ cc -L$prefix/lib $LDFLAGS conftest.c $LIBS >/dev/null 2>&1 && rm conftest.* ; } \
|| fn_error "requires $1"
}
cmake --version >/dev/null 2>&1 \
|| fn_error "requires cmake"
fn_check_link BLAS dgemm_
fn_check_link ScaLAPACK pdgetrf_
fn_check_includes MPI mpi.h
fn_check_includes METIS metis.h
fn_check_includes ParMETIS parmetis.h
fn_check_includes SuperLU slu_ddefs.h
fn_check_includes SuperLU_DIST superlu_dist_config.h
fn_check_includes PT-Scotch ptscotch.h
fn_check_includes MUMPS mumps_c_types.h
fn_check_includes HYPRE HYPRE.h
fn_check_includes SUNDIALS sundials/sundials_types.h
fn_check_includes HDF5 hdf5.h
test -e petsc-lite-$VERSION.tar.gz \
|| $WGET http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-$VERSION.tar.gz \
|| fn_error "could not fetch source"
echo "$SHA256SUM petsc-lite-$VERSION.tar.gz" | sha256sum --check \
|| fn_error "source hash mismatch"
tar xf petsc-lite-$VERSION.tar.gz \
|| fn_error "could not untar source"
cd petsc-$VERSION
: ${CRAY_CPU_TARGET=`uname -m`}
case "$CRAY_CPU_TARGET" in
x86-64|x86_64)
level1_dcache_assoc=4
level1_dcache_linesize=64
level1_dcache_size=16384
;;
sandybridge|ivybridge|haswell|aarch64)
level1_dcache_assoc=0
level1_dcache_linesize=32
level1_dcache_size=32768
;;
*skylake*|mic*)
configure_flags="$configure_flags --with-avx512-kernels"
level1_dcache_assoc=8
level1_dcache_linesize=32
level1_dcache_size=32768
;;
esac
case "$compiler" in
cray)
# PETSc will fail to discover some libraries, e.g. MPICH, if the
# preprocessor issues warnings.
CPPFLAGS="-hnomessage=11709 $CPPFLAGS"
;;
crayclang)
# Similarly:
CPPFLAGS="-Wno-unused-command-line-argument $CPPFLAGS"
;;
intel)
# For proper linking of fortran against c++
LIBS="-lstdc++"
;;
esac
case "$compiler" in
cray|pgi) mpi_long_double=0 ;;
*) mpi_long_double=1 ;;
esac
cat >configure-petsc.sh <<EOF
#!/bin/sh
exec ./configure \\
--known-has-attribute-aligned=1 \\
--known-mpi-int64_t=0 \\
--known-bits-per-byte=8 \\
--known-64-bit-blas-indices=0 \\
--known-sdot-returns-double=0 \\
--known-snrm2-returns-double=0 \\
--known-level1-dcache-assoc=${level1_dcache_assoc:-4} \\
--known-level1-dcache-linesize=${level1_dcache_linesize:-64} \\
--known-level1-dcache-size=${level1_dcache_size:-16384} \\
--known-memcmp-ok=1 \\
--known-mpi-c-double-complex=1 \\
--known-mpi-long-double=$mpi_long_double \\
--known-mpi-shared-libraries=0 \\
--known-sizeof-MPI_Comm=4 \\
--known-sizeof-MPI_Fint=4 \\
--known-sizeof-char=1 \\
--known-sizeof-double=8 \\
--known-sizeof-float=4 \\
--known-sizeof-int=4 \\
--known-sizeof-long-long=8 \\
--known-sizeof-long=8 \\
--known-sizeof-short=2 \\
--known-sizeof-size_t=8 \\
--known-sizeof-void-p=8 \\
--with-ar=ar \\
--with-batch=1 \\
--with-cc=cc \\
--with-clib-autodetect=0 \\
--with-cxx=CC \\
--with-cxxlib-autodetect=0 \\
--with-debugging=0 \\
--with-dependencies=0 \\
--with-fc=ftn \\
--with-fortran-datatypes=0 \\
--with-fortran-interfaces=0 \\
--with-fortranlib-autodetect=1 \\
--with-ranlib=ranlib \\
--with-scalar-type=real \\
--with-shared-ld=ar \\
--with-etags=0 \\
--with-x=0 \\
--with-ssl=0 \\
--with-shared-libraries=0 \\
--with-mpi-lib=[] \\
--with-mpi-include=[] \\
--with-blas-lapack=1 \\
--with-superlu=1 \\
--with-superlu-dir=$prefix \\
--with-superlu_dist=1 \\
--with-superlu_dist-dir=$prefix \\
--with-parmetis=1 \\
--with-metis=1 \\
--with-metis-dir=$prefix \\
--with-scalapack=1 \\
--with-ptscotch=1 \\
--with-ptscotch-include=$prefix/include \\
--with-ptscotch-lib="-L$prefix/lib -lptscotch -lscotch -lptscotcherr -lscotcherr" \\
--with-mumps=1 \\
--with-mumps-include=$prefix/include \\
--with-mumps-lib="-L$prefix/lib -lcmumps -ldmumps -lesmumps -lsmumps -lzmumps -lmumps_common -lptesmumps -lesmumps -lpord" \\
--with-hdf5=1 \\
--CFLAGS="$CFLAGS $OMPFLAG" \\
--CPPFLAGS="-I$prefix/include $CPPFLAGS" \\
--CXXFLAGS="$CFLAGS $OMPFLAG" \\
--with-cxx-dialect=C++11 \\
--FFLAGS="$FFLAGS $FOMPFLAG" \\
--LDFLAGS="-L$prefix/lib $OMPFLAG" \\
--LIBS="$PE_LIBS $LIBS -lstdc++" \\
--PETSC_ARCH="$CRAY_CPU_TARGET" \\
--prefix=$prefix${configure_flags+ \\
$configure_flags}
EOF
test "$?" = "0" \
&& chmod +x configure-petsc.sh \
&& ./configure-petsc.sh \
|| fn_error "configuration failed"
make MAKE_NP=$make_jobs PETSC_DIR=`pwd` PETSC_ARCH=$CRAY_CPU_TARGET all \
|| fn_error "build failed"
make PETSC_DIR=`pwd` PETSC_ARCH=$CRAY_CPU_TARGET install \
|| fn_error "install failed"
# Local Variables:
# indent-tabs-mode:nil
# sh-basic-offset:2
# End: