On Fri, Jun 14, 2013 at 2:01 PM, Matthias Lee <[email protected]> wrote: > Hi, > I need to add some zero padding around a 2D gpuarray. In numpy I have > usually accomplished this by slicing: > x = np.zeros((20, 20)) > y = np.ones((10, 10)) > x[0:10,0:10]=y > > I had hoped this would work similarly in pycuda with gpuarrays, but it seems > it's not implemented yet. > Is there a preferred method of doing this?
Matthias, I don't have an easy or exact answer, but I hope the following helps. In the past when I have had to do this (to do 2D zero-padding before 2D FFT), I recall doing the following: - `mem_alloc` to allocate new memory to store all of `x`, - `memset_d32` to fill it with zeros, - `Memcpy2D` by giving its `set_src_device` method `y`'s pointer, viz., `y.gpudata` and a few other things it needs. This is probably an answer that you were fearing, but I thought it might help if you knew that others had successfully done this through this long-winded method. Once you figure out the details, it's easily put into a reusable and testable function... which might be a valuable addition to PyCUDA? (I can't share code due to proprietary software requirements :-/.) Best, Ahmed _______________________________________________ PyCUDA mailing list [email protected] http://lists.tiker.net/listinfo/pycuda
