-
Notifications
You must be signed in to change notification settings - Fork 4
/
SConstruct
executable file
·691 lines (583 loc) · 22.6 KB
/
SConstruct
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
#! /usr/bin/python
# @file
# This file is part of SWE.
#
# @author Alexander Breuer
# (breuera AT in.tum.de,
# http://www5.in.tum.de/wiki/index.php/Dipl.-Math._Alexander_Breuer)
# @author Sebastian Rettenberger
# (rettenbs AT in.tum.de,
# http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger,_M.Sc.)
#
# @section LICENSE
#
# SWE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SWE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SWE. If not, see <http://www.gnu.org/licenses/>.
#
#
# @section DESCRIPTION
#
# Builds the SWE code with several options.
#
import os
import sys
from subprocess import check_output
# Explicitly import SCons symbols for proper linting
from SCons.Script import (Environment, Variables, PathVariable,
EnumVariable, BoolVariable, Help, Exit,
Export, Import, Builder, SConscript)
########
# INIT #
########
# Welcome message
print('****************************************')
print('** Welcome to the build script of SWE **')
print('****************************************')
print('SWE Copyright (C) 2012-2013')
print('')
print(' Technische Universitaet Muenchen')
print(' Department of Informatics')
print(' Chair of Scientific Computing')
print(' http://www5.in.tum.de/SWE')
print('')
print('SWE comes with ABSOLUTELY NO WARRANTY.')
print('SWE is free software, and you are welcome to redistribute it')
print('under certain conditions.')
print('Details can be found in the file \'gpl.txt\'.')
print('')
vars = Variables()
# read parameters from a file if given
vars.AddVariables(
PathVariable('buildVariablesFile',
('location of the python file, '
'which contains the build variables'),
None, PathVariable.PathIsFile)
)
env = Environment(variables=vars)
if 'buildVariablesFile' in env:
vars = Variables(env['buildVariablesFile'])
# Compile time options
vars.AddVariables(
# Build directory
PathVariable('buildDir',
'where to build the code',
'build',
PathVariable.PathIsDirCreate),
# Compiler
EnumVariable('compiler',
'compiler to be used',
'gnu',
allowed_values=('gnu', 'intel', 'cray')
),
# Channel
EnumVariable('compileMode',
'mode of the compilation',
'release',
allowed_values=('debug', 'release')
),
# SIMD settings
EnumVariable('simdExtensions',
('SIMD extensions used for vectorization '
'(for intrinsics code)'),
'NONE',
allowed_values=('NONE', 'SSE4', 'AVX')
),
# Parallelization
EnumVariable('parallelization',
'level of parallelization',
'none',
allowed_values=('none', 'cuda', 'mpi_with_cuda',
'mpi', 'ampi', 'charm', 'upcxx', 'hpx', 'chameleon')
),
BoolVariable('openmp',
'compile with OpenMP parallelization enabled',
False),
# Compute capability
EnumVariable('computeCapability',
('optional architecture/compute capability '
'of the CUDA card'),
'sm_20',
allowed_values=('sm_10', 'sm_11', 'sm_12', 'sm_13',
'sm_20', 'sm_21', 'sm_22', 'sm_23',
'sm_30', 'sm_35')
),
# OpenGL
BoolVariable('openGL', 'compile with OpenGL visualization', False),
BoolVariable('openGL_instr',
'add instructions to openGL version (requires SDL_ttf)',
False),
# NetCDF input/output
BoolVariable('writeNetCDF',
'write output in the netCDF-format',
False),
# ASAGI input
BoolVariable('asagi',
'use ASAGI',
False),
PathVariable('asagiInputDir',
'location of netcdf input files',
'',
PathVariable.PathAccept),
# Solver
EnumVariable('solver', 'Riemann solver', 'augrie',
allowed_values=('rusanov', 'fwave', 'augrie', 'hybrid',
'fwavevec', 'augriefun', 'augrie_simd')
),
# Vectorization
BoolVariable('vectorize',
'add pragmas to help vectorization (release only)',
False),
BoolVariable('showVectorization',
'show loop vectorization (Intel compiler only)',
False),
# Platform
EnumVariable('platform',
'compile for a specific platform (Intel compiler only)',
'default',
allowed_values=('default', 'mic')
),
# Runtime parameters
BoolVariable('xmlRuntime',
'use a xml-file for runtime parameters',
False),
BoolVariable('copyenv',
'copy the whole environment',
False),
# FLOP measuring
BoolVariable('countflops',
'enable flop counting; defines the macro COUNTFLOPS',
False),
BoolVariable('itt',
'enable itt api interface',
False)
)
# external variables
vars.AddVariables(
PathVariable('cudaToolkitDir', 'location of the CUDA toolkit', None),
PathVariable('libSDLDir', 'location of libSDL', None),
PathVariable('netCDFDir', 'location of netCDF', None),
PathVariable('asagiDir', 'location of ASAGI', None),
PathVariable('libxmlDir', 'location of libxml2', None)
)
# set environment
env = Environment(ENV={'PATH': os.environ['PATH']},
variables=vars)
# generate help text
Help(vars.GenerateHelpText(env))
# handle unknown, maybe misspelled variables
unknownVariables = vars.UnknownVariables()
# remove the buildVariablesFile from the list
# of unknown variables (used before)
if 'buildVariablesFile' in unknownVariables:
unknownVariables.pop('buildVariablesFile')
# exit in the case of unknown variables
if unknownVariables:
print(sys.stderr,
"*** The following build variables are unknown:",
unknownVariables.keys())
Exit(1)
# valid solver for CUDA?
if (env['parallelization'] in ['cuda', 'mpi_with_cuda'] and
env['solver'] not in ['rusanov', 'fwave', 'augrie']):
print(sys.stderr,
'** The "' + env['solver'] + '" solver is not supported in CUDA.')
Exit(3)
# CUDA parallelization for openGL
if env['parallelization'] != 'cuda' and env['openGL']:
print(sys.stderr,
('** The parallelization \"' + env['parallelization'] + '\" '
'does not support OpenGL visualization (CUDA only).'))
Exit(3)
# Copy whole environment?
if env['copyenv']:
env.AppendUnique(ENV=os.environ, delete_existing=1)
#######################
# UPCXX Specific Init #
#######################
if env['parallelization'] == 'upcxx':
env.Append(CCFLAGS=['-std=c++14'])
# get the upcxx folder
upcxxInstall = os.environ['UPCXX_PATH']
if upcxxInstall == '':
print(sys.stderr,
'No UPC++ installation found. Did you set $UPCXX_PATH?')
Exit(3)
else:
print("Found UPC++ install at: " + upcxxInstall)
# point to the upcxx native upcxx-meta tool
upcxxMeta =upcxxInstall + '/bin/upcxx-meta'
# let upcxx-meta tell us the necessary compiler flags
upcxxPpFlags = check_output([upcxxMeta, 'PPFLAGS']).split()
upcxxLdFlags = check_output([upcxxMeta, 'LDFLAGS']).split()
upcxxLibFlags = check_output([upcxxMeta, 'LIBFLAGS']).split()
print(upcxxLdFlags)
# SCons likes special formats!
# cut the -D/-I/-L/-l prefixes from the options
upcxxDefines = [i[2:] for i in upcxxPpFlags if i.startswith("-D")]
upcxxIncludes = [i[2:] for i in upcxxPpFlags if i.startswith("-I")]
upcxxLibPaths = [i[2:] for i in upcxxLibFlags if i.startswith("-L")]
upcxxLibs = [i[2:] for i in upcxxLibFlags if i.startswith("-l")]
#######################
# HPX Specific Init #
#######################
if env['parallelization'] == 'hpx':
env.Append(CCFLAGS=['-std=c++17'])
# get the upcxx folder
hpxInstall = os.environ['HPX_PATH']
if hpxInstall == '':
print(sys.stderr,
'No HPX installation found. Did you set $HPX_PATH?')
Exit(3)
else:
print("Found HPX install at: " + hpxInstall)
boostInstall = os.environ['BOOST_ROOT']
if boostInstall == '':
print(sys.stderr,
'No BOOST installation found. Did you set $BOOST_ROOT?')
Exit(3)
else:
print("Found BOOST install at: " + boostInstall)
hwInstall = os.environ['HWLOC_BASE']
if hwInstall == '':
print(sys.stderr,
'No HWLOC installation found. Did you set $HWLOC_ROOT?')
Exit(3)
else:
print("Found HWLOC install at: " + hwInstall)
################################
# Charm++ / AMPI specific Init #
################################
if env['parallelization'] in ['charm', 'ampi']:
# Path to the compiler#
env.Append(CCFLAGS=['-language charm++ -module CommonLBs'])
charmInstall = os.environ['CHARM_PATH']
if charmInstall == '':
print(sys.stderr,
'No Charm++ installation found. Did you set $CHARM_PATH?')
Exit(3)
else:
print("Found Charm++ install at: " + charmInstall)
# Custom builder for *.def.h and *.decl.h / Charm++ specific files
def modifyTargets(target, source, env):
target.append('${SOURCE.basename}.def.h')
return target, source
env.Append(CPPPATH='blocks')
#env.Append(CPPPATH='examples')
buildString = "cd ${SOURCE.dir};" +charmInstall + '/bin/charmc ' + '${SOURCE.file}'
charmBuilder = Builder(action=buildString,
suffix='.decl.h',
src_suffix='.ci')
env.Append(BUILDERS={'charmBuilder': charmBuilder})
env.charmBuilder(["src/blocks/SWE_DimensionalSplittingCharm.ci","src/examples/swe_charm.ci"])
################################
# Chameleon specific
################################
if env['parallelization'] in ['chameleon']:
env.Append(CCFLAGS=['-std=c++11'])
env.Append(CCFLAGS=['-lchameleon', '-lm', '-lstdc++'])
# get the chameleon folder
libfabricPath = os.environ['LIBFABRIC_PATH']
chameleonPath = os.environ['CHAM_PATH']
if chameleonPath == '':
print(sys.stderr,
'No chameleon installation found. Did you set $CHAM_PATH?')
Exit(3)
else:
print("Trying to find chameleon install at: " + chameleonPath
)
env.Append(CCFLAGS=['-I'+chameleonPath+'/include/'])
env.Append(CCFLAGS=['-L'+chameleonPath+'/lib/'])
env.Append(LINKFLAGS=['-L'+chameleonPath+'/lib/'])
env.Append(LINKFLAGS=['-L'+libfabricPath])
env.Append(LINKFLAGS=['-lchameleon'])
env.Append(LINKFLAGS=['-lfabric'])
# env.Append(LINKFLAGS=['-lifcore'])
# env.Append(LINKFLAGS=['-lirng'])
env.Append(RPATH=[chameleonPath+'/lib/'])
################################
# StarPU specific
################################
if env['parallelization'] in ['starpu']:
# get the starpu folder
starpuPath = os.environ['STARPU_PATH']
if starpuPath == '':
print(sys.stderr,
'No StarPU installation found. Did you set $STARPU_PATH?')
Exit(3)
else:
print("Trying to find StarPU install at: " + starpuPath)
env.Append(CCFLAGS=['-I'+starpuPath+'/include/'])
env.Append(CCFLAGS=['-I'+starpuPath+'/mpi/include/'])
env.Append(CCFLAGS=['-L'+starpuPath+'/lib/'])
env.Append(LINKFLAGS=['-L'+starpuPath+'/lib/'])
env.Append(LINKFLAGS=['-lfabric'])
env.Append(LINKFLAGS=['-lifcore'])
env.Append(LINKFLAGS=['-lirng'])
env.Append(LINKFLAGS=['-lstarpu-1.3'])
env.Append(LINKFLAGS=['-lstarpumpi-1.3'])
#####################################
# Precompiler/Compiler/Linker flags #
#####################################
# Select the compiler (MPI and/or Intel, GNU is default)
if env['parallelization'] in ['mpi', 'mpi_with_cuda']:
env.Append(CCFLAGS=['-std=c++11'])
if env['compiler'] == 'cray':
env['CXX'] = 'CC'
else:
env['CXX'] = env['LINKERFORPROGRAMS'] = env.Detect(['mpiCC', 'mpicxx'])
if not env['CXX']:
print(sys.stderr,
('** MPI compiler not found, '
'please update PATH environment variable'))
Exit(1)
if env['compiler'] == 'intel':
# TODO: ???
# We need to the the mpiCC wrapper which compiler it should use
# Here are several environment variables that
# do the job for different MPI libraries
envVars = ['OMPI_CXX', 'MPICH_CXX']
for var in envVars:
env['ENV'][var] = 'icpc'
elif env['parallelization'] == 'ampi':
env['CXX'] = charmInstall + '/bin/ampicc'
elif env['parallelization'] == 'charm':
env['CXX'] = charmInstall + '/bin/charmc' # ' -balancer NeighborLB'
elif env['parallelization'] == 'upcxx':
env['CXX'] = check_output([upcxxMeta, 'CXX']).replace("\n", "")
elif env['parallelization'] == 'hpx':
env['CXX'] = 'mpicxx'
elif env['parallelization'] == 'chameleon':
env['CXX'] = 'mpicxx'
#env['CXX'] = env['LINKERFORPROGRAMS'] = env.Detect(['mpiCC', 'mpicxx'])
elif env['parallelization'] == 'starpu':
env['CXX'] = 'mpiicpc'
else:
if env['compiler'] == 'intel':
env['CXX'] = 'icpc'
elif env['compiler'] == 'cray':
env['CXX'] = env['LINKERFORPROGRAMS'] = 'CC'
# eclipse specific flag
if env['compiler'] != 'cray':
env.Append(CCFLAGS=['-fmessage-length=0'])
# xml parameters for the compiler TODO
# set (pre-)compiler flags for the compile modes
if env['compileMode'] == 'debug':
env.Append(CPPDEFINES=['DEBUG'])
if env['compiler'] == 'gnu':
env.Append(CCFLAGS=['-O0', '-g3', '-Wall' ])
elif env['compiler'] == 'intel':
env.Append(CCFLAGS=['-O0', '-g'])
elif env['compiler'] == 'cray':
env.Append(CCFLAGS=['-O0'])
elif env['compileMode'] == 'release':
env.Append(CPPDEFINES=['NDEBUG'])
if env['compiler'] == 'gnu':
#env.Append(CCFLAGS=['-O3', '-mtune=native'])
env.Append(CCFLAGS=['-O2'])
elif env['compiler'] == 'intel':
env.Append(CCFLAGS=['-O2'])#, '-std=c++0x'])
# especially for env['compiler'] == 'cray'
else:
env.Append(CCFLAGS=['-O3'])
# Other compiler flags (for all compilers)
if env['compiler'] != 'cray':
env.Append(CCFLAGS=['-fstrict-aliasing', '-fargument-noalias'])
# env.Append(CCFLAGS=['-fno-strict-aliasing',
# '-fargument-noalias', '-g', '-g3', '-ggdb',
# '-Wall', '-Wextra', '-Wstrict-aliasing=2'])
# Vectorization via Intrinsics
if env['simdExtensions'] == 'SSE4':
env.Append(CCFLAGS=['-msse4'])
elif env['simdExtensions'] == 'AVX':
env.Append(CCFLAGS=['-mavx'])
if env['countflops']:
env.Append(CCFLAGS=['-DCOUNTFLOPS'])
# Vectorization?
if env['compileMode'] == 'release' and env['vectorize']:
env.Append(CPPDEFINES=['VECTORIZE'])
#if env['compiler'] == 'intel' and env['platform'] != 'mic':
# env.Append(CCFLAGS=['-xHost'])
if env['compiler'] == 'intel' and env['showVectorization']:
#env.Append(CCFLAGS=['-vec-report2', '-opt-report'])
env.Append(CCFLAGS=['-qopt-report-phase=vec', '-qopt-report=2'])
# OpenMP parallelism
# TODO Refactor: This can probably be an else if
if env['openmp']:
if env['compiler'] == 'intel':
env.Append(CCFLAGS=['-qopenmp'])
env.Append(LINKFLAGS=['-qopenmp'])
# cray: OpenMP turned on by default
if env['compiler'] == 'gnu':
env.Append(CCFLAGS=['-fopenmp'])
env.Append(LINKFLAGS=['-fopenmp'])
# Platform
if env['compiler'] == 'intel' and env['platform'] == 'mic':
env.Append(CCFLAGS=['-mmic'])
env.Append(LINKFLAGS=['-mmic'])
# Compiler
if env['compiler'] == 'intel':
# Add Intel specific libraries
env.Append(LIBS=['svml', 'imf', 'intlc'])
# Add source directory to include path (important for subdirectories)
env.Append(CPPPATH=['.'])
env.Append(CPPPATH=['include'])
# upcxx specific compiler options
if env['parallelization'] == 'upcxx':
env.Append(CPPDEFINES=['UPCXX'])
env.Append(CPPDEFINES=upcxxDefines)
env.Append(CPPPATH=upcxxIncludes)
env.Append(LIBS=upcxxLibs)
env.Append(LIBPATH=upcxxLibPaths)
if env['parallelization'] == 'hpx':
boostInstallLib = boostInstall+ '/stage/lib/'
hpxInstallLib = hpxInstall + '/lib/'
hpxInstallLib = hpxInstall + '/lib64/'
#boostInstallLib = boostInstall
hwInstallLib = hwInstall + '/lib/'
hpxIncDir=[hpxInstall+'/include',boostInstall, hwInstall+'/include']
init_lib = File(hpxInstallLib+'libhpx_init.a')
hpxLinDir=[init_lib,'libhpx.so','libhpx_iostreams.so'
,'libboost_atomic.so'
,'libboost_filesystem.so'
,'libboost_program_options.so'
#,'libboost_regex.so'
,'libboost_system.so','-lpthread'
#$(TCMALLOC_ROOT)/libtcmalloc_minimal.so
,'libhwloc.so', '-ldl' ,'-lrt']
env.Append(LIBS=hpxLinDir)
env.Append(CPPPATH=hpxIncDir)
env.Append(LIBS=[init_lib])
#env.Append(LINKFLAGS=['-Wl,-wrap=main'])
env.Append(LIBPATH=[hpxInstallLib,boostInstallLib,hwInstallLib])
env.Append(RPATH=[hpxInstallLib, boostInstallLib, hwInstallLib])
if env['parallelization'] == 'charm':
env.Append(CPPDEFINES=['CHARM'])
# set the precompiler variables for the solver
if env['solver'] == 'fwave':
env.Append(CPPDEFINES=['WAVE_PROPAGATION_SOLVER=1'])
elif env['solver'] == 'augrie' or env['solver'] == 'augriefun':
env.Append(CPPDEFINES=['WAVE_PROPAGATION_SOLVER=2'])
elif env['solver'] == 'hybrid':
env.Append(CPPDEFINES=['WAVE_PROPAGATION_SOLVER=0'])
elif env['solver'] == 'fwavevec':
env.Append(CPPDEFINES=['WAVE_PROPAGATION_SOLVER=4'])
elif env['solver'] == 'augrie_simd':
env.Append(CPPDEFINES=['WAVE_PROPAGATION_SOLVER=5'])
# set the precompiler flags for CUDA
if env['parallelization'] in ['cuda', 'mpi_with_cuda']:
env.Append(CPPDEFINES=['CUDA'])
# set the directories for the CudaTool
if 'cudaToolkitDir' in env:
env['CUDA_TOOLKIT_PATH'] = env['cudaToolkitDir']
env.Tool('CudaTool', toolpath=['.'])
# set precompiler flag for nvcc
env.Append(NVCCFLAGS=['-DCUDA'])
if env['solver'] == 'augrie':
env.Append(NVCCFLAGS=['-DCUDA_AUGRIE'])
# set the compute capability of the cuda compiler
# (needs to be set after the CudaTool
env.Append(NVCCFLAGS=['--gpu-architecture='+env['computeCapability']])
# Append the source directory to the include path
env.Append(NVCCFLAGS=['-Isrc'])
# compile explicitly with 64-bit on Mac OS X
if env['PLATFORM'] == 'darwin':
env.Append(NVCCFLAGS=' -m64')
# set the nvcc precompiler flags for MPI (CUDA)
if env['parallelization'] == 'mpi_with_cuda':
env.Append(NVCCFLAGS=['-DUSEMPI'])
# set the precompiler flags for MPI (C++)
if env['parallelization'] in ['mpi_with_cuda', 'mpi', 'ampi']:
env.Append(CPPDEFINES=['USEMPI'])
if env['openGL']:
env.Append(LIBS=['SDL', 'GL', 'GLU'])
if env['openGL_instr']:
# We assume that SDL_ttf is in the same directory as SDL
env.Append(LIBS=['SDL_ttf'])
env.Append(CPPDEFINES=['USESDLTTF'])
# set the compiler flags for libSDL
if 'libSDLDir' in env:
env.Append(CPPPATH=[env['libSDLDir']+'/include'])
env.Append(LIBPATH=[env['libSDLDir']+'/lib'])
env.Append(RPATH=[env['libSDLDir']+'/lib'])
# set the precompiler flags and includes for netCDF
if env['writeNetCDF']:
env.Append(CPPDEFINES=['WRITENETCDF'])
env.Append(LIBS=['netcdf'])
path_netcdf=os.environ['NETCDF_BASE']
# set netCDF location
env.Append(CPPPATH=[path_netcdf+'/include'])
env.Append(LIBPATH=[path_netcdf+ '/lib'])
env.Append(RPATH=[path_netcdf+ '/lib'])
# set the precompiler flags, includes and libraries for ASAGI
if env['asagi']:
env.Append(CPPDEFINES=['ASAGI'])
if (env['parallelization'] == 'none' or
env['parallelization'] not in ['mpi', 'mpi_with_cuda', 'ampi']):
env.Append(CPPDEFINES=['ASAGI_NOMPI'])
env.Append(LIBS=['asagi_nompi'])
env.Append(LIBPATH=['lib'])
else:
env.Append(LIBS=['asagi'])
if 'asagiDir' in env:
print(env['asagiDir'])
env.Append(CPPPATH=[env['asagiDir']+'/include'])
env.Append(LIBPATH=[env['asagiDir']+'/build'])
env.Append(RPATH=[os.path.join(env['asagiDir'], 'build')])
if 'netCDFDir' in env:
env.Append(LIBPATH=[env['netCDFDir']+'/lib'])
env.Append(RPATH=[os.path.join(env['netCDFDir'], 'lib')])
if 'asagiInputDir' in env:
env.Append(CPPFLAGS=['\'-DASAGI_INPUT_DIR="'
+ env['asagiInputDir'] + '"\''])
if env['itt']:
env.Append(CPPDEFINES=['ITT'])
env.Append(LIBS=['ittnotify'])
# xml runtime parameters
if env['xmlRuntime']: # TODO
print('xml runtime parameters are not implemented so far.')
Exit(1)
env.Append(CPPDEFINES=['READXML'])
# set xmllib2 location
if 'libxmlDir' in env:
env.Append(CPPPATH=[env['libxmlDir']+'/include/libxml2'])
env.Append(LIBPATH=[env['libxmlDir']+'/lib'])
#
# setup the program name and the build directory
#
program_name = 'SWE'
# compiler
if env['parallelization'] != 'ampi':
program_name += '_' + env['compiler']
else:
program_name += '_' + 'ampicc'
# compile mode
program_name += '_' + env['compileMode']
# parallelization
program_name += '_' + env['parallelization']
# using openmp?
if env['openmp']:
program_name += '_omp'
# solver
program_name += '_' + env['solver']
# vectorization
if env['vectorize']:
program_name += '_vec'
# build directory
build_dir = env['buildDir'] + '/build_' + program_name
# get the static object files
env.objects = []
Export('env')
SConscript('src/SConscript', variant_dir=build_dir, duplicate=0)
Import('env')
# build the program
env.Program('build/' + program_name, env.objects)