Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F84847547
detect.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Sep 25, 05:30
Size
5 KB
Mime Type
text/x-python
Expires
Fri, Sep 27, 05:30 (2 d)
Engine
blob
Format
Raw Data
Handle
21095389
Attached To
rTAMAAS tamaas
detect.py
View Options
import
SCons
from
os.path
import
join
,
abspath
,
exists
,
isdir
,
basename
from
SCons.Script
import
Configure
# ------------------------------------------------------------------------------
def
_get_path
(
env
,
ext
,
module_var
):
path
=
""
if
module_var
in
env
[
'ENV'
]:
root
=
abspath
(
env
[
'ENV'
][
module_var
])
if
not
exists
(
root
)
or
not
isdir
(
root
):
raise
RuntimeError
(
"{} is set to a non-existing path '{}'"
.
format
(
module_var
,
root
))
path
=
join
(
root
,
ext
)
if
not
exists
(
path
)
or
not
isdir
(
path
):
raise
RuntimeError
(
"{} does not contain '{}' directory"
.
format
(
module_var
,
ext
))
return
[
path
]
# ------------------------------------------------------------------------------
def
FindFFTW
(
env
,
components
=
[],
module_var
=
'FFTW_ROOT'
):
"""Find FFTW3 and set relevant environment variables"""
if
not
env
.
get
(
'should_configure'
,
True
):
return
fftw_vars
=
{}
fftw_vars
[
'CPPPATH'
]
=
_get_path
(
env
,
'include'
,
module_var
)
fftw_vars
[
'LIBPATH'
]
=
_get_path
(
env
,
'lib'
,
module_var
)
# Setting up FFTW
wishes
=
[
'main'
]
+
components
# Components
lib_names
=
{
'main'
:
'fftw3'
,
'thread'
:
'fftw3_threads'
,
'omp'
:
'fftw3_omp'
}
inc_names
=
[
'fftw3.h'
]
# Checking list of wishes
try
:
libs
=
[
lib_names
[
i
]
for
i
in
wishes
]
except
KeyError
:
raise
SCons
.
Errors
.
StopError
(
'Incompatible FFTW wishlist {0}'
.
format
(
wishes
))
fftw_vars
[
'LIBS'
]
=
libs
conf_env
=
env
.
Clone
(
**
fftw_vars
)
conf
=
Configure
(
conf_env
)
if
not
conf
.
CheckLibWithHeader
(
libs
,
inc_names
,
'c++'
):
raise
SCons
.
Errors
.
StopError
(
'Failed to find libraries {0} or '
'headers {1}.'
.
format
(
str
(
lib_names
),
str
(
inc_names
)))
conf_env
=
conf
.
Finish
()
# Update modified variables
env
.
AppendUnique
(
**
fftw_vars
)
# ------------------------------------------------------------------------------
def
FindBoost
(
env
,
headers
=
[
'boost/version.hpp'
],
module_var
=
'BOOST_ROOT'
):
"""Find Boost and set relevant environment variables"""
if
not
env
.
get
(
'should_configure'
,
True
):
return
boost_vars
=
{}
boost_vars
[
'CPPPATH'
]
=
_get_path
(
env
,
'include'
,
module_var
)
conf_env
=
env
.
Clone
(
**
boost_vars
)
conf
=
Configure
(
conf_env
)
if
not
conf
.
CheckCXXHeader
(
headers
):
raise
SCons
.
Errors
.
StopError
(
'Failed to find Boost headers {}'
.
format
(
headers
))
conf_env
=
conf
.
Finish
()
# Update modified variables
env
.
AppendUnique
(
**
boost_vars
)
# ------------------------------------------------------------------------------
def
FindThrust
(
env
,
backend
=
'omp'
,
module_var
=
'THRUST_ROOT'
):
"""Find Thrust and set relevant environment variables"""
if
not
env
.
get
(
'should_configure'
,
True
):
return
thrust_vars
=
{}
thrust_vars
[
'CPPPATH'
]
=
_get_path
(
env
,
'include'
,
module_var
)
if
basename
(
env
[
'CXX'
])
==
"clang++"
:
thrust_vars
[
'CXXFLAGS'
]
=
[
"-Wno-unused-local-typedef"
]
if
backend
==
'omp'
:
thrust_vars
[
'CPPDEFINES'
]
=
[
"THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP"
]
elif
backend
==
'cuda'
:
thrust_vars
[
'CPPDEFINES'
]
=
[
"THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA"
,
"USE_CUDA"
]
else
:
raise
SCons
.
Errors
.
StopError
(
'Unknown thrust backend "{}"'
.
format
(
backend
))
conf_env
=
env
.
Clone
(
**
thrust_vars
)
conf
=
Configure
(
conf_env
)
if
not
conf
.
CheckCXXHeader
(
'thrust/version.h'
):
raise
SCons
.
Errors
.
StopError
(
'Failed to find Thrust'
)
conf_env
=
conf
.
Finish
()
# Update modified variables
env
.
AppendUnique
(
**
thrust_vars
)
# ------------------------------------------------------------------------------
def
FindCuda
(
env
):
"""Detect cuda on clusters"""
if
not
env
.
get
(
'should_configure'
,
True
):
return
if
'CUDA_ROOT'
in
env
[
'ENV'
]:
env
[
'CUDA_TOOLKIT_PATH'
]
=
env
[
'ENV'
][
'CUDA_ROOT'
]
else
:
env
[
'CUDA_TOOLKIT_PATH'
]
=
'/opt/cuda'
env
[
'CUDA_COMPONENTS'
]
=
[
'cufft'
]
env
[
'CUDA_ARCH_FLAG'
]
=
'-arch=sm_60'
colors
=
env
[
'COLOR_DICT'
]
if
not
env
[
'verbose'
]:
env
[
'NVCCCOMSTR'
]
=
env
[
'SHCXXCOMSTR'
]
env
[
'SHLINKCOMSTR'
]
=
\
u'{0}[Linking (cuda)] {1}$TARGET{2}'
.
format
(
colors
[
'purple'
],
colors
[
'blue'
],
colors
[
'end'
])
env
.
AppendUnique
(
CXXFLAGS
=
[
"-expt-extended-lambda"
,
# experimental lambda support
"-expt-relaxed-constexpr"
,
# experimental constexpr
])
if
env
[
'build_type'
]
==
'debug'
:
env
.
AppendUnique
(
CXXFLAGS
=
"-G"
)
env
.
Tool
(
'nvcc'
)
# ------------------------------------------------------------------------------
def
FindGTest
(
env
):
"""A tool to configure GoogleTest"""
if
not
env
.
get
(
'should_configure'
,
True
):
return
conf
=
Configure
(
env
)
if
not
conf
.
CheckCXXHeader
(
'gtest/gtest.h'
):
raise
SCons
.
Errors
.
StopError
(
'Failed to find GoogleTest header
\n
'
+
"Run 'git submodule update --init --recursive "
+
"third-party/googletest'"
)
env
=
conf
.
Finish
()
Event Timeline
Log In to Comment