Re: [PyCUDA] Question about gpuarray

2009-12-04 Thread Michael Rule
I just did this ...

my solution was to malloc a large GPUarray, then construct pointers to
within this region. GPUarrays made from these pointers pass in the master
array as the base.

I think what I was trying to do is better served by slice notation however.
Previously I was not certain what a slice of a GPUarray actually was so I
was handling things manually.

--mrule.


On Fri, Dec 4, 2009 at 2:43 PM, Andreas Klöckner li...@informa.tiker.netwrote:

 On Freitag 04 Dezember 2009, you wrote:
  Hi Andreas -
  As part of my work to get host cuda functions compilable through PyCUDA,
   I've needed to come up with a mechanism for creating GPUArrays from
 device
   pointers produced by host functions.  I've been able to do that, but
 only
   by commenting out an assertion in gpuarray.py on line 89: if gpudata is
   None:
...
  else:
self.gpudata = gpudata
assert base is not None  
 
  What is GPUArray.base for, and if we really need it, what data is
 expected
   there?  I can't find GPUArray.base being used anywhere in the PyCUDA
 code
   base.

 Same as numpy.base--its sole purpose is to establish lifetime dependencies.
 Say you create an array A that's a view of another array B (a slice, say).
 Then you'd very much like B to not be destroyed before A.

 HTH,
 Andreas

 ___
 PyCUDA mailing list
 PyCUDA@tiker.net
 http://tiker.net/mailman/listinfo/pycuda_tiker.net


___
PyCUDA mailing list
PyCUDA@tiker.net
http://tiker.net/mailman/listinfo/pycuda_tiker.net


Re: [PyCUDA] Question about gpuarray

2009-12-04 Thread Andreas Klöckner
On Freitag 04 Dezember 2009, Bryan Catanzaro wrote:
 Thanks for the explanation.  In that case, do you have objections to
  removing the assertion that if a GPUArray is created and given a
  preexisting buffer, that the new array must be a view of another array? 
  In my situation, I don't think this assertion is true:  I would like to
  transfer ownership of a gpu buffer (created outside of PyCUDA by some host
  code) to a particular GPUArray.  This means I instantiate a GPUArray with
  gpudata=the pointer created by the host code, but base should still be
  None, since this new GPUArray is not a view of any other array, and so
  this GPUArray should have sole ownership of the buffer being given at
  initialization.

If I understand you correctly, then whatever you assign to .gpudata already 
establishes the lifetime dependency, right? In that case, yes, the assert 
should go away.

Andreas

PS: Please keep the PyCUDA list cc'ed, unless there's good reason not to.


signature.asc
Description: This is a digitally signed message part.
___
PyCUDA mailing list
PyCUDA@tiker.net
http://tiker.net/mailman/listinfo/pycuda_tiker.net