-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathpetsc.py
More file actions
215 lines (193 loc) · 8.9 KB
/
petsc.py
File metadata and controls
215 lines (193 loc) · 8.9 KB
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
from hashdist import build_stage
def preConfigureCrayXE6(ctx, conf_lines):
conf_lines += ['LDFLAGS=' + ctx.parameters['DYNAMIC_EXE_LINKER_FLAGS'],
'--known-mpi-shared-libraries=1',
'--with-batch',
'--known-sdot-returns-double=0',
'--known-snrm2-returns-double=0',
'--known-level1-dcache-size=16384',
'--known-level1-dcache-linesize=64',
'--known-level1-dcache-assoc=4',
'--known-memcmp-ok=1',
'--known-sizeof-char=1',
'--known-sizeof-void-p=8',
'--known-sizeof-short=2',
'--known-sizeof-int=4',
'--known-sizeof-long=8',
'--known-sizeof-long-long=8',
'--known-sizeof-float=4',
'--known-sizeof-double=8',
'--known-sizeof-size_t=8',
'--known-bits-per-byte=8',
'--known-sizeof-MPI_Comm=4',
'--known-sizeof-MPI_Fint=4',
'--known-mpi-long-double=1',
'--known-mpi-c-double-complex=1',
'--known-mpi-int64_t=1',
'--with-pthread=1']
def preConfigureCrayXC30(ctx, conf_lines):
conf_lines += ['LDFLAGS=' + ctx.parameters['DYNAMIC_EXE_LINKER_FLAGS'],
'--known-mpi-shared-libraries=1',
'--with-batch',
'--known-sdot-returns-double=0',
'--known-snrm2-returns-double=0',
'--known-level1-dcache-size=16384',
'--known-level1-dcache-linesize=64',
'--known-level1-dcache-assoc=4',
'--known-memcmp-ok=1',
'--known-sizeof-char=1',
'--known-sizeof-void-p=8',
'--known-sizeof-short=2',
'--known-sizeof-int=4',
'--known-sizeof-long=8',
'--known-sizeof-long-long=8',
'--known-sizeof-float=4',
'--known-sizeof-double=8',
'--known-sizeof-size_t=8',
'--known-bits-per-byte=8',
'--known-sizeof-MPI_Comm=4',
'--known-sizeof-MPI_Fint=4',
'--known-mpi-long-double=1',
'--known-mpi-c-double-complex=1',
'--known-mpi-int64_t=1',
'--with-pthread=1']
def preConfigureSGIICEX(ctx, conf_lines):
conf_lines += ['LDFLAGS=' + ctx.parameters['DYNAMIC_EXE_LINKER_FLAGS'],
'--known-mpi-shared-libraries=1',
'--with-pic',
'--with-batch',
'--known-level1-dcache-size=16384',
'--known-level1-dcache-linesize=64',
'--known-level1-dcache-assoc=4',
'--known-memcmp-ok=1',
'--known-sizeof-char=1',
'--known-sizeof-void-p=8',
'--known-sizeof-short=2',
'--known-sizeof-int=4',
'--known-sizeof-long=8',
'--known-sizeof-long-long=8',
'--known-sizeof-float=4',
'--known-sizeof-double=8',
'--known-sizeof-size_t=8',
'--known-bits-per-byte=8',
'--known-sizeof-MPI_Comm=4',
'--known-sizeof-MPI_Fint=4',
'--known-mpi-long-double=1',
'--known-mpi-c-double-complex=1',
'--known-mpi-int64_t=1',
'--with-pthread=1',
'--with-blas-lapack-lib=[mkl_rt]']
@build_stage()
def configure(ctx, stage_args):
"""
Generates PETSc ./configure line.
Example::
- name: configure
coptflags: -O2
link: shared
debug: false
Note: this is a fairly sophisticated build stage that inspects
the build artifacts available to decide what to enable in PETSc.
By default, this package builds PETSc with all required artifacts,
debugging support enabled, and shared libraries enabled. The
following extra keys are relevant:
* coptflags: Fine-grained control over PETSc's C optimization
flags. Left unspecified by default.
* link: Build shared or static libraries. Shared by default.
* debug: Enable/disable debugging. true by default.
* download: A list of packages to instruct PETSc to download and
build. These will not be readily available outside PETSc.
"""
# PETSc queries TMPDIR, which is not always a useful place to put
# temporaries. Here, we force PETSc to use our ./_tmp directory
# as its temporary directory. This configuration change may be of
# general use for the other build systems.
conf_lines = ['mkdir ${PWD}/_tmp && TMPDIR=${PWD}/_tmp',
'./configure --prefix="${ARTIFACT}"']
if ctx.parameters.get('machine','') == 'CrayXE6':
preConfigureCrayXE6(ctx, conf_lines)
elif ctx.parameters.get('machine','') == 'CrayXC30':
preConfigureCrayXC30(ctx, conf_lines)
elif ctx.parameters.get('machine','') == 'SGIICEX':
preConfigureSGIICEX(ctx, conf_lines)
if stage_args['coptflags']:
conf_lines.append('COPTFLAGS=%s' % stage_args['coptflags'])
if stage_args['link']:
conf_lines.append('--with-shared-libraries=%d' %
bool(stage_args['link'] == 'shared'))
# must explicitly set --with-debugging=0 to disable debugging
conf_lines.append('--with-debugging=%d' % stage_args['debug'])
# Special case, openssl provides ssl
if 'OPENSSL' in ctx.dependency_dir_vars:
conf_lines.append('--with-ssl=1')
conf_lines.append('--with-ssl-dir=${OPENSSL_DIR}')
else:
# Disable ssl when not a dependency
conf_lines.append('--with-ssl=0')
# Special case, --with-blas-dir does not work with OpenBLAS
if 'OPENBLAS' in ctx.dependency_dir_vars:
if ctx.parameters['platform'] == 'Darwin':
libopenblas = '${OPENBLAS_DIR}/lib/libopenblas.dylib'
else:
libopenblas = '${OPENBLAS_DIR}/lib/libopenblas.so'
conf_lines.append('--with-blas-lapack-lib=%s' % libopenblas)
else:
# Special case, no meaningful BLAS/LAPACK directories when using Accelerate
if ctx.parameters['platform'] != 'Darwin':
conf_lines.append('--with-blas-dir=$BLAS_DIR')
conf_lines.append('--with-lapack-dir=$LAPACK_DIR')
# Special case, ParMETIS also provides METIS
if 'PARMETIS' in ctx.dependency_dir_vars:
conf_lines.append('--with-metis-dir=$PARMETIS_DIR')
conf_lines.append('--with-parmetis-dir=$PARMETIS_DIR')
# Special case, SCOTCH also provides PTSCOTCH
if 'SCOTCH' in ctx.dependency_dir_vars:
conf_lines.append('--with-scotch-dir=${SCOTCH_DIR}')
conf_lines.append('--with-ptscotch-dir=${SCOTCH_DIR}')
# Special case, Trilinos provides ML
if 'TRILINOS' in ctx.dependency_dir_vars:
if ctx.parameters['platform'] == 'Darwin':
libml = '${TRILINOS_DIR}/lib/libml.dylib'
else:
libml = '${TRILINOS_DIR}/lib/libml.so'
conf_lines.append('--with-ml=1')
conf_lines.append('--with-ml-lib=%s' % libml)
conf_lines.append('--with-ml-include=${TRILINOS_DIR}/include/trilinos')
if 'SUITESPARSE' in ctx.dependency_dir_vars:
conf_lines.append('--with-suitesparse=1')
conf_lines.append('--with-suitesparse-include=${SUITESPARSE_DIR}/include/suitesparse')
conf_lines.append('--with-suitesparse-lib=[${SUITESPARSE_DIR}/lib/libumfpack.a,libklu.a,libcholmod.a,libbtf.a,libccolamd.a,libcolamd.a,libcamd.a,libamd.a,libsuitesparseconfig.a]')
if 'HYPRE' in ctx.dependency_dir_vars:
if ctx.parameters['platform'] == 'Darwin':
libHYPRE = '${HYPRE_DIR}/lib/libHYPRE.a'
else:
libHYPRE = '${HYPRE_DIR}/lib/libHYPRE.so'
conf_lines.append('--with-hypre=1')
conf_lines.append('--with-hypre-include=${HYPRE_DIR}/include')
conf_lines.append('--with-hypre-lib=%s' % libHYPRE)
for dep_var in ctx.dependency_dir_vars:
if dep_var in ['BLAS', 'HYPRE', 'LAPACK', 'OPENBLAS', 'PARMETIS',
'SCOTCH', 'TRILINOS', 'SUITESPARSE']:
continue
if dep_var == 'MPI':
conf_lines.append('--with-mpi-compilers')
conf_lines.append('CC=$MPICC')
conf_lines.append('CXX=$MPICXX')
if ctx.parameters['fortran']:
conf_lines.append('F77=$MPIF77')
conf_lines.append('F90=$MPIF90')
conf_lines.append('FC=$MPIF90')
else:
conf_lines.append('--with-fc=0')
continue
conf_lines.append('--with-%s-dir=$%s_DIR' %
(dep_var.lower(),
dep_var))
for package in stage_args['download']:
package_name = package.strip()
conf_lines.append('--download-%s=1' % package_name)
# Multilinify
for i in range(len(conf_lines) - 1):
conf_lines[i] = conf_lines[i] + ' \\'
conf_lines[i + 1] = ' ' + conf_lines[i + 1]
return conf_lines