On Donnerstag 29 April 2010, Amir wrote:
I would like to create different views of a GPUArray. I have no idea
1D slicing logic already exists. See GPUArray.__getitem__ on how it's
Let A be a 2D float32 c-continuous array. How do I create a 1D view
of its rows? I am not sure how to set gpudata in the view. An example would
be great. Is there a pointer arithmetic trick?
This would have to happen along the lines of how the view is built
above, but is hampered by the fact that our kernels don't yet have the
necessary stride support. (I.e. you could already implement contiguous
slices without touching the kernels, but non-contiguous ones need more
Is it possible to create a float32 view of a complex64 array?
Yup, that should be easy. Just follow GPUArray.__getitem__. Is there a
conventional numpy spelling for this?
I am trying to use gpuarray.multi_take_put to copy slices between
float and complex arrays but it requires dtypes to match.
multi_take_put, in addition to being an undocumented feature, needs
index arrays and is therefore likely overkill for what you want.
Is using gpuarray.multi_take_put the best way to copy a slice of an
No--'array[5:17].copy()' should be way faster, if you need a copy at