CUDA and SCons configuring

Dear all,

I’ve existing Eclipse project with already created SConstruct file. NSight is used, and I’m working on a Mac (10.8)
I need to make everything work with kernels I wrote.

What did I add in SCons file (Build call is “/usr/local/bin/scons -j4 UserCompiler=nvcc UserBuildMode=debug”):

cppFlags[“debugNVCC”] = [’–verbose’, ‘-ccbin=/opt/local/bin/g++’, ‘–compiler-options=-Wall,-g3,-O0,-Wconversion,-ansi,-Wno-long-long,-pedantic,-Werror,-std=c++0x’]

//all compiler options have to be there - requirement of the project settings
[b]
linkFlags[“debugNVCC”] = [’–compiler-bindir=/opt/local/bin/gcc’]

env = Environment()

if UserCompiler.lower() == “nvcc”:
env[‘CC’] = “/Developer/NVIDIA/CUDA-5.5/bin/nvcc”
env[‘CXX’] = “/Developer/NVIDIA/CUDA-5.5/bin/nvcc”
env[‘LINK’] = “/opt/local/bin/g++”
[/b]

But the build output shows a lot of errors of kind
error: ‘__syncthreads’ was not declared in this scope
error: ‘__ffs’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]

(at the kernel call) error: expected primary-expression before ‘<’ token
etc.

So, mvcc actually makes nothing - and gcc, of course, cannot link all these libraries and functions.
There are no errors regarding blockIdx and threadIdx, because at the kernel files I’ve included:
#include </usr/local/cuda/include/cuda_runtime.h>
#include </usr/local/cuda/include/device_launch_parameters.h>
#include </usr/local/cuda/include/device_functions.h>

I found this scone tool: http://www.scons.org/wiki/CudaTool but either I use it improperly, or it’s usage makes no effect.

Do anybody have ideas, how to set up CUDA in my SCons file properly?

Thanks in advance.

Here is build output (beginning, some not important parts omitted and marked with “…”):

scons: Reading SConscript files …
scons: done reading SConscript files.
scons: Building targets …
/Developer/NVIDIA/CUDA-5.5/bin/nvcc -o debug_nvcc_exe/main.o -c --verbose -ccbin=/opt/local/bin/g++ --compiler-options=-Wall,-g3,-O0,-Wconversion,-ansi,-Wno-long-long,-pedantic,-Werror,-std=c++0x -DMAC -Isrc …
# _SPACE_= /Developer/NVIDIA/CUDA-5.5/bin/nvcc -o debug_nvcc_exe/mysgpp/data/DataVector.o -c --verbose -ccbin=/opt/local/bin/g++ --compiler-options=-Wall,-g3,-O0,-Wconversion,-ansi,-Wno-long-long,-pedantic,-Werror,-std=c++0x -DMAC -Isrc ... # CUDART=cudart
# _HERE_=/Developer/NVIDIA/CUDA-5.5/bin /Developer/NVIDIA/CUDA-5.5/bin/nvcc -o debug_nvcc_exe/mysgpp/data/DataVectorSP.o -c --verbose -ccbin=/opt/local/bin/g++ --compiler-options=-Wall,-g3,-O0,-Wconversion,-ansi,-Wno-long-long,-pedantic,-Werror,-std=c++0x -DMAC -Isrc ... # THERE=/Developer/NVIDIA/CUDA-5.5/bin
/Developer/NVIDIA/CUDA-5.5/bin/nvcc -o debug_nvcc_exe/mysgpp/grid/Grid.o -c --verbose -ccbin=/opt/local/bin/g++ --compiler-options=-Wall,-g3,-O0,-Wconversion,-ansi,-Wno-long-long,-pedantic,-Werror,-std=c++0x -DMAC -Isrc …
# _TARGET_SIZE_= # TARGET_DIR=
# _TARGET_SIZE_=64 # TOP=/Developer/NVIDIA/CUDA-5.5/bin/…
# NVVMIR_LIBRARY_DIR=/Developer/NVIDIA/CUDA-5.5/bin/../nvvm/libdevice # PATH=/Developer/NVIDIA/CUDA-5.5/bin/…/open64/bin:/Developer/NVIDIA/CUDA-5.5/bin/…/nvvm/bin:/Developer/NVIDIA/CUDA-5.5/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
# INCLUDES="-I/Developer/NVIDIA/CUDA-5.5/bin/../include" # LIBRARIES= “-L/Developer/NVIDIA/CUDA-5.5/bin/…/lib”
# CUDAFE_FLAGS= # OPENCC_FLAGS=

And here errors starts:


# _SPACE_= # CUDART=cudart
# _HERE_=/Developer/NVIDIA/CUDA-5.5/bin # THERE=/Developer/NVIDIA/CUDA-5.5/bin
# _TARGET_SIZE_= # TARGET_DIR=
# _TARGET_SIZE_=64 # TOP=/Developer/NVIDIA/CUDA-5.5/bin/…
# NVVMIR_LIBRARY_DIR=/Developer/NVIDIA/CUDA-5.5/bin/../nvvm/libdevice # PATH=/Developer/NVIDIA/CUDA-5.5/bin/…/open64/bin:/Developer/NVIDIA/CUDA-5.5/bin/…/nvvm/bin:/Developer/NVIDIA/CUDA-5.5/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
# INCLUDES="-I/Developer/NVIDIA/CUDA-5.5/bin/../include" # LIBRARIES= “-L/Developer/NVIDIA/CUDA-5.5/bin/…/lib”
# CUDAFE_FLAGS= # OPENCC_FLAGS=
# PTXAS_FLAGS= # “/opt/local/bin”/g++ -c -x c++ -D__NVCC__ -Wall -g3 -O0 -Wconversion -ansi -Wno-long-long -pedantic -Werror -std=c++0x -I"src" …
In file included from src/main.cpp:31:
src/data/GPUKernel.cuh: In member function ‘void mysg::GPUKernel<T, C1>::hierarchizeKernel(void*, void*, void*)’:
src/data/GPUKernel.cuh:77:17: error: there are no arguments to ‘__syncthreads’ that depend on a template parameter, so a declaration of ‘__syncthreads’ must be available [-fpermissive]
src/data/GPUKernel.cuh:77:17: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
src/data/GPUKernel.cuh:80:39: error: there are no arguments to ‘__ffs’ that depend on a template parameter, so a declaration of ‘__ffs’ must be available [-fpermissive]
src/data/GPUKernel.cuh:81:43: error: there are no arguments to ‘__ffs’ that depend on a template parameter, so a declaration of ‘__ffs’ must be available [-fpermissive]
src/data/GPUKernel.cuh:109:17: error: there are no arguments to ‘__syncthreads’ that depend on a template parameter, so a declaration of ‘__syncthreads’ must be available [-fpermissive]
src/data/GPUKernel.cuh: In member function ‘void mysg::GPUKernel<T, C1>::hierarchizeIt(int&, mysg::SubspaceStackIteratorData&, C1&)’:
src/data/GPUKernel.cuh:141:22: error: expected primary-expression before ‘<’ token
src/data/GPUKernel.cuh:141:56: error: expected primary-expression before ‘>’ token

P.s. SConstuct Build Tool is included properly, and what and why is going wrong - still no ideas.

Do your source files have .cu extension? Your CUDA C source files should either have .cu extension or you need to pass -x cu to nvcc.

I am not a SCons expert,but this SConstruct works for me:

env = Environment()
env.Replace(CC='/usr/local/cuda/bin/nvcc -ccbin=/usr/bin/clang -arch sm_30')
env.Append(LIBS=['curand'])

env.Program(target='american',source=['polyX.cu'])