Reputation: 1
I have encountered a strange syntax inside armaments list of OpenCL host-code. However, I do not have any problem with my hostcode functionality but it is strange for me what does it mean at all and why it pass the arguments in this way.
clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&c_mem_obj);
To the best of my knowledge, it is type cast. am i wrong ?
i believe it does not have any special purpose since the clSetKernelArg API already accept only pointer.
It is really helpful to have a more technical explanation.
thanks, jimbo
Upvotes: 0
Views: 197
Reputation: 6343
You are right, it is a type cast. It is taking the address of your cl_mem
object (which is type cl_mem *
) and casting it to type void *
(and since clSetKernelArg takes a const void *
it's not even the best cast).
It is not required. You could also just write clSetKernelArg(kernel, 0, sizeof(cl_mem), &c_mem_obj)
and it should compile (it does for our code, on Windows, Mac, and Linux).
Upvotes: 2