I’m just trying to manipulate the RGB values of each pixel in a photo. But when I try to launch a kernel I’m getting a “invalid argument” error.
this my kernel code:
__global__ void addKernel(uchar* ptr_BGR, uchar* ptr_GREY, int num_rows, int num_cols)
{
int x = threadIdx.x;
int y = blockIdx.y;
int absolute_pos = num_cols*y*3 + x;
uchar b = ptr_BGR[absolute_pos];
uchar g = ptr_BGR[absolute_pos+1];
uchar r = ptr_BGR[absolute_pos+2];
ptr_GREY[absolute_pos] = 255-b;
ptr_GREY[absolute_pos+1] = 255-g;
ptr_GREY[absolute_pos+2] = 255-r;
}
and this is where I launch the kernel.
const dim3 blockSize(1, num_rows, 1);
const dim3 threadsPerBlock(num_cols, 1,1);
addKernel<<<blockSize, threadsPerBlock>>>(d_pt_BGR, d_pt_GREY, num_rows, num_cols);
// Check for any errors launching the kernel
cudaStatus = cudaGetLastError();
if (cudaStatus != cudaSuccess) {
fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus));
//goto Error;
}
the values of the num_rows and num_cols are both 900 for the images I use. Thanks in advance.