[PyCuda] pycuda memcpy_htod
Andreas Klöckner
lists at informa.tiker.net
Sun Mar 1 10:06:22 PST 2009
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.
> 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
Andreas
PS: Please use the mailing list for all questions, for archival mainly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20090301/c30fb7d9/attachment-0001.pgp>
More information about the PyCUDA
mailing list