mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 01:46:15 +01:00
Improve the cuda example #2212
This commit is contained in:
parent
1c7be35dc0
commit
ee719f1912
@ -4,7 +4,6 @@
|
||||
|
||||
"cuda"
|
||||
|
||||
import os
|
||||
from waflib import Task
|
||||
from waflib.TaskGen import extension
|
||||
from waflib.Tools import ccroot, c_preproc
|
||||
@ -22,6 +21,14 @@ class cuda(Task.Task):
|
||||
def c_hook(self, node):
|
||||
return self.create_compiled_task('cuda', node)
|
||||
|
||||
@extension('.cpp')
|
||||
def cxx_hook(self, node):
|
||||
# override processing for one particular type of file
|
||||
if getattr(self, 'cuda', False):
|
||||
return self.create_compiled_task('cuda', node)
|
||||
else:
|
||||
return self.create_compiled_task('cxx', node)
|
||||
|
||||
def configure(conf):
|
||||
conf.find_program('nvcc', var='NVCC')
|
||||
conf.find_cuda_libs()
|
||||
|
@ -16,25 +16,32 @@ def configure(conf):
|
||||
# conf.env.LIBPATH_CUDA = ['c:\\foo\\bar\\lib']
|
||||
# conf.env.INCLUDES_CUDA = ['c:\\foo\\bar\\includes']
|
||||
|
||||
conf.env = conf.all_envs['cuda'] = conf.env.derive()
|
||||
conf.load('cuda', tooldir='.')
|
||||
|
||||
def build(bld):
|
||||
|
||||
# native application
|
||||
bld.program(
|
||||
source = 'test.cpp',
|
||||
target = 'testapp',
|
||||
)
|
||||
|
||||
# cuda application
|
||||
t = bld.program(
|
||||
source = 'test.cu main.cpp',
|
||||
target = 'app',
|
||||
use = 'CUDA CUDART',
|
||||
env = bld.all_envs['cuda'])
|
||||
use = 'CUDA CUDART')
|
||||
|
||||
#t.env.CUDAFLAGS = ['-deviceemu']
|
||||
# --ptxas-options="-v"
|
||||
# --ptxas-options="-v -maxrregcount=10"
|
||||
|
||||
# -----------------------
|
||||
|
||||
# native application
|
||||
bld.program(
|
||||
source = 'test.cpp',
|
||||
target = 'testapp')
|
||||
|
||||
# cuda application
|
||||
bld.program(
|
||||
source = 'test.cpp',
|
||||
target = 'testapp',
|
||||
cuda = True,
|
||||
use = 'CUDA CUDART')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user