OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1719 Discussions

clSetKernelArg bug for <type>3 arguments

Bruce_M_
Beginner
649 Views

I've found a bug in the 2013 beta Linux build: when using clSetKernelArg to set an int3 argument, it fails if sizeof(cl_int3) is used as the size. It accepts 3 * sizeof(cl_int), but the CL spec is pretty clear that the API type corresponding to int3 is cl_int3, not cl_int[3] (there's a table at the start of section 6.1.2 in the CL 1.1 spec). The sizes are different because cl_int3 is padded to 4*sizeof(cl_int).

Both the NVIDIA and AMD OpenCL implementations expect the size to be sizeof(cl_int3).

0 Kudos
4 Replies
Raghupathi_M_Intel
649 Views
Bruce, I don't think that's a bug. The spec clearly says this about sizeof - "When applied to an operand that is a vector type, the result is number of components * size of each scalar component (Except for 3-component vectors whose size is defined as 4 * size of each scalar component.)". So it appears that Intel's behavior is correct. Thanks, Raghu
0 Kudos
Bruce_M_
Beginner
649 Views
Raghupathi Muthyalampalli (Intel) wrote:

Bruce,

"When applied to an operand that is a vector type, the result is number of components * size of each scalar component (Except for 3-component vectors whose size is defined as 4 * size of each scalar component.)"

Actually I think the part in parentheses supports my point: the size of an int3 is 16, not 12, yet clSetKernelArg only works when I pass a size of 12.
0 Kudos
Raghupathi_M_Intel
649 Views
Ah sorry. I thought your original post said the opposite. Can you attach a small test case? Thanks, Raghu
0 Kudos
Bruce_M_
Beginner
649 Views
I've written and attached a testcase that uses CLU. I included the CLU runtime in the zipfile, which I had to edit slightly to get it to compile with GCC. When I run it, it outputs intel_sizeof.c:50: clSetKernelArg(kernel, 0, sizeof(arg), &arg) failed: -51 and -51 is CL_INVALID_ARG_SIZE.
0 Kudos
Reply