bool array in opencl?

Hi All,

I’m completely new to openCL and I’m trying to see if I can use it for a project. I don’t really need a GPU to solve it, but I’ve been wanting to learn.

I’m trying to implement a bitmap and I’m wondering if I create an array of say 1024 bool values if it will create a 1024 byte array or if it will somehow use only 1024 bits. I’m pretty sure it will be the former, but it would be pretty convenient if it did all the bitmasking and whatnot out of the box :slight_smile:

Thanks!

From the spec, 6.8 section k, you cannot use bool types to kernel arguments, so it pretty much kills that idea. The reason it gives is pretty much the same one: who knows what the format a boolean array would be in.

You probably don’t want to do this bit packing anyway (if you need to write to it): there’s no (efficient) way to atomically update bits. Using 32-bit ints will probably be the best if you can afford the space.

If you really need it for the compression it provides, just use a uint (32 bit) and ensure only full 32-bits are written at any time. e.g. using local workgroups or whatever else.

Obviously this depends on what you’re trying to do …