Hello,
This is something I'm a bit stumped on.
I know how to operate on two vectors by using "Adventures in Pyopencl", but
when I use components of a vector to do operations, I get the wrong results.
when printing the results, c = a zero vector.
Could you look at my simple code?
from numpy import *import pyopencl as cl
ctx = cl.create_some_context()queue = cl.CommandQueue(ctx)fstr = "__kernel void
part1(__global float* a, __global float* b,__global float* c,){ unsigned int i
= get_global_id(0); float value = 0; value = (a[i] + b[i]); c[i] = value ;
}"program = cl.Program(ctx,fstr).build()
o = array([range(10),range(10)])a = o[0,:]b = o[1,:]
mf = cl.mem_flagsa_buf = cl.Buffer(ctx,mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf
= a.copy())b_buf = cl.Buffer(ctx,mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf =
b.copy())dest_buf = cl.Buffer(.ctx, mf.WRITE_ONLY, b.nbytes)
program.part1(queue, a.shape, None, a_buf, b_buf,dest_buf)c =
empty_like(a)cl.enqueue_read_buffer(queue, dest_buf, c).wait()
Thanks,
Ajay
_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl