/[escript]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6739 - (show annotations)
Wed Nov 7 23:58:41 2018 UTC (4 months, 2 weeks ago) by aellery
File size: 33186 byte(s)
I have removed support for boomerAMG from eScript. Specific changes are:

i) I have removed the definition of the variables "boomeramg", "boomeramg_prefix" and "boomeramg_libs" from SConstruct as well as the boomerAMG section of dependencies.py. Similarly, I have removed the boomerAMG section of paso/src/SConscript. Also, I have removed boomeramg from the report that scons prints out after compilation.
ii) I have removed the enum SO_PRECONDITIONER_BOOMERAMG from escriptcpp.cpp 
iii) I have removed the enum SO_PRECONDITIONER_BOOMERAMG from escriptcore/src/SolverOptions.h and have updated a few comments.
iv) I have removed the case for SO_PRECONDITIONER_BOOMERAMG from the switches in SolverBuddy::getSummary(), SolverBuddy::getName() and SolverBuddy::setPreconditioner() in SolverOptions.cpp
v) In paso/src/Preconditioner.h, I have redefined the structure Preconditioner_AMG_Root so that it does not include a pointer to a Preconditioner_BoomerAMG.
vi) I have updated a couple of files in paso (AMG.cpp, AMG_Root.cpp) to reflect the changes in this structure (specifically, the fact that prec->boomeramg is now meaningless).
vii) I have removed a preprocessor directive in paso/src/Options.h (#define PASO_BOOMERAMG 60) and have updated paso/src/Options.cpp to reflect this change by removing this case from several switches.
viii) The files paso/src/BOOMERAMG.h and paso/src/BOOMERAMG.cpp have been removed from the latest commit.

On meerkat, with these changes, escripts compiles without any problems.



