Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
8 years ago

Obtaining CL_INVALID_KERNEL error when setting cl_float4 as a kernel argument

Hello,

I have got a question about the function 'clSetKernelArg()' and the error code 'CL_INVALID_KERNEL'.

My problem:

My kernel function takes nine parameters.

When I try to set the kernel arguments via the function 'clSetKernelArg()' everything works fine until I want to set a cl_float4. I then get a 'CL_INVALID_KERNEL' error.

Is cl_float4 not supported by FPGA?

When I run the same code on CPU or GPU everything works fine.

Any hints will be apprecciated.

Tobias

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Is the "CL_INVALID_KERNEL" error generated by clSetKernelArg() or clEnqueueNDRangeKernel()? CL_INVALID_KERNEL points to an invalid kernel object, I highly doubt your problem has anything to do with using cl_float4. Are you correctly creating your program from a pre-compiled binary using clCreateProgramWithBinary (instead of clCreateProgramWithSource), and then creating your kernel from that program using clCreateKernel()?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi HRZ,

    thank you for your answer.

    The 'CL_INVALID_KERNEL' error is generated by clSetKernelArg(). After each call of this function the returned cl_int value is checked for errors. There is none for the first eight parameters, but for the ninth (cl_float4).

    If the order of setting kernel arguments is changed, it is again successful until the cl_float4 argument.

    The program is obtained from a pre-compiled binary by using clCreateProgramWithBinary() in combination with clBuildProgram(). Afterwards the kernel is created with clCreateKernel().
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It's a small thing, but check the index value you set in each call of clSetKernelArg. If you accidentally use the same index (from a copy/paste), you will have an issue. cl_float4 should work fine.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Can you post the host code starting from clCreateProgramWithBinary() until clEnqueueNDRangeKernel()? Please either attach the file to your post, or copy paste it between the "code" tag so that indentation is preserved.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Actually, it was not the cl_float4 value. After I reduced the number of arguments to 8 it worked out.