On Sun, Mar 1, 2009 at 10:06, Andreas Klöckner <[email protected]>wrote:

> Hi Nicholas,
>
> On Samstag 28 Februar 2009, Nicholas Tung wrote:
> >     In much of the tutorial, numpy arrays are treated as buffer objects.
>
> In the implementation, too. In particular, memcpy_htod doesn't really care
> what it's given, as long as that something adheres to the Python buffer
> interface. Numpy arrays do so most of the time.
>
> > This doesn't always work, and should be pointed out somewhere...
>
> What's the failure? If it's something non-intuitive, we should catch it in
> PyCuda and give a nicer warning.


The failure is the wrong data is transferred to the kernel; it appeared to
be something like the array transposed (which, needless to say, can be very
bad, particularly if loop bounds are taken from corrupted memory).


>
>
> > I found
> > out the hard way. I don't know if compressed matrices have the similar
> > effects, but this code seems to fail for me.
> >
> > new = numpy.concatenate([original, numpy.zeros((original.shape[0], 0),
> > uint32)], axis=1)
> > gpu = drv.to_device(new.astype(uint32))
> >
> >     The ndarray.copy function seems to resolve the problem. Sorry I'm not
> > familiar with numpy internals.
>
> Please post the output of
>
> print original.shape
> print original.strides
> print original.flags


original array
(3, 32777) (4, 12)
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

copied array
(3, 32777) (131108, 4)
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

Looks like C_CONTIGUOUS is what we're looking for. The numpy documentation
mentions this and a possibly applicable function call:
http://numpy.scipy.org/numpydoc/numpy-13.html#marker-59740


> Andreas
>
> PS: Please use the mailing list for all questions, for archival mainly.


I forgot, sorry. Thanks for your help :)

regards,
Nicholas
_______________________________________________
PyCuda mailing list
[email protected]
http://tiker.net/mailman/listinfo/pycuda_tiker.net

Reply via email to