On Wed, 30 Nov 2011 12:04:59 +0200, Apostolis Glenis <apostgle...@gmail.com> 
wrote:
> Hello all,
> I am implementing an iterative algorithm in pyCUDA.
> Inside the while loop I need to do a reduction,I have implemented it with a
> gpuarray and it works nicely but i think that using a gpuarray inside a
> loop is a bad idea because of the allocation and deallocation overhead.
> So I was thinking that I could use the reduction example from the SDK.
> The problem is that i need only the first value of the reduced array
> returned to the host.
> I couldn't find anywhere in the documentation how to do that.

Regarding allocation and deallocation overhead: That can be eliminated
by using memory pools. See the PyCUDA docs on how to use them.

Next, not sure why you want to use the SDK sample for reduction when
PyCUDA comes with reduction built in--once again, see the docs. :)

Reductions return so-called array scalars, i.e. arrays that satisfy
a.shape == (1,) or a.shape == () (the two are mostly equivalent). (These
exist in both numpy and PyCUDA's GPUArrays, and they can be transferred
like any other array.)

HTH,
Andreas

Attachment: pgpcuLMf3hFhU.pgp
Description: PGP signature

_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
http://lists.tiker.net/listinfo/pycuda

Reply via email to