-
Notifications
You must be signed in to change notification settings - Fork 18
/
cuda.py
executable file
·50 lines (40 loc) · 1.46 KB
/
cuda.py
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
#!/usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2010
"cuda"
import os
from waflib import Task
from waflib.TaskGen import extension
from waflib.Tools import ccroot, c_preproc
from waflib.Configure import conf
class cuda(Task.Task):
run_str = '${NVCC} ${CUDAFLAGS} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}'
color = 'GREEN'
ext_in = ['.h']
vars = ['CCDEPS']
scan = c_preproc.scan
shell = False
@extension('.cu', '.cuda')
def c_hook(self, node):
return self.create_compiled_task('cuda', node)
def configure(conf):
conf.find_program('nvcc', var='NVCC')
conf.options.cuda_dir=conf.root.find_node(conf.env.NVCC).parent.parent.abspath()
conf.find_cuda_libs()
@conf
def find_cuda_libs(self):
if not self.env.NVCC:
self.fatal('check for nvcc first')
d = self.root.find_node(self.env.NVCC).parent.parent
node = d.find_node('include')
_includes = node and node.abspath() or ''
_libpath=[]
for x in ('lib64', 'lib'):
try:
_libpath.append(d.find_node(x).abspath())
except:
pass
# this should not raise any error
# self.check_cxx(header='cuda.h', lib='cuda', libpath=_libpath, includes=_includes)
self.check_cxx(header='cuda.h', lib='cudart', libpath=_libpath, includes=_includes)
self.check_cxx(header='cufft.h', lib='cufft', libpath=_libpath, includes=_includes)