LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
cuda.py
Go to the documentation of this file.
1 """
2 cuda
3 
4 CUDA Tool for SCons
5 
6 """
7 
8 import os
9 import SCons.Tool
10 import SCons.Scanner.C
11 import SCons.Defaults
12 
13 CUDAScanner = SCons.Scanner.C.CScanner()
14 
15 # this object emitters add '.linkinfo' suffixed files as extra targets
16 # these files are generated by nvcc. The reason to do this is to remove
17 # the extra .linkinfo files when calling scons -c
18 def CUDANVCCStaticObjectEmitter(target, source, env):
19  tgt, src = SCons.Defaults.StaticObjectEmitter(target, source, env)
20  for file in src:
21  lifile = os.path.splitext(src[0].rstr())[0] + '.linkinfo'
22  #tgt.append(lifile)
23  return tgt, src
24 def CUDANVCCSharedObjectEmitter(target, source, env):
25  tgt, src = SCons.Defaults.SharedObjectEmitter(target, source, env)
26  for file in src:
27  lifile = os.path.splitext(src[0].rstr())[0] + '.linkinfo'
28  #tgt.append(lifile)
29  return tgt, src
30 
31 def generate(env):
32  staticObjBuilder, sharedObjBuilder = SCons.Tool.createObjBuilders(env);
33  staticObjBuilder.add_action('.cu', '$STATICNVCCCMD')
34  staticObjBuilder.add_emitter('.cu', CUDANVCCStaticObjectEmitter)
35  sharedObjBuilder.add_action('.cu', '$SHAREDNVCCCMD')
36  sharedObjBuilder.add_emitter('.cu', CUDANVCCSharedObjectEmitter)
37  SCons.Tool.SourceFileScanner.add_scanner('.cu', CUDAScanner)
38 
39  # default compiler
40  env['NVCC'] = 'nvcc'
41 
42  # default flags for the NVCC compiler
43  env['NVCCFLAGS'] = ''
44  env['STATICNVCCFLAGS'] = ''
45  env['SHAREDNVCCFLAGS'] = ''
46  env['ENABLESHAREDNVCCFLAG'] = '-shared'
47  env['NVCCCMDLINE'] = ''
48 
49  # default NVCC commands
50  env['STATICNVCCCMD'] = '$NVCC -o $TARGET -c $NVCCFLAGS $_CPPINCFLAGS $STATICNVCCFLAGS $NVCCCMDLINE $SOURCES'
51  env['SHAREDNVCCCMD'] = '$NVCC -o $TARGET -c $NVCCFLAGS $_CPPINCFLAGS $SHAREDNVCCFLAGS $ENABLESHAREDNVCCFLAG $NVCCCMDLINE $SOURCES'
52 
53 def exists(env):
54  return env.Detect('nvcc')
55 
def CUDANVCCSharedObjectEmitter
Definition: cuda.py:24
def CUDANVCCStaticObjectEmitter
Definition: cuda.py:18
def exists
Definition: cuda.py:53
def generate
Definition: cuda.py:31