Hi, I’ve just started using CUDA and have come across a problem that’s got me stuck. Hopefully someone here can help out!
I have a host function that sets up three arrays (d_A, d_B and d_C) on the device, then loads data from the host (h_A) into one of these arrays (d_A). I then call a kernel function to try to calculate a rolling mean. d_A is unmodified, d_B is set equal to the sum of the 9 relevant elements of d_A and d_C is d_B/9.
Here’s the kernel code:
__global__ void test_func(float* data,float* otherdata,float* outdata)
{
int i=blockDim.x * blockIdx.x + threadIdx.x;
otherdata[i]=0;
outdata[i]=data[i];
if (i>=4)
{
int j=0;
for (j=-4;j<=4;j++)otherdata[i]=otherdata[i]+data[i+j];
outdata[i]=otherdata[i]/9.0;
}
}
I call it with this:
test_func<<<blocksPerGrid, threadsPerBlock>>>(d_A, d_B, d_C);
Afterwards I use CUDA_CHECK_RETURN (from the nsight default code) on a cudaThreadSynchronize and a cudaGetLastError. My problem is that the division ( outdata[i]=otherdata[i]/9.0 ) does not work and gives me this error:
Error too many resources requested for launch at line 80 in file ../src/MAIN_FUNCS.cu
Line 80 is cudaGetLastError. If I switch the /9.0 to *9.0 then the code works fine. It also works fine if I change the line to read: outdata[i]=1.0/9.0
I’m running on Ubuntu 12.04 with Intel i7 processor, 24GiB RAM, a Tesla C2070 and the Cuda developers kit v5.5. I wrote/compiled my code in the nsight GUI.
Any ideas what I’m doing wrong? I assume I’m making a newbie mistake somewhere.
Thanks!