On 04/27/2012 08:46 PM, Andrea Borsic wrote:
For example this small test:
------------------------------------------
...
# 2D "slice" dev array 10x10x1
*dest_buff_dev = cl.Buffer(ctx, mf.READ_ONLY,
source_buff_host.shape[0]*source_buff_host.shape[1]*source_buff_host.itemsize)
*
# copy one 2D slice to the dev buffer
cl.enqueue_copy(queue, dest_buff_dev, source_buff_host[:,:,1])
------------------------------------------
Results in the following error:
File
"/Users/andrea_borsic/Dropbox/ImageAnalisisAndVisualization/mCT/VES
PyOpenCL/SliceCopyTest.py", line 15, in <module>
cl.enqueue_copy(queue, dest_buff_dev, source_buff_host[:,:,1])
File
"/Library/Python/2.7/site-packages/pyopencl-2011.2-py2.7-macosx-10.7-intel.egg/pyopencl/__init__.py",
line 755, in enqueue_copy
return _cl._enqueue_write_buffer(queue, dest, src, **kwargs)
_TypeError: expected a single-segment buffer object _
As I see, your *dest_buff_dev* buffer is one-dimmensional, and it
_complains_ about copying 2D numpy array to 1D buffer.
I guess, following should work:
dest_buff_dev = cl.Buffer(ctx, mf.READ_ONLY,
hostbuf=source_buff_host[:,:,1])
hostbuf=source_buff_host[:,:,1] -- this should make dest_buff_dev have
the same shape as source_buff_host[:,:,1]
Hope this will help!
PS sorry for my English, if anything isn't clear))
_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl