5 Replies Latest reply on Sep 5, 2013 12:11 AM by himanshu.gautam

    CL_INVALID_ARG_INDEX

    sajis997

      Hi forum,

       

       

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

       

       

      [code]

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

      [/code]

       

       

      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

        • Re: CL_INVALID_ARG_INDEX
          nou

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

            • Re: CL_INVALID_ARG_INDEX
              sajis997

              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()));

                • Re: CL_INVALID_ARG_INDEX
                  himanshu.gautam

                  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.

                  1 of 1 people found this helpful
                    • Re: CL_INVALID_ARG_INDEX
                      sajis997

                      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

                        • Re: CL_INVALID_ARG_INDEX
                          himanshu.gautam

                          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.

                          1 of 1 people found this helpful