[PyCUDA] single elements of gpuarray

Andreas Klöckner lists at informa.tiker.net
Wed Apr 14 08:59:40 PDT 2010


On Mittwoch 14 April 2010, gerald wrong wrote:
> I am trying to write a gpu kernel to expand an array to a much larger
>  sparse array using PyCUDA (which I will then perform some linear algebra
>  on). Currently I have a simple cpu based implementation working nicely,
>  and I was hoping that PyCUDA would have the tools to allow me to perform
>  such operation in parallel without manually going down to C kernel using
>  memoryIDs.
> 
> I need to read a row in from from A_gpu, and then make some modifications
>  to specific elements of M_gpu.  Such an uncoupled task screams for GPGPU.
> 
> I am stuck because I cannot seem to figure out how to retrieve a single
> element from a gpuarray without writing a C kernel using memory addresses.
> 
> Is there anything to do:
> 
> M_gpu[i,j]
> 
> in PyCUDA that I missed reading about in the Docs?

Nope--that would be awfully slow. (But it's not hard to code if you need
it, using a just a memcpy from the right address.) There is a somehwat
limited facility to do 1D slices, but I doubt that's what you want.
Unless you're doing the same thing to the whole array, you will likely
have to go to CUDA C.

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20100414/b19ac03b/attachment-0001.pgp>


More information about the PyCUDA mailing list