Hmm, so did I get that totally wrong:
(from: examples/matrix-multiply.py)
[..]
h_a = numpy.random.rand(a_height, a_width).astype(numpy.float32)
h_b = numpy.random.rand(a_width, a_height).astype(numpy.float32)
h_c = numpy.empty((a_height, a_height)).astype(numpy.float32)
[..]
d_a_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=h_a)
d_b_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=h_b)
d_c_buf = cl.Buffer(ctx, mf.WRITE_ONLY, size=h_c.nbytes)
[..]
event = kernel(queue, (a_height,a_height), d_c_buf, d_a_buf, d_b_buf,
cl.LocalMemory(4* block_size**2),
cl.LocalMemory(4* block_size**2),
local_size=(block_size, block_size))
event.wait()
[..]
cl.enqueue_read_buffer(queue, d_c_buf, h_c).wait()
[..]
So there are 2D arrays (h_a,h_b,h_c) and the corresponding cl.Buffers d_... They are send
to the kernel here:
'event = kernel(queue, (a_height,a_height), d_c_buf, d_a_buf, d_b_buf,...'
But how is that connected to:
__kernel __attribute__((reqd_work_group_size(16,16,1)))
void
matrixMul( __global float* C, __global float* A, __global float* B,
__local float* As, __local float* Bs)
My C experience is a 'bit' rusty so please: what does 'float* A' do and
how does that differ from 'float *A'?
Thanks
Markus
Am 12.02.2010 um 19:01 schrieb Rohit Garg:
OpenCL doesn't support 2D arrays.
You'll _have_ to do that fancy stuff.
On Fri, Feb 12, 2010 at 11:11 PM, Markus Mohr <markus(a)johalla.de> wrote:
> Hi,
>
> I'm pretty new to opencl so this might be quite obvious. :)
>
> How do I pass a two dimensional array to a kernel, process it there and read it
back?
>
> Most examples have 1D arrays and those with 2D (like matrix-multiply) do a lot of
fancy stuff which I do not (yet) understand.
> To keep it simple, the processing would be just to add 1 to each element.
>
>
> thanks for your help
> Markus
> _______________________________________________
> PyOpenCL mailing list
> PyOpenCL(a)host304.hostmonster.com
>
http://host304.hostmonster.com/mailman/listinfo/pyopencl_tiker.net
>
--
Rohit Garg
http://rpg-314.blogspot.com/
Senior Undergraduate
Department of Physics
Indian Institute of Technology
Bombay