I am working on a CUDA C project, adding new functionalities step by step. Everything was going fine until I added to the code a particular kernel: the nvcc compiler now gives me 4 errors, all related to the same kernel (the new one). Here are the error-generating lines:
__global__ void update(float* original, float* new, float* current, int nhalf) { // line 104
int i = threadIdx.x + blockDim.x*blockIdx.x; // line 105
if (i < nhalf) { // line 106
current[i] /= nhalf; // line 107
new[i] = (original[i] < current[i]) ? current[i] : original[i]; // line 108
}
}
Since I write the kernel bodies before the main function, I don't use prototypes.
In the main function I launch the kernel at line 384:
update<<<p->gridSize,p->blockSize>>>(p->deviceEnv, p->deviceTrueEnv, p->deviceSmoothTrueEnv, Nhalf);
The first three arguments are pointers to float, while the fourth argument is just an integer number.
When I try compiling with nvcc I get the following errors:
project.cu(106): error: expected a ")"
project.cu(107): error: identifier "current" is undefined
project.cu(108): error: expected a type specifier
project.cu(384): error: too many arguments in function call
I use the following bash command to compile:
nvcc -O0 -shared -o libproject.so project.cu -Xcompiler "-fPIC" -I$HOME/include/csound -arch=sm_30 -I/usr/local/cuda/include -L/usr/local/cuda/lib -lcufft -g -G
I am really confused, also because in the very same project I have many other kernels which are very similar and they compile all right. I launch them without any problems in the same exact way. Can somebody please help me identifying the problem here? Many thanks in advance.
PS: I am using the cuda toolkit 7.0 on Ubuntu.