-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConscript
More file actions
111 lines (85 loc) · 3.78 KB
/
SConscript
File metadata and controls
111 lines (85 loc) · 3.78 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
# Authors: Mike Wall & Nick Sauter
# Date: 6/15/2017
# Lattice methods wrapped by Alex Wolff (9/22/2017).
import libtbx.load_env
import os, sys
from libtbx.env_config import get_boost_library_with_python_version
op = os.path
Import("env_base", "env_etc")
env_etc.lunus_dist = libtbx.env.dist_path("lunus")
env_etc.lunus_include = env_etc.lunus_dist
env_etc.lunus_common_includes = [
env_etc.libtbx_include,
env_etc.scitbx_include,
env_etc.lunus_include,
env_etc.boost_adaptbx_include,
env_etc.boost_include,
op.dirname(libtbx.env.find_in_repositories(
relative_path="tbxx", optional=False))
]
CPPP = os.path.join(env_etc.lunus_include,"c","include")
env_lunus = env_base.Clone(SHLINKFLAGS=env_etc.shlinkflags)
if "-ffast-math" in env_lunus["CCFLAGS"]:
replacement_ccflags = []
for f in env_lunus["CCFLAGS"]:
if (f not in ["-ffast-math"]):
replacement_ccflags.append(f)
env_lunus.Replace(CCFLAGS = replacement_ccflags)
if "-ffast-math" in env_lunus["CCFLAGS"]:
replacement_shcxxflags = []
for f in env_lunus["SHCXXFLAGS"]:
if (f not in ["-ffast-math"]):
replacement_shcxxflags.append(f)
env_lunus.Replace(SHCXXFLAGS = replacement_shcxxflags)
if (env_etc.have_openmp):
env_lunus.Prepend(CCFLAGS=["-DUSE_OPENMP"])
env_lunus.Prepend(SHCXXFLAGS=["-DUSE_OPENMP"])
if sys.platform.startswith('linux') and env_etc.enable_kokkos:
kokkos_flags = ["-DUSE_KOKKOS","-DLUNUS_NUM_JBLOCKS=16","-DLUNUS_NUM_IBLOCKS=8"]
env_lunus.Prepend(CCFLAGS=kokkos_flags)
env_lunus.Prepend(SHCXXFLAGS=kokkos_flags)
else:
if (env_etc.enable_cuda):
env_lunus.Prepend(CCFLAGS=["-DUSE_CUDA","-DLUNUS_NUM_JBLOCKS=16","-DLUNUS_NUM_IBLOCKS=8"])
correct_prefix = "#"+os.path.basename(env_etc.lunus_dist)
import glob
glob_str = os.path.join(env_etc.lunus_dist,"c","lib","*.c")
srcfile_list = glob.glob(glob_str)
env_lunus.StaticLibrary(target='#lib/lunus',
source = [os.path.join(correct_prefix,"c","lib",os.path.basename(srcfile)) for srcfile in srcfile_list],CPPPATH=[CPPP] )
if sys.platform.startswith('linux') and env_etc.enable_kokkos:
env_lunus.SConscript("lunus/kokkos/SConscript",exports={ 'env' : env_lunus })
lunus_program_libs = ['lunus_kokkos','lunus','m',"kokkoskernels",
"kokkoscontainers",
"kokkoscore"]
else:
if sys.platform.startswith('linux') and env_etc.enable_cuda:
env_lunus.SConscript("lunus/cuda/SConscript",exports={ 'env' : env_lunus })
lunus_program_libs = ['lunus_cuda','lunus','m']
else:
lunus_program_libs = ['lunus','m']
if 'Cuda' in os.getenv('LUNUS_KOKKOS_DEVICES'):
lunus_program_libs.extend(["dl","cudart"])
env_lunus.Append(LIBPATH=[os.path.join(os.environ['CUDA_HOME'], 'lib64')])
env_lunus.Append(LIBPATH=[os.path.join(os.environ['CUDA_HOME'], 'compat')])
if (not env_etc.no_boost_python):
Import("env_no_includes_boost_python_ext")
env_lunus = env_no_includes_boost_python_ext.Clone()
env_etc.include_registry.append(
env=env_lunus,
paths=env_etc.lunus_common_includes + [env_etc.python_include])
if libtbx.env.build_options.use_conda:
boost_python = get_boost_library_with_python_version(
"boost_python", env_etc.conda_libpath
)
else:
boost_python = "boost_python"
env_lunus.Append(LIBS=env_etc.libm+["scitbx_boost_python",boost_python,"cctbx"])
env_etc.enable_more_warnings(env=env_lunus)
env_lunus.SConscript("lunus/SConscript",exports={ 'env' : env_lunus })
# lunus_program_libs += env_lunus['LIBS']
glob_str = os.path.join(env_etc.lunus_dist,"c","src","*.c")
srcfile_list = glob.glob(glob_str)
env_lunus.Append(CFLAGS=["-std=c99"])
for f in [os.path.join(correct_prefix,"c","src",os.path.basename(srcfile)) for srcfile in srcfile_list]:
env_lunus.Program('#bin/{}'.format("lunus."+os.path.basename(f).split('.')[0]),f,LIBS=lunus_program_libs,RPATH=env_lunus['LIBPATH'],CPPPATH=[CPPP])