[PyCUDA] Feature proposal: GPUArray views
Andreas Kloeckner
lists at informa.tiker.net
Fri Sep 9 00:07:49 PDT 2011
On Fri, 9 Sep 2011 13:17:36 +1000, Bogdan Opanchuk <mantihor at gmail.com> wrote:
> Hello,
>
> I recently found myself missing a certain feature in PyCuda (and, in
> fact, the same can be said about PyOpenCL). Namely, the feature is a
> view of a part of GPUArray.
> For example, if I have some large array and want to perform some
> operation on the part of it, I have to introduce additional parameters
> like 'offset' and 'length':
>
> a = GPUArray(full_size, dtype)
> func(a, offset=1024, length=2048)
>
> In my opinion, this can be too error-prone, and this would be better:
>
> a = GPUArray(full_size, dtype)
> a_view = a.get_view(offset=1024, length=2048)
> func(a_view)
>
> Now func() does not have to worry about offsets and can just work with
> a_view as if it were a common GPUArray. This especially helps if
> func() is some library function which you cannot/do not want to mess
> with. Other advantage of views would be that you can reuse some large
> temporary array by creating different views to use at different steps
> (instead of creating many temporary arrays which take more memory).
>
> So, at this point I am just interested whether I am the only one who
> will find this feature useful. Unfortunately, in the nearest future I
> will not have time to add it myself. I am not even sure whether it
> should go to PyCuda/OpenCL or straight to compyte (or is it there
> already?).
PyCUDA already supports this--just do array[start:end]. PyOpenCL not
yet, but I'm meaning to add this at some point, unless compyte gets
there first.
Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20110909/0eb2e86d/attachment.pgp>
More information about the PyCUDA
mailing list