cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

sajis997
Adept I

CL_INVALID_ARG_INDEX

Hi forum,

I am allocating a memory buffer and getting error value -49 with the following command :

      errNum |= clSetKernelArg(clKernel,1, sizeof(cl_mem),trgBuffer);

While allocating the trgBuffer i am not getting any error and it means that the memory creation was successful.

Any hint to track the reason of the error?

Thanks

Sajjad

0 Likes
5 Replies
nou
Exemplar

how many kernel arguments do your kernel have? kernel arguments are indexed from 0.

0 Likes

I am sending 3 kernel arguments . The detailed version is as follows:

errNum = clSetKernelArg(clKernel,0, sizeof(cl_mem), _srcArray->map(MAP_DEVICE_ARRAY));

errNum |= clSetKernelArg(clKernel,1, sizeof(cl_mem),_trgBuffer->map(MAP_DEVICE_TARGET));

errNum |= clSetKernelArg(clKernel,2, sizeof(unsigned int),(void*)(_trgBuffer->getPitch()));

0 Likes

Hi Please check your kernel code whether its receiving the same number of arguments which you are passing from the host code, there might be some mismatch. this error is mainly due to invalid argument index passed. You can refer the opencl specification 1.2 for more information.

From the host side, the kernel argument setting and on the device side the kernel argument parameter is as follows:

//////////////////////////////// HOST //////////////////////////////////////////////////////////

errNum = clSetKernelArg(clKernel,0, sizeof(cl_mem), _srcArray->map(MAP_DEVICE_ARRAY));

errNum |= clSetKernelArg(clKernel,1, sizeof(cl_mem),_trgBuffer->map(MAP_DEVICE_TARGET));

errNum |= clSetKernelArg(clKernel,2, sizeof(unsigned int),(void*)(&_trgBuffer->getPitch()));

/////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////// KERNEL ///////////////////////////////////////////////

__kernel void swapKernel(__read_only image2d_t srcArray,

          __global float4 *trgBuffer,

          unsigned int targetPitch)

{

.......

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

Now i get rid of the error. Previously it was as follows:

///////////////////////////////////////// KERNEL ///////////////////////////////////////////////

__kernel void swapKernel(__read_only image2d_t srcArray,

          __write_only  image2d_t trgBuffer,

          unsigned int targetPitch)

{

.......

}

///////////////////////////////////////// ///////////////////////////////////////////////

I am not sure what was the mistake ?

Regards

Sajjadul

0 Likes

I think you have some problem in declaring trgBuffer. What type is this buffer. The memory object specified as argument value must be a 2D image object if the argument is declared to be of type image2d_t. Check this once You can check the openCL spec 1.2 for the same.