-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathwscript
executable file
·375 lines (352 loc) · 15.2 KB
/
wscript
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
365
366
367
368
369
370
371
372
373
374
375
import os
def options(opt):
opt.load('compiler_c compiler_fc')
opt.load('compiler_cxx')
mkl=opt.add_option_group('MKL Options')
mkl.add_option('--mkl-dir',
help='Base directory where mkl is installed')
mkl.add_option('--mkl-incdir',
help='Directory where mkl include files are installed')
mkl.add_option('--mkl-libdir',
help='Directory where mkl library files are installed')
mkl.add_option('--mkl-libs',
help='Names of the mkl libraries without prefix or suffix\n'
'(e.g. "mkl_intel_lp64 mkl_intel_thread mkl_core"')
fftw=opt.add_option_group('FFTW Options')
fftw.add_option('--use-fftw', action='store_true', default=False,
help='Use FFTW instead of MKL')
fftw.add_option('--fftw-dir',
help='Base directory where fftw is installed')
fftw.add_option('--fftw-incdir',
help='Directory where fftw include files are installed')
fftw.add_option('--fftw-libdir',
help='Directory where fftw library files are installed')
cuda=opt.add_option_group('CUDA Options')
cuda.add_option('--use-cuda', action='store_true', default=False,
help='Uses GPU for computation')
cuda.add_option('--cuda-dir',
help='Base Directory where the cuda is installed')
cuda.add_option('--cuda-incdir',
help='Directory where cuda include files are installed.')
cuda.add_option('--cuda-libdir',
help='Directory where cuda library files are installed')
papi=opt.add_option_group('PAPI Options')
papi.add_option('--use-papi', action='store_true', default=False,
help='Use PAPI for profiling')
papi.add_option('--papi-dir',
help='Base directory where papi is installed')
papi.add_option('--papi-incdir',
help='Directory where papi include files are installed')
papi.add_option('--papi-libdir',
help='Directory where papi library files are installed')
netcdf=opt.add_option_group('NETCDF Options')
netcdf.add_option('--netcdf-dir',
help='Base directory where NETCDF is installed')
netcdf.add_option('--netcdf-incdir',
help='Directory where NETCDF include files are installed')
netcdf.add_option('--netcdf-libdir',
help='Directory where NETCDF library files are installed')
other=opt.add_option_group('Other Options')
other.add_option('--openmp-flag',
help="C and Fortran compiler flag for OpenMP")
other.add_option('--cpp-flag',
help="Fortran compiler flag to run the C preprocessor")
other.add_option('--use-ctfft', action='store_true', default=False,
help='Use slow internal CTFFT instead of MKL or FFTW')
other.add_option('--length-flag',
help='Fortran compiler option to allow unlimited line length')
other.add_option('--relax-lite', action='store_true', default=False,
help="Generating the relax library")
def configure(cnf):
cnf.load('compiler_c compiler_fc')
cnf.load('compiler_cxx')
# We set the flags here
if not cnf.env.CFLAGS:
cnf.env.CFLAGS=['-O3','-fPIC']
if not cnf.env.FCFLAGS:
cnf.env.FCFLAGS=['-O3']
cnf.check_fortran()
# Find NETCDF
if not cnf.options.relax_lite:
if cnf.options.netcdf_dir:
if not cnf.options.netcdf_incdir:
cnf.options.netcdf_incdir=cnf.options.netcdf_dir + "/include"
if not cnf.options.netcdf_libdir:
cnf.options.netcdf_libdir=cnf.options.netcdf_dir + "/lib"
if cnf.options.netcdf_incdir:
includedirs=[cnf.options.netcdf_incdir]
else:
includedirs=['','/usr/include/netcdf']
found_netcdf=False
for inc in includedirs:
try:
netcdf_frag="PROGRAM MAIN\n" + 'USE netcdf\n' \
+ "END PROGRAM MAIN\n"
cnf.check_fc(msg="Checking for netcdf.mod",
includes=[inc], fragment=netcdf_frag, uselib_store='netcdf',
libpath=[cnf.options.netcdf_libdir],
rpath=[cnf.options.netcdf_libdir],
lib=['netcdff'])
except cnf.errors.ConfigurationError:
pass
else:
found_netcdf=True
break
if not found_netcdf:
cnf.fatal('Could not find NETCDF')
#Find Cuda
if cnf.options.use_cuda:
cnf.env.CUDA=cnf.options.use_cuda
cnf.load('cuda',tooldir='.')
if not cnf.env.CUDAFLAGS:
cnf.env.CUDAFLAGS = ['-gencode','arch=compute_35,code=sm_35','-Xcompiler','-fPIC']
# cnf.env.CUDAFLAGS += ['-Xptxas', '-dlcm=cg']
# cnf.env.CUDAFLAGS += ['--maxrregcount=32']
# cnf.env.CUDAFLAGS = ['-gencode','arch=compute_30,code=sm_30']
# cnf.env.CUDAFLAGS = ['-gencode','arch=compute_20,code=sm_20']
cnf.env.CXXFLAGS=['-m64']
if cnf.options.cuda_dir:
if not cnf.options.cuda_incdir:
cnf.options.cuda_incdir=cnf.options.cuda_dir + "/include"
if not cnf.options.cuda_libdir:
cnf.options.cuda_libdir=cnf.options.cuda_dir + "/lib64"
if cnf.options.cuda_incdir:
includedirs=[cnf.options.cuda_incdir]
else:
includedirs=['','/usr/local/cuda/include']
found_cuda=False
for inc in includedirs:
try:
cnf.check_cc(msg="Checking for cuda.h",
header_name='cuda.h', includes=inc,
libpath=[cnf.options.cuda_libdir],
rpath=[cnf.options.cuda_libdir],
lib=['cudart', 'cufft','stdc++'], uselib_store='cuda',
define_name="USING_CUDA")
except cnf.errors.ConfigurationError:
pass
else:
found_cuda=True
break
if not found_cuda:
cnf.fatal('Could not find cuda')
# Find PAPI
if cnf.options.use_papi:
if cnf.options.papi_dir:
if not cnf.options.papi_incdir:
cnf.options.papi_incdir=cnf.options.papi_dir + "/include"
if not cnf.options.papi_libdir:
cnf.options.papi_libdir=cnf.options.papi_dir + "/lib"
if cnf.options.papi_incdir:
includedirs=[cnf.options.papi_incdir]
else:
includedirs=['','/usr/include/papi']
found_papi=False
for inc in includedirs:
try:
cnf.check_cc(msg="Checking for papi.h in '" + inc + "'",
header_name='papi.h', includes=inc,
libpath=[cnf.options.papi_libdir],
rpath=[cnf.options.papi_libdir],
lib=['papi'], uselib_store='papi',define_name="PAPI_PROF")
except cnf.errors.ConfigurationError:
pass
else:
found_papi=True
break
if not found_papi:
cnf.fatal('Could not find papi')
# Find OpenMP
openmp_msg="Checking for openmp flag "
openmp_fragment="program main\n call omp_get_num_threads()\nend program main"
found_openmp=False
openmp_flags=['-fopenmp','-openmp','-mp','-xopenmp','-omp','-qsmp=omp']
if cnf.options.openmp_flag:
openmp_flags=[cnf.options.openmp_flag]
for flag in openmp_flags:
try:
cnf.check_fc(msg=openmp_msg+flag, fragment=openmp_fragment,
fcflags=flag, linkflags=flag, uselib_store='openmp')
except cnf.errors.ConfigurationError:
continue
else:
found_openmp=True
break
if not found_openmp:
cnf.fatal('Could not find OpenMP')
# Find FFTW
#if not cnf.options.use_cuda:
if cnf.options.use_fftw:
if cnf.options.fftw_dir:
if not cnf.options.fftw_incdir:
cnf.options.fftw_incdir=cnf.options.fftw_dir + "/include"
if not cnf.options.fftw_libdir:
cnf.options.fftw_libdir=cnf.options.fftw_dir + "/lib"
frag="program main\n" + 'include "fftw3.f"\n' \
+ "end program main\n"
if cnf.options.fftw_incdir:
inc=cnf.options.fftw_incdir
else:
inc='/usr/include'
cnf.check_fc(msg="Checking for fftw",
includes=[inc], fragment=frag, uselib_store='fftw',
libpath=[cnf.options.fftw_libdir],
rpath=[cnf.options.fftw_libdir],
lib=['fftw3f','fftw3f_threads'], define_name="FFTW3")
# Find MKL
elif not cnf.options.use_ctfft:
if cnf.options.mkl_dir:
if not cnf.options.mkl_incdir:
cnf.options.mkl_incdir=cnf.options.mkl_dir + "/include"
if not cnf.options.mkl_libdir:
cnf.options.mkl_libdir=cnf.options.mkl_dir + "/lib"
if cnf.options.mkl_libs:
libs=cnf.options.mkl_libs.split()
else:
libs=['mkl_intel_lp64', 'mkl_intel_thread',
'mkl_core']
cnf.check_fc(msg="Checking for MKL", lib=libs,
uselib_store='imkl',
includes=[cnf.options.mkl_incdir],
libpath=[cnf.options.mkl_libdir],
rpath=[cnf.options.mkl_libdir],
use='openmp', define_name='IMKL_FFT')
# Check for C preprocessor option
frag="program main\n INTEGER :: foo\n" + "end program main\n"
cpp_flags=['-cpp','-Mpreprocess','-fpic']
if cnf.options.cpp_flag:
cpp_flags=[cnf.options.cpp_flag]
found_cpp=False
for flag in cpp_flags:
try:
cnf.check_fc(fragment=frag,msg="Checking preprocessor option " + flag,
fcflags=flag,uselib_store='cpp')
except:
continue
else:
found_cpp=True
break
if not found_cpp:
cnf.fatal("Could not find an option for running the C preprocessor")
# Check for line length option
frag="program main\n" +" WRITE(*,*) \" \"\n" + "end program main\n"
length_flags=['','-ffree-line-length-none']
if cnf.options.length_flag:
length_flags=[cnf.options.length_flag]
found_length=False
for flag in length_flags:
try:
cnf.check_fc(fragment=frag,msg="Checking length option " + flag,
fcflags=flag,uselib_store='length')
except:
continue
else:
found_length=True
break
if not found_length:
cnf.fatal("Could not find an option for allowing long lines")
cnf.write_config_header('config.h')
def lite(ctx) :
if(ctx.env.CUDA):
ctx.shlib(features='c fc fcprogram cxx',
source=['src/curelaxlite.f90',
'src/ctfft.f',
'src/types.f90',
'src/fourier.f90',
'src/green.f90',
'src/okada/green_space.f90',
'src/okada/dc3d.f',
'src/elastic3d.f90',
'src/friction3d.f90',
'src/viscoelastic3d.f90',
'src/getdata.f',
'src/getopt_m.f90',
'src/util.f90',
'src/mkl_dfti.f90',
'src/cugreen.cu',
'src/cuelastic.cu'],
install_path='${PREFIX}/bin',
includes=['build'],
use=['openmp','fftw','imkl','cpp','length','cuda','papi','stdc++'],
target='librelax.so'
)
else:
ctx.shlib(features='c fc fcprogram',
source=['src/relaxlite.f90',
'src/ctfft.f',
'src/types.f90',
'src/fourier.f90',
'src/green.f90',
'src/okada/green_space.f90',
'src/okada/dc3d.f',
'src/elastic3d.f90',
'src/friction3d.f90',
'src/viscoelastic3d.f90',
'src/getdata.f',
'src/getopt_m.f90',
'src/util.f90',
'src/mkl_dfti.f90'],
install_path='${PREFIX}/bin',
includes=['build'],
use=['openmp','fftw','imkl','cpp','length','papi','stdc++'],
target='librelax.so'
)
from waflib.Build import BuildContext
class miracle(BuildContext):
cmd = 'lite'
fun = 'lite'
def build(bld):
if bld.env.CUDA:
bld.program(features='c fc fcprogram cxx',
source=['src/curelax.f90',
'src/ctfft.f',
'src/types.f90',
'src/fourier.f90',
'src/green.f90',
'src/okada/green_space.f90',
'src/okada/dc3d.f',
'src/elastic3d.f90',
'src/friction3d.f90',
'src/viscoelastic3d.f90',
'src/writevtk.c',
'src/exportnetcdf.f90',
'src/export.f90',
'src/getdata.f',
'src/getopt_m.f90',
'src/input.f90',
'src/util.f90',
'src/mkl_dfti.f90',
'src/papi_prof.c',
'src/cugreen.cu',
'src/cuelastic.cu'],
install_path='${PREFIX}/bin',
includes=['build'],
use=['netcdf','openmp','fftw','imkl','cpp','length','cuda','papi','stdc++'],
target='relax'
)
else:
bld.program(features='c fc fcprogram',
source=['src/relax.f90',
'src/ctfft.f',
'src/types.f90',
'src/fourier.f90',
'src/green.f90',
'src/okada/green_space.f90',
'src/okada/dc3d.f',
'src/elastic3d.f90',
'src/friction3d.f90',
'src/viscoelastic3d.f90',
'src/writevtk.c',
'src/exportnetcdf.f90',
'src/export.f90',
'src/getdata.f',
'src/getopt_m.f90',
'src/input.f90',
'src/util.f90',
'src/mkl_dfti.f90',
'src/papi_prof.c'],
install_path='${PREFIX}/bin',
includes=['build'],
use=['netcdf','openmp','fftw','imkl','cpp','length','papi','stdc++'],
target='relax'
)