Antonio Beamud Montero <antonio.beamud(a)gmail.com> writes:
I was testing using a result array of booleans, the problem is accessing
by index to the correct element... What's the correct way of doing this?
For example, with this buffers declarations:
a = numpy.random.randint(-100000000, 100000000, 10).astype(numpy.int32)
r = numpy.zeros(10, numpy.bool)
a_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a)
dest_buf = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=r)
and this kernel:
__kernel void test(__global const int *a,
__global bool *c
int agid = get_global_id(0);
if (agid == 1)
c[agid] = true;
The c buffer contains the next values (initialized to false 10 elements):
[False False False False True False False False False False]
i.e. is using 1 * 4 (int size, 4 bytes) as index value...
I'm a little confused :-)
If you look at 6.1.1 in the OpenCL spec, you'll note that no size is
prescribed for the bool data type. I would therefore avoid it and use
one of the types with defined sizes for exchanging data.