Look at this example: #test_map.py import pyopencl as cl import numpy as np import numpy.linalg as la ctx = cl.create_some_context() queue = cl.CommandQueue(ctx) ary = np.arange(3*4*5).reshape(3,4,5, order="C").astype(np.float32) mf = cl.mem_flags flags = mf.READ_WRITE | mf.COPY_HOST_PTR | mf.ALLOC_HOST_PTR buf = cl.Buffer(ctx, flags, hostbuf = ary) queue.finish() ar2 = np.empty_like(ary) cl.enqueue_read_buffer(queue, buf, ar2) print la.norm(ary-ar2), ary.strides, ar2.strides (ar3, e) = cl.enqueue_map_buffer(queue, buf, cl.map_flags.READ, 0, ary.shape, ary.dtype, "C") print la.norm(ary-ar3), ary.strides, ar3.strides
ary is created with C-order, enqueue_map_buffer is told to return in C-order, but in fact it return in Fortran order. Changing order="C" to order="F" during ary creation makes this example work. -- Maxim _______________________________________________ PyOpenCL mailing list [email protected] http://lists.tiker.net/listinfo/pyopencl
