-
Notifications
You must be signed in to change notification settings - Fork 2
/
SConstruct
64 lines (58 loc) · 1.9 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
# vim: fdm=marker fdl=0
import os
from nvcc import *
# compiler options
additional_includes = [os.environ['RSFROOT'] + '/include']
additional_libpath = [os.environ['RSFROOT'] + '/lib']
additional_libs = ['rsf', 'su']
c_compiler = ['/usr/bin/gcc', '-std=c99', '-march=native']
cxx_compiler = ['/usr/bin/g++', '-fopenmp', '-march=native']
linker = ['/usr/bin/g++', '-fopenmp', '-march=native']
cur_cflags = ['-Wall', '-Wextra', '-fopenmp', '-O3', '-g', '-DNO_BLAS',]
cuda_cc = ['nvcc', '--compiler-bindir', '/usr/bin/g++', '-arch=sm_35']
cuda_flags = ['-O2']
# set the sub directories (key, value), where value is the name of directory#{{{
# please make sure the source code are in src subdirectory
dirlist = [
('lib', 'lib'),
('bin', 'bin'),
('elasgpu', 'src/elastic-3d-gpu'),
('elasgpustd', 'src/elastic-3d-gpu-std'),
('elascpu', 'src/elastic-3d-cpu'),
('acouscpu', 'src/acoustic-3d-c'),
('acousfortran', 'src/acoustic-3d-fortran'),
('acousfortran2d', 'src/acoustic-2d-fortran'),
]
dirs = dict(dirlist)
#}}}
# set includes and libs#{{{
inc_path = []
libpath = ['#lib']
libs = []
for inc in additional_includes:
inc_path += ['-isystem', inc]
for l in additional_libpath:
libpath += [l]
for lp in additional_libs:
libs += [lp]
#}}}
# setup environment#{{{
cudaenv = Environment(
CC = c_compiler,
CCFLAGS = cur_cflags + inc_path,
LIBPATH = libpath,
LIBS = libs,
LINK = [cuda_cc] + '-Xcompiler -fopenmp'.split())
cudaenv.Tool('nvcc', toolpath='./nvcc.py')
cudaenv.Replace(NVCC = cuda_cc)
cudaenv.Prepend(NVCCFLAGS = cuda_flags)
#}}}
# compile#{{{
for d in dirlist:
if not 'src' in d[1]:
continue
SConscript(d[1] + '/SConscript',
variant_dir = d[1].replace('src', 'build'),
duplicate = 0,
exports = 'cudaenv dirs')
#}}}