cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

cgorac
Journeyman III

passing cl_bool as kernel argument

I have bool variable declared in my host code:

bool foo;

I try then to pass it as an argument to my kernel:

error = clSetKernelArg(kernel, 0, sizeof(cl_bool), &foo);
assert(error == CL_SUCCESS);

And I have my kernel signature as follows:

__kernel void myKernel(const bool foo, ...)

However, it seems that a bit other than the least-significant bit get set in this bool variable when passed down to the kernel, so I get either 0x800000 or 0x800001 as the contents of this variable in my kernel, thus it's always true.  So - is this bug, or some kind of error of mine in passing this argument?

Thanks.

0 Likes
3 Replies
cgorac
Journeyman III

Hmm, tried with NVIDIA SDK, and it refused to compile the code above.  So I gues passing cl_bool is not allowed after all, still I can't find corresponding notice in the specification...

0 Likes

As per OpenCL specification, you cannot pass bool to the kernel.

 

0 Likes

Originally posted by: omkaranathan As per OpenCL specification, you cannot pass bool to the kernel.

Thanks, indeed I found it in the specification: section 6.8, under (k), on page 156.  I guess it is then bug of AMD SDK compiler to accept the kernel definition as above.

0 Likes