1 ##############################################################################
2 #
3 # Copyright (c) 2003-2018 by The University of Queensland
4 # http://www.uq.edu.au
5 #
6 # Primary Business: Queensland, Australia
7 # Licensed under the Apache License, version 2.0
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 # Development 2012-2013 by School of Earth Sciences
12 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 #
14 ##############################################################################
15
16 EnsureSConsVersion(0,98,1)
17 EnsurePythonVersion(2,5)
18
19 import atexit, sys, os, platform, re
20 from distutils import sysconfig
21 from dependencies import *
22 from site_init import *
23
24 print(sys.version)
25
26 # Version number to check for in options file. Increment when new features are
27 # added or existing options changed.
28 REQUIRED_OPTS_VERSION=203
29
30 # MS Windows support, many thanks to PH
31 IS_WINDOWS = (os.name == 'nt')
32
33 IS_OSX = (os.uname()[0] == 'Darwin')
34
35 ########################## Determine options file ############################
36 # 1. command line
37 # 2. scons/<hostname>_options.py
38 # 3. name as part of a cluster
39 options_file=ARGUMENTS.get('options_file', None)
40 if not options_file:
41 ext_dir = os.path.join(os.getcwd(), 'scons')
42 hostname = platform.node().split('.')[0]
43 for name in hostname, effectiveName(hostname):
44 mangledhostname = re.sub('[^0-9a-zA-Z]', '_', hostname)
45 options_file = os.path.join(ext_dir, mangledhostname+'_options.py')
46 if os.path.isfile(options_file): break
47
48 if not os.path.isfile(options_file):
49 print("\nWARNING:\nOptions file %s" % options_file)
50 print("not found! Default options will be used which is most likely suboptimal.")
51 print("We recommend that you copy the most relavent options file in the scons/template/")
52 print("subdirectory and customize it to your needs.\n")
53 options_file = None
54
55 ############################### Build options ################################
56
57 default_prefix='/usr'
58 mpi_flavours=('no', 'none', 'MPT', 'MPICH', 'MPICH2', 'OPENMPI', 'INTELMPI')
59 netcdf_flavours = ('no', 'off', 'none', 'False', # Must be last of the false alternatives
60 'yes', 'on', 'True', '3', # Must be last of the version 3 alternatives
61 '4')
62 all_domains = ['dudley','finley','ripley','speckley']
63
64 #Note that scons construction vars the the following purposes:
65 # CPPFLAGS -> to the preprocessor
66 # CCFLAGS -> flags for _both_ C and C++
67 # CXXFLAGS -> flags for c++ _only_
68 # CFLAGS -> flags for c only
69
70 vars = Variables(options_file, ARGUMENTS)
71 vars.AddVariables(
72 PathVariable('options_file', 'Path to options file', options_file, PathVariable.PathIsFile),
73 PathVariable('prefix', 'Installation prefix', Dir('#.').abspath, PathVariable.PathIsDirCreate),
74 PathVariable('build_dir', 'Top-level build directory', Dir('#/build').abspath, PathVariable.PathIsDirCreate),
75 BoolVariable('verbose', 'Output full compile/link lines', False),
76 # Compiler/Linker options
77 ('cxx', 'Path to C++ compiler', 'default'),
78 ('cc_flags', 'Base (C and C++) compiler flags', 'default'),
79 ('cc_optim', 'Additional (C and C++) flags for a non-debug build', 'default'),
80 ('cc_debug', 'Additional (C and C++) flags for a debug build', 'default'),
81 ('cxx_extra', 'Extra C++ compiler flags', ''),
82 ('ld_extra', 'Extra linker flags', ''),
83 ('nvcc', 'Path to CUDA compiler', 'default'),
84 ('nvccflags', 'Base CUDA compiler flags', 'default'),
85 BoolVariable('werror','Treat compiler warnings as errors', True),
86 BoolVariable('debug', 'Compile with debug flags', False),
87 BoolVariable('openmp', 'Compile parallel version using OpenMP', False),
88 ('omp_flags', 'OpenMP compiler flags', 'default'),
89 ('omp_ldflags', 'OpenMP linker flags', 'default'),
90 # Mandatory libraries
91 ('boost_prefix', 'Prefix/Paths of boost installation', default_prefix),
92 ('boost_libs', 'Boost libraries to link with', ['boost_python-mt']),
93 # Mandatory for tests
94 ('cppunit_prefix', 'Prefix/Paths of CppUnit installation', default_prefix),
95 ('cppunit_libs', 'CppUnit libraries to link with', ['cppunit']),
96 # Optional libraries and options
97 EnumVariable('mpi', 'Compile parallel version using MPI flavour', 'none', allowed_values=mpi_flavours),
98 ('mpi_prefix', 'Prefix/Paths of MPI installation', default_prefix),
99 ('mpi_libs', 'MPI shared libraries to link with', ['mpi']),
100 BoolVariable('cuda', 'Enable GPU code with CUDA (requires thrust)', False),
101 ('cuda_prefix', 'Prefix/Paths to NVidia CUDA installation', default_prefix),
102 EnumVariable('netcdf', 'Enable netCDF file support', False, allowed_values=netcdf_flavours),
103 ('netcdf_prefix', 'Prefix/Paths of netCDF installation', default_prefix),
104 ('netcdf_libs', 'netCDF libraries to link with', 'DEFAULT'),
105 BoolVariable('parmetis', 'Enable ParMETIS (requires MPI)', False),
106 ('parmetis_prefix', 'Prefix/Paths of ParMETIS installation', default_prefix),
107 ('parmetis_libs', 'ParMETIS libraries to link with', ['parmetis', 'metis']),
108 BoolVariable('mkl', 'Enable the Math Kernel Library', False),
109 ('mkl_prefix', 'Prefix/Paths to MKL installation', default_prefix),
110 ('mkl_libs', 'MKL libraries to link with', ['mkl_solver','mkl_em64t','guide','pthread']),
111 BoolVariable('umfpack', 'Enable UMFPACK', False),
112 ('umfpack_prefix', 'Prefix/Paths to UMFPACK installation', default_prefix),
113 ('umfpack_libs', 'UMFPACK libraries to link with', ['umfpack']),
114 TristateVariable('lapack', 'Enable LAPACK', 'auto'),
115 ('lapack_prefix', 'Prefix/Paths to LAPACK installation', default_prefix),
116 ('lapack_libs', 'LAPACK libraries to link with', []),
117 BoolVariable('silo', 'Enable the Silo file format in weipa', False),
118 ('silo_prefix', 'Prefix/Paths to Silo installation', default_prefix),
119 ('silo_libs', 'Silo libraries to link with', ['siloh5', 'hdf5']),
120 BoolVariable('trilinos', 'Enable the Trilinos solvers', False),
121 ('trilinos_prefix', 'Prefix/Paths to Trilinos installation', default_prefix),
122 ('trilinos_libs', 'Trilinos libraries to link with', []),
123 BoolVariable('visit', 'Enable the VisIt simulation interface', False),
124 ('visit_prefix', 'Prefix/Paths to VisIt installation', default_prefix),
125 ('visit_libs', 'VisIt libraries to link with', ['simV2']),
126 ListVariable('domains', 'Which domains to build', 'all', all_domains),
127 BoolVariable('paso', 'Build Paso solver library', True),
128 BoolVariable('weipa', 'Build Weipa data export library', True),
129 ('mathjax_path', 'Path to MathJax.js file', 'default'),
130 # Advanced settings
131 ('launcher', 'Launcher command (e.g. mpirun)', 'default'),
132 ('prelaunch', 'Command to execute before launcher (e.g. mpdboot)', 'default'),
133 ('postlaunch', 'Command to execute after launcher (e.g. mpdexit)', 'default'),
134 #dudley_assemble_flags = -funroll-loops to actually do something
135 ('dudley_assemble_flags', 'compiler flags for some dudley optimisations', ''),
136 # To enable passing function pointers through python
137 BoolVariable('iknowwhatimdoing', 'Allow non-standard C', False),
138 # An option for specifying the compiler tools
139 ('tools_names', 'Compiler tools to use', ['default']),
140 ('env_export', 'Environment variables to be passed to tools',[]),
141 TristateVariable('forcelazy', 'For testing use only - set the default value for autolazy', 'auto'),
142 TristateVariable('forcecollres', 'For testing use only - set the default value for force resolving collective ops', 'auto'),
143 BoolVariable('build_shared', '(deprecated option, ignored)', True),
144 ('sys_libs', 'Extra libraries to link with', []),
145 ('escript_opts_version', 'Version of options file (do not specify on command line)'),
146 ('SVN_VERSION', 'Do not use from options file', -2),
147 ('pythoncmd', 'which python to compile with', sys.executable),
148 ('pythonlibname', 'Name of the python library to link. (This is found automatically for python2.X.)', ''),
149 ('pythonlibpath', 'Path to the python library. (You should not need to set this unless your python has moved)',''),
150 ('pythonincpath','Path to python include files. (You should not need to set this unless your python has moved',''),
151 BoolVariable('longindices', 'use long indices (for very large matrices)', False),
152 BoolVariable('compressed_files','Enables reading from compressed binary files', True),
153 ('compression_libs', 'Compression libraries to link with', ['boost_iostreams']),
154 BoolVariable('papi', 'Enable PAPI', False),
155 ('papi_prefix', 'Prefix/Paths to PAPI installation', default_prefix),
156 ('papi_libs', 'PAPI libraries to link with', ['papi']),
157 BoolVariable('papi_instrument_solver', 'Use PAPI to instrument each iteration of the solver', False),
158 BoolVariable('osx_dependency_fix', 'Fix dependencies for libraries to have absolute paths (OSX)', False),
159 BoolVariable('stdlocationisprefix', 'Set the prefix as escript root in the launcher', False),
160 BoolVariable('mpi_no_host', 'Do not specify --host in run-escript launcher (only OPENMPI)', False),
161 BoolVariable('insane', 'Instructs scons to not run a sanity check after compilation.', False)
162 )
163
164 ##################### Create environment and help text #######################
165
166 # Intel's compiler uses regular expressions improperly and emits a warning
167 # about failing to find the compilers. This warning can be safely ignored.
168
169 # PATH is needed so the compiler, linker and tools are found if they are not
170 # in default locations.
171 env = Environment(tools = ['default'], options = vars,
172 ENV = {'PATH': os.environ['PATH']})
173
174 # set the vars for clang
175 def mkclang(env):
176 env['CXX']='clang++'
177
178 if env['tools_names'] != ['default']:
179 zz=env['tools_names']
180 if 'clang' in zz:
181 zz.remove('clang')
182 zz.insert(0, mkclang)
183 env = Environment(tools = ['default'] + env['tools_names'], options = vars,
184 ENV = {'PATH' : os.environ['PATH']})
185
186 # Covert env['netcdf'] into one of False, 3, 4
187 # Also choose default values for libraries
188 pos1=netcdf_flavours.index('False')
189 pos2=netcdf_flavours.index('3')
190 mypos=netcdf_flavours.index(env['netcdf'])
191 if 0 <= mypos <=pos1:
192 env['netcdf']=0
193 elif pos1 < mypos <= pos2:
194 env['netcdf']=3
195 if env['netcdf_libs']=='DEFAULT':
196 env['netcdf_libs']=['netcdf_c++', 'netcdf']
197 else: # netcdf4
198 env['netcdf']=4
199 if env['netcdf_libs']=='DEFAULT':
200 env['netcdf_libs']=['netcdf_c++4']
201
202 if options_file:
203 opts_valid=False
204 if 'escript_opts_version' in env.Dictionary() and \
205 int(env['escript_opts_version']) >= REQUIRED_OPTS_VERSION:
206 opts_valid=True
207 if opts_valid:
208 print("Using options in %s." % options_file)
209 else:
210 print("\nOptions file %s" % options_file)
211 print("is outdated! Please update the file after reading scons/templates/README_FIRST")
212 print("and setting escript_opts_version to %d.\n"%REQUIRED_OPTS_VERSION)
213 Exit(1)
214
215 # Generate help text (scons -h)
216 Help(vars.GenerateHelpText(env))
217
218 # Check for superfluous options
219 if len(vars.UnknownVariables())>0:
220 for k in vars.UnknownVariables():
221 print("Unknown option '%s'" % k)
222 Exit(1)
223
224 if env['cuda']:
225 if env['nvcc'] != 'default':
226 env['NVCC'] = env['nvcc']
227 env.Tool('nvcc')
228
229 if 'dudley' in env['domains']:
230 env['domains'].append('finley')
231
232 env['domains'] = sorted(set(env['domains']))
233
234 # create dictionary which will be populated with info for buildvars file
235 env['buildvars'] = {}
236 # create list which will be populated with warnings if there are any
237 env['warnings'] = []
238
239 #################### Make sure install directories exist #####################
240
241 env['BUILD_DIR'] = Dir(env['build_dir']).abspath
242 prefix = Dir(env['prefix']).abspath
243 env['buildvars']['prefix'] = prefix
244 env['incinstall'] = os.path.join(prefix, 'include')
245 env['bininstall'] = os.path.join(prefix, 'bin')
246 env['libinstall'] = os.path.join(prefix, 'lib')
247 env['pyinstall'] = os.path.join(prefix, 'esys')
248 if not os.path.isdir(env['bininstall']):
249 os.makedirs(env['bininstall'])
250 if not os.path.isdir(env['libinstall']):
251 os.makedirs(env['libinstall'])
252 if not os.path.isdir(env['pyinstall']):
253 os.makedirs(env['pyinstall'])
254
255 env.Append(CPPPATH = [env['incinstall']])
256 env.Append(LIBPATH = [env['libinstall']])
257
258 ################# Fill in compiler options if not set above ##################
259
260 if env['cxx'] != 'default':
261 env['CXX'] = env['cxx']
262
263 # default compiler/linker options
264 cc_flags = '-std=c++11'
265 cc_optim = ''
266 cc_debug = ''
267 omp_flags = ''
268 omp_ldflags = ''
269 fatalwarning = '' # switch to turn warnings into errors
270 sysheaderopt = '' # how to indicate that a header is a system header
271
272 # env['CC'] might be a full path
273 cc_name=os.path.basename(env['CXX'])
274
275 if cc_name == 'icpc':
276 # Intel compiler
277 # #1478: class "std::auto_ptr<...>" was declared deprecated
278 # #1875: offsetof applied to non-POD types is nonstandard (in boost)
279 # removed -std=c99 because icpc doesn't like it and we aren't using c anymore
280 cc_flags = "-std=c++11 -fPIC -w2 -wd1875 -wd1478 -Wno-unknown-pragmas"
281 cc_optim = "-Ofast -ftz -fno-alias -xCORE-AVX2 -ipo"
282 #cc_optim = "-Ofast -ftz -fno-alias -inline-level=2 -ipo -xCORE-AVX2"
283 #cc_optim = "-O2 -ftz -fno-alias -inline-level=2"
284 #cc_optim = "-O0 -ftz -fno-alias"
285 #cc_optim = "-O3 -ftz -fno-alias -inline-level=2 -ipo -xHost"
286 cc_debug = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK -DSLOWSHARECHECK"
287 omp_flags = "-qopenmp"
288 omp_ldflags = "-qopenmp" # removing -openmp-report (which is deprecated) because the replacement outputs to a file
289 fatalwarning = "-Werror"
290 elif cc_name[:3] == 'g++':
291 # GNU C++ on any system
292 # note that -ffast-math is not used because it breaks isnan(),
293 # see mantis #691
294 cc_flags = "-std=c++11 -pedantic -Wall -fPIC -Wno-unknown-pragmas -Wno-sign-compare -Wno-system-headers -Wno-long-long -Wno-strict-aliasing -finline-functions"
295 cc_flags += " --param=max-vartrack-size=100000000"
296 cc_optim = "-O3"
297 #max-vartrack-size: avoid vartrack limit being exceeded with escriptcpp.cpp
298 cc_debug = "-g3 -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK -DSLOWSHARECHECK --param=max-vartrack-size=100000000"
299 #Removed because new netcdf doesn't seem to like it
300 #cc_debug += ' -D_GLIBCXX_DEBUG '
301 omp_flags = "-fopenmp"
302 omp_ldflags = "-fopenmp"
303 fatalwarning = "-Werror"
304 sysheaderopt = "-isystem"
305 elif cc_name == 'cl':
306 # Microsoft Visual C on Windows
307 cc_flags = "/EHsc /MD /GR /wd4068 /D_USE_MATH_DEFINES /DDLL_NETCDF"
308 cc_optim = "/O2 /Op /W3"
309 cc_debug = "/Od /RTCcsu /ZI /DBOUNDS_CHECK"
310 fatalwarning = "/WX"
311 elif cc_name == 'icl':
312 # Intel C on Windows
313 cc_flags = '/EHsc /GR /MD'
314 cc_optim = '/fast /Oi /W3 /Qssp /Qinline-factor- /Qinline-min-size=0 /Qunroll'
315 cc_debug = '/Od /RTCcsu /Zi /Y- /debug:all /Qtrapuv'
316 omp_flags = '/Qvec-report0 /Qopenmp /Qopenmp-report0 /Qparallel'
317 omp_ldflags = '/Qvec-report0 /Qopenmp /Qopenmp-report0 /Qparallel'
318
319 env['sysheaderopt']=sysheaderopt
320
321 # set defaults if not otherwise specified
322 if env['cc_flags'] == 'default': env['cc_flags'] = cc_flags
323 if env['cc_optim'] == 'default': env['cc_optim'] = cc_optim
324 if env['cc_debug'] == 'default': env['cc_debug'] = cc_debug
325 if env['omp_flags'] == 'default': env['omp_flags'] = omp_flags
326 if env['omp_ldflags'] == 'default': env['omp_ldflags'] = omp_ldflags
327 if env['cxx_extra'] != '': env.Append(CXXFLAGS = env['cxx_extra'])
328 if env['ld_extra'] != '': env.Append(LINKFLAGS = env['ld_extra'])
329
330 if env['nvccflags'] != 'default':
331 env['NVCCFLAGS'] = env['nvccflags']
332 env['SHNVCCFLAGS'] = env['nvccflags'] + ' -shared'
333
334 if env['longindices']:
335 env.Append(CPPDEFINES = ['ESYS_INDEXTYPE_LONG'])
336
337 # set up the autolazy values
338 if env['forcelazy'] == 1:
339 env.Append(CPPDEFINES=['FAUTOLAZYON'])
340 elif env['forcelazy'] == 0:
341 env.Append(CPPDEFINES=['FAUTOLAZYOFF'])
342
343 # set up the collective resolve values
344 if env['forcecollres'] == 1:
345 env.Append(CPPDEFINES=['FRESCOLLECTON'])
346 elif env['forcecollres'] == 0:
347 env.Append(CPPDEFINES=['FRESCOLLECTOFF'])
348
349 # allow non-standard C if requested
350 if env['iknowwhatimdoing']:
351 env.Append(CPPDEFINES=['IKNOWWHATIMDOING'])
352
353 # Disable OpenMP if no flags provided
354 if env['openmp'] and env['omp_flags'] == '':
355 env['warnings'].append("OpenMP requested but no flags provided - disabling OpenMP!")
356 env['openmp'] = False
357
358 if env['openmp']:
359 env.Append(CCFLAGS = env['omp_flags'])
360 if env['omp_ldflags'] != '': env.Append(LINKFLAGS = env['omp_ldflags'])
361 else:
362 env['omp_flags']=''
363 env['omp_ldflags']=''
364
365 env['buildvars']['openmp']=int(env['openmp'])
366
367 # add debug/non-debug compiler flags
368 env['buildvars']['debug']=int(env['debug'])
369 if env['debug']:
370 env.Append(CCFLAGS = env['cc_debug'])
371 else:
372 env.Append(CCFLAGS = env['cc_optim'])
373
374 # always add cc_flags
375 env.Append(CCFLAGS = env['cc_flags'])
376
377 # add system libraries
378 env.AppendUnique(LIBS = env['sys_libs'])
379
380 # determine svn revision
381 global_revision=ARGUMENTS.get('SVN_VERSION', None)
382 if global_revision:
383 global_revision = re.sub(':.*', '', global_revision)
384 global_revision = re.sub('[^0-9]', '', global_revision)
385 if global_revision == '': global_revision='-2'
386 else:
387 # Get the global Subversion revision number for the getVersion() method
388 try:
389 global_revision = os.popen('svnversion -n .').read()
390 global_revision = re.sub(':.*', '', global_revision)
391 global_revision = re.sub('[^0-9]', '', global_revision)
392 if global_revision == '': global_revision='-2'
393 except:
394 global_revision = '-1'
395 env['svn_revision']=global_revision
396 env['buildvars']['svn_revision']=global_revision
397 env.Append(CPPDEFINES=['SVN_VERSION='+global_revision])
398
399 env['IS_WINDOWS']=IS_WINDOWS
400 env['IS_OSX']=IS_OSX
401
402 ###################### Copy required environment vars ########################
403
404 # Windows doesn't use LD_LIBRARY_PATH but PATH instead
405 if IS_WINDOWS:
406 LD_LIBRARY_PATH_KEY='PATH'
407 env['ENV']['LD_LIBRARY_PATH']=''
408 else:
409 LD_LIBRARY_PATH_KEY='LD_LIBRARY_PATH'
410
411 env['LD_LIBRARY_PATH_KEY']=LD_LIBRARY_PATH_KEY
412
413 # the following env variables are exported for the unit tests
414
415 for key in 'OMP_NUM_THREADS', 'ESCRIPT_NUM_PROCS', 'ESCRIPT_NUM_NODES':
416 try:
417 env['ENV'][key] = os.environ[key]
418 except KeyError:
419 env['ENV'][key] = '1'
420
421 env_export=env['env_export']
422 env_export.extend(['ESCRIPT_NUM_THREADS','ESCRIPT_HOSTFILE','DISPLAY','XAUTHORITY','PATH','HOME','KMP_MONITOR_STACKSIZE','TMPDIR','TEMP','TMP','LD_PRELOAD'])
423
424 for key in set(env_export):
425 try:
426 env['ENV'][key] = os.environ[key]
427 except KeyError:
428 pass
429
430 for key in os.environ.keys():
431 if key.startswith("SLURM_"):
432 env['ENV'][key] = os.environ[key]
433
434 try:
435 env.PrependENVPath(LD_LIBRARY_PATH_KEY, os.environ[LD_LIBRARY_PATH_KEY])
436 except KeyError:
437 pass
438
439 if IS_OSX:
440 try:
441 env.PrependENVPath('DYLD_LIBRARY_PATH', os.environ['DYLD_LIBRARY_PATH'])
442 except KeyError:
443 pass
444
445 try:
446 env['ENV']['PYTHONPATH'] = os.environ['PYTHONPATH']
447 except KeyError:
448 pass
449
450 ######################## Add some custom builders ############################
451
452 # Takes care of prefix and suffix for Python modules:
453 def build_python_module(env, target, source):
454 return env.SharedLibrary(target, source, SHLIBPREFIX='', SHLIBSUFFIX='.so')
455 env.AddMethod(build_python_module, "PythonModule")
456
457 if env['pythoncmd']=='python':
458 py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
459 else:
460 py_builder = Builder(action = env['pythoncmd']+" scripts/py_comp.py $SOURCE $TARGET", suffix = '.pyc', src_suffix = '.py', single_source=True)
461 env.Append(BUILDERS = {'PyCompile' : py_builder});
462
463 runUnitTest_builder = Builder(action = runUnitTest, suffix = '.passed', src_suffix=env['PROGSUFFIX'], single_source=True)
464 env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
465
466 runPyUnitTest_builder = Builder(action = runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
467 env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
468
469 runPyExample_builder = Builder(action = runPyExample, suffix = '.passed', src_suffic='.py', single_source=True)
470 env.Append(BUILDERS = {'RunPyExample' : runPyExample_builder});
471
472 epstopdfbuilder = Builder(action = eps2pdf, suffix='.pdf', src_suffix='.eps', single_source=True)
473 env.Append(BUILDERS = {'EpsToPDF' : epstopdfbuilder});
474
475 ############################ Dependency checks ###############################
476
477 ######## Compiler
478 env=checkCompiler(env)
479
480 ######## Python headers & library (required)
481 env=checkPython(env)
482
483 ######## boost & boost-python (required)
484 env=checkBoost(env)
485
486 ######## numpy (required) and numpy headers (optional)
487 env=checkNumpy(env)
488
489 ######## CppUnit (required for tests)
490 env=checkCppUnit(env)
491
492 ######## NVCC version (optional)
493 if env['cuda'] and 'ripley' in env['domains']:
494 env=checkCudaVersion(env)
495 env=checkCUDA(env)
496
497 ######## optional python modules (sympy, pyproj)
498 env=checkOptionalModules(env)
499
500 ######## optional dependencies (netCDF, PAPI, MKL, UMFPACK, Lapack, Silo, ...)
501 env=checkOptionalLibraries(env)
502
503 ######## PDFLaTeX (for documentation)
504 env=checkPDFLatex(env)
505
506 # set defaults for launchers if not otherwise specified
507 if env['prelaunch'] == 'default':
508 if env['mpi'] == 'INTELMPI' and env['openmp']:
509 env['prelaunch'] = "export I_MPI_PIN_DOMAIN=omp"
510 elif env['mpi'] == 'OPENMPI':
511 # transform comma-separated list to '-x a -x b -x c ...'
512 env['prelaunch'] = "EE=$(echo -x %e|sed -e 's/,/ -x /g')"
513 elif env['mpi'] == 'MPT':
514 env['prelaunch'] = "export MPI_NUM_MEMORY_REGIONS=0"
515 elif env['mpi'] == 'MPICH2':
516 env['prelaunch'] = "mpdboot -n %n -r ssh -f %f"
517 else:
518 env['prelaunch'] = ""
519
520 if env['launcher'] == 'default':
521 if env['mpi'] == 'INTELMPI':
522 env['launcher'] = "mpirun -hostfile %f -n %N -ppn %p %b"
523 elif env['mpi'] == 'OPENMPI':
524 if env['mpi_no_host']:
525 hostoptionstr=''
526 else:
527 hostoptionstr='--host %h'
528 # default to OpenMPI version 1.10 or higher
529 env['launcher'] = "mpirun ${AGENTOVERRIDE} --gmca mpi_warn_on_fork 0 ${EE} "+hostoptionstr+" --map-by node:pe=%t -bind-to core -np %N %b"
530 if 'orte_version' in env:
531 major,minor,point = [int(i) for i in env['orte_version'].split('.')]
532 if major == 1 and minor < 10:
533 env['launcher'] = "mpirun ${AGENTOVERRIDE} --gmca mpi_warn_on_fork 0 ${EE} "+hostoptionstr+" --cpus-per-rank %t -np %N %b"
534 elif env['mpi'] == 'MPT':
535 env['launcher'] = "mpirun %h -np %p %b"
536 elif env['mpi'] == 'MPICH':
537 env['launcher'] = "mpirun -machinefile %f -np %N %b"
538 elif env['mpi'] == 'MPICH2':
539 env['launcher'] = "mpiexec -genvlist %e -np %N %b"
540 else:
541 env['launcher'] = "%b"
542
543 if env['postlaunch'] == 'default':
544 if env['mpi'] == 'MPICH2':
545 env['postlaunch'] = "mpdallexit"
546 else:
547 env['postlaunch'] = ""
548
549 # dependency sanity checks
550
551 if len(env['domains']) == 0:
552 env['warnings'].append("No domains have been built, escript will not be very useful!")
553
554 # keep some of our install paths first in the list for the unit tests
555 env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
556 env.PrependENVPath('PYTHONPATH', prefix)
557 env['ENV']['ESCRIPT_ROOT'] = prefix
558
559 if not env['verbose']:
560 env['CXXCOMSTR'] = "Compiling $TARGET"
561 env['SHCXXCOMSTR'] = "Compiling $TARGET"
562 env['ARCOMSTR'] = "Linking $TARGET"
563 env['LINKCOMSTR'] = "Linking $TARGET"
564 env['SHLINKCOMSTR'] = "Linking $TARGET"
565 env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
566 env['BIBTEXCOMSTR'] = "Generating bibliography $TARGET"
567 env['MAKEINDEXCOMSTR'] = "Generating index $TARGET"
568 env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
569 #Progress(['Checking -\r', 'Checking \\\r', 'Checking |\r', 'Checking /\r'], interval=17)
570
571 ########################### Configure the targets ############################
572
573 from grouptest import GroupTest
574 TestGroups=[]
575
576 # keep an environment without warnings-as-errors
577 dodgy_env=env.Clone()
578
579 # now add warnings-as-errors flags. This needs to be done after configuration
580 # because the scons test files have warnings in them
581 if ((fatalwarning != '') and (env['werror'])):
582 env.Append(CCFLAGS = fatalwarning)
583
584 Export(
585 ['env',
586 'dodgy_env',
587 'IS_WINDOWS',
588 'TestGroups'
589 ]
590 )
591
592 target_init = env.Command(os.path.join(env['pyinstall'],'__init__.py'), None, Touch('$TARGET'))
593 env.Alias('target_init', [target_init])
594
595 # escript can't be turned off
596 build_all_list = ['build_escript']
597 install_all_list = ['target_init', 'install_escript']
598
599 if env['usempi']:
600 build_all_list += ['build_pythonMPI', 'build_overlord']
601 install_all_list += ['install_pythonMPI', 'install_overlord']
602
603 env['buildvars']['paso'] = int(env['paso'])
604 if env['paso']:
605 env.Append(CPPDEFINES = ['ESYS_HAVE_PASO'])
606 build_all_list += ['build_paso']
607 install_all_list += ['install_paso']
608
609 env['buildvars']['trilinos'] = int(env['trilinos'])
610 if env['trilinos']:
611 build_all_list += ['build_trilinoswrap']
612 install_all_list += ['install_trilinoswrap']
613
614 env['buildvars']['domains'] = ','.join(env['domains'])
615 for domain in env['domains']:
616 env.Append(CPPDEFINES = ['ESYS_HAVE_'+domain.upper()])
617 build_all_list += ['build_%s'%domain]
618 install_all_list += ['install_%s'%domain]
619
620 env['buildvars']['weipa'] = int(env['weipa'])
621 if env['weipa']:
622 env.Append(CPPDEFINES = ['ESYS_HAVE_WEIPA'])
623 build_all_list += ['build_weipa']
624 install_all_list += ['install_weipa']
625 if 'finley' in env['domains'] or 'dudley' in env['domains']:
626 build_all_list += ['build_escriptreader']
627 install_all_list += ['install_escriptreader']
628
629 variant='$BUILD_DIR/$PLATFORM/'
630 env.SConscript('escriptcore/SConscript', variant_dir=variant+'escriptcore', duplicate=0)
631 env.SConscript('escript/py_src/SConscript', variant_dir=variant+'escript', duplicate=0)
632 env.SConscript('pythonMPI/src/SConscript', variant_dir=variant+'pythonMPI', duplicate=0)
633 env.SConscript('tools/overlord/SConscript', variant_dir=variant+'tools/overlord', duplicate=0)
634 env.SConscript('paso/SConscript', variant_dir=variant+'paso', duplicate=0)
635 env.SConscript('trilinoswrap/SConscript', variant_dir=variant+'trilinoswrap', duplicate=0)
636 env.SConscript('cusplibrary/SConscript')
637 env.SConscript('dudley/SConscript', variant_dir=variant+'dudley', duplicate=0)
638 env.SConscript('finley/SConscript', variant_dir=variant+'finley', duplicate=0)
639 env.SConscript('ripley/SConscript', variant_dir=variant+'ripley', duplicate=0)
640 env.SConscript('speckley/SConscript', variant_dir=variant+'speckley', duplicate=0)
641 env.SConscript('weipa/SConscript', variant_dir=variant+'weipa', duplicate=0)
642 env.SConscript(dirs = ['downunder/py_src'], variant_dir=variant+'downunder', duplicate=0)
643 env.SConscript(dirs = ['modellib/py_src'], variant_dir=variant+'modellib', duplicate=0)
644 env.SConscript(dirs = ['pycad/py_src'], variant_dir=variant+'pycad', duplicate=0)
645 env.SConscript('tools/escriptconvert/SConscript', variant_dir=variant+'tools/escriptconvert', duplicate=0)
646 env.SConscript('doc/SConscript', variant_dir=variant+'doc', duplicate=0)
647
648 env.Alias('build', build_all_list)
649
650 install_all_list += ['install_downunder_py']
651 install_all_list += ['install_modellib_py']
652 install_all_list += ['install_pycad_py']
653 install_all_list += [env.Install(Dir('scripts',env['build_dir']), os.path.join('scripts', 'release_sanity.py'))]
654
655 if env['osx_dependency_fix']:
656 print("Require dependency fix")
657 install_all=env.Command('install', install_all_list, 'scripts/moveall.sh')
658 else:
659 install_all=env.Alias('install', install_all_list)
660
661 sanity=env.Alias('sanity', env.Command('dummy','',os.path.join(env['prefix'], 'bin', 'run-escript')+' '+os.path.join(env['build_dir'],'scripts', 'release_sanity.py')))
662 env.Depends('dummy', install_all)
663 if env['usempi']:
664 env.Depends('dummy', ['install_pythonMPI'])
665
666 # if all domains are built:
667 if env['domains'] == all_domains and env['insane'] == False:
668 env.AlwaysBuild('sanity')
669 env.Default('sanity')
670 else:
671 env.Default('install')
672
673 ################## Targets to build and run the test suite ###################
674
675 if not env['cppunit']:
676 test_msg = env.Command('.dummy.', None, '@echo "Cannot run C++ unit tests, CppUnit not found!";exit 1')
677 env.Alias('run_tests', test_msg)
678 env.Alias('build_tests', '')
679 env.Alias('run_tests', ['install'])
680 env.Alias('all_tests', ['install', 'run_tests', 'py_tests'])
681 env.Alias('build_full',['install','build_tests','build_py_tests'])
682 Requires('py_tests', 'install')
683
684 ##################### Targets to build the documentation #####################
685
686 env.Alias('pdfdocs',['user_pdf', 'install_pdf', 'cookbook_pdf', 'inversion_pdf'])
687 env.Alias('basedocs', ['pdfdocs','examples_tarfile', 'examples_zipfile', 'api_doxygen'])
688 env.Alias('docs', ['basedocs', 'sphinxdoc'])
689 env.Alias('release_prep', ['docs', 'install'])
690 env.Alias('release_prep_old', ['basedocs', 'api_epydoc', 'install'])
691
692 # The test scripts are always generated, this target allows us to
693 # generate the testscripts without doing a full build
694 env.Alias('testscripts',[])
695
696 if not IS_WINDOWS:
697 generateTestScripts(env, TestGroups)
698
699 ######################## Populate the buildvars file #########################
700
701 write_buildvars(env)
702 # delete buildvars upon cleanup - target_init is default so use it
703 env.Clean('target_init', File('buildvars', env['libinstall']))
704
705 write_launcher(env)
706
707 # remove obsolete files
708 if not env['usempi']:
709 Execute(Delete(File(['pythonMPI','pythonMPIredirect'], env['libinstall'])))
710 Execute(Delete(File('escript-overlord', env['bininstall'])))
711
712 ######################## Summarize our environment ###########################
713 def print_summary():
714 d_list=[]
715 print("")
716 print("*** Config Summary (see config.log and <prefix>/lib/buildvars for details) ***")
717 print("Escript revision %s"%global_revision)
718 print(" Install prefix: %s"%env['prefix'])
719 print(" Python: %s (Version %s)"%(env['pythoncmd'],env['python_version']))
720 print(" boost: %s (Version %s)"%(env['boost_prefix'],env['boost_version']))
721 if env['numpy_h']:
722 print(" numpy: YES (with headers)")
723 else:
724 print(" numpy: YES (without headers)")
725 if env['usempi']:
726 if 'orte_version' in env:
727 print(" MPI: %s (Version %s)"%(env['mpi'], env['orte_version']))
728 else:
729 print(" MPI: YES (flavour: %s)"%env['mpi'])
730 else:
731 d_list.append('mpi')
732 if env['parmetis']:
733 print(" ParMETIS: %s (Version %s)"%(env['parmetis_prefix'],env['parmetis_version']))
734 else:
735 d_list.append('parmetis')
736 if env['uselapack']:
737 print(" LAPACK: YES (flavour: %s)"%env['lapack'])
738 else:
739 d_list.append('lapack')
740 if env['cuda']:
741 print(" CUDA: YES (nvcc: %s)"%env['nvcc_version'])
742 else:
743 d_list.append('cuda')
744 if env['gmshpy']:
745 gmshpy=" + python module"
746 else:
747 gmshpy=""
748 if env['gmsh']=='m':
749 print(" gmsh: YES, MPI-ENABLED"+gmshpy)
750 elif env['gmsh']=='s':
751 print(" gmsh: YES"+gmshpy)
752 else:
753 if env['gmshpy']:
754 print(" gmsh: python module only")
755 else:
756 d_list.append('gmsh')
757 if env['compressed_files']:
758 print(" gzip: YES")
759 else:
760 d_list.append('gzip')
761
762 solvers = []
763 direct = []
764 if env['paso']:
765 solvers.append('paso')
766 if env['mkl']:
767 direct.append('mkl')
768 if env['umfpack']:
769 direct.append('umfpack')
770 else:
771 d_list.append('paso')
772 if env['trilinos']:
773 solvers.append('trilinos')
774 direct.append('trilinos')
775 else:
776 d_list.append('trilinos')
777
778 print(" Solver library: %s"%(", ".join(solvers)))
779 if len(direct) > 0:
780 print(" Direct solver: YES (%s)"%(", ".join(direct)))
781 else:
782 print(" Direct solver: NONE")
783 print(" domains: %s"%(", ".join(env['domains'])))
784 if env['netcdf']==4:
785 print(" netcdf: YES (4 + 3)")
786 elif env['netcdf']==3:
787 print(" netcdf: YES (3)")
788 else:
789 print(" netcdf: NO")
790 e_list=[]
791 for i in ('weipa','debug','openmp','cppunit','gdal','mkl',
792 'papi','pyproj','scipy','silo','sympy','umfpack','visit'):
793 if env[i]: e_list.append(i)
794 else: d_list.append(i)
795
796 d_list += set(all_domains).difference(env['domains'])
797 for i in e_list:
798 print("%16s: YES"%i)
799 print("\n DISABLED features: %s"%(" ".join(sorted(d_list))))
800
801 if ((fatalwarning != '') and (env['werror'])):
802 print(" Treating warnings as errors")
803 else:
804 print(" NOT treating warnings as errors")
805 print("")
806 for w in env['warnings']:
807 print("WARNING: %s"%w)
808 if len(GetBuildFailures()):
809 print("\nERROR: build stopped due to errors\n")
810 else:
811 print("\nSUCCESS: build complete\n")
812
813 atexit.register(print_summary)
814

  ViewVC Help
Powered by ViewVC 1.1.26