On Fri, 22 Jul 2011 15:42:23 +1000, Daryl Bond <[email protected]> wrote:
> Hi guys,
> 
> I have looked for answers in the documentation, but no luck, so here
> goes.
> 
> I have data stored in a buffer that already exists on the device. I
> would like to do a reduction of that data, in this case, I would like to
> find the maximum value of a large 2D array (assigned as a buffer with
> C-type addressing). 
> 
> By looking in the documentation there exists a reduction feature for
> working on pyOpenCL arrays, so the question is, how do I do either of
> the following:
> 
> A) Pass the buffer instance directly to the reduce function.
> 
> or
> 
> B) Create a pyopencl.array instance and pass it to a kernel as an
> argument. I can then fill it with whatever data I please whilst
> operating on the device(I will have to do operations on the data before
> finding the max value so this is not a wasted step). I can then, on the
> host side, pass the pyopencl.array to the reduce function and get my max
> value of the array.

My suggestion would be to take your existing buffer and call the
pyopencl.array.Array constructor on it. (Pass in your buffer as the
'data' kwarg.) No copying involved, you just get an array that sits on
your existing storage. You can then feed that array to the reduction
kernel.

HTH,
Andreas

Attachment: pgpyaI11b5yGq.pgp
Description: PGP signature

_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl

Reply via email to