Hi Ahmed, That is more or less how I ended up solving the problem. This would certainly be a useful addition to pycuda as a whole or just gpuarray. Perhaps submit a patch when I get the chance
Thanks, Matthias On Sun, Jun 16, 2013 at 8:48 PM, Ahmed Fasih <[email protected]> wrote: > 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 > -- Matthias Lee IDIES/Johns Hopkins University Performance @ Rational/IBM [email protected] [email protected] (320) 496 6293 To know recursion, you must first know recursion.
_______________________________________________ PyCUDA mailing list [email protected] http://lists.tiker.net/listinfo/pycuda
