I m new with cuda. I m writing code for image processing in cuda.
My c and cuda code is below and i tried to convert into cuda, but it not works well.
My C code :
int main(int argc, char **argv)
{
/* here i define and initialize some variable */
int point=0;
for(int i=0;i<1050;i++,point+=1580)
{
/* doing some image process using that point value on 16 bit grayscale image.*/
}
return 0;
}
i tried to convert my c code into cuda, but its wrong.
So, my cuda code that what ever i tried is below.
__global__ void processOnImage(int pointInc)
{
int line = blockIdx.x * blockDim.x + threadIdx.x;
int point=((line)*pointInc));
/* here i m not getting exact vaue of point variable as same like in c code */
/* doing image processing here using point value */
}
int main(int argc, char **argv)
{
/* here i define and initialize some variable */
int pointInc=1580;
static const int BLOCK_WIDTH = 25;
int x = static_cast<int>(ceilf(static_cast<float>(1050) / BLOCK_WIDTH));
const dim3 grid (x,1);
const dim3 block(BLOCK_WIDTH,1);
processOnImage<<<grid,block>>>(pointInc);
return 0;
}
In processOnImage function of cuda code i m not getting exact value of point(int point) variable as in above c code. so what i m doing wrong in cuda code. Or how to use that block and thread for my code in c.