Hi, I'm Franco, I'm study physic in Argentina and I'm new in PyOpenCl word.

My problem in when I use barrier. This is my kernel:

b_dev = cl.array.arange(queue, N2, dtype=np.float32)
b_new_dev = cl.array.zeros(queue, N2, dtype=np.float32)
a_dev = cl.array.zeros(queue, N2, dtype=np.float32)

#kernel
prg = cl.Program(ctx, """
    __kernel void twice(__global float *a, __global float *b, __global float *c)
    {
      int gid = get_global_id(0);

      __local float a_local[17];

      a_local[gid + 1] = b[gid] + b[gid + 1] + b[gid + 2];
      c[gid + 1] = a_local[gid + 1];
      barrier(CLK_LOCAL_MEM_FENCE);
      a[gid] = a_local[gid];
    }
    """).build()
twice = prg.twice

twice(queue, (N,), None, a_dev.data, b_dev.data, b_new_dev.data)

print " b\n %s\n\n c\n %s\n vector A donde copio\n %s" %(b_dev,
b_new_dev, a_dev)


And generated this output:

b
 [  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.  10.  11.]

 c
 [  0.   3.   6.   9.  12.  15.  18.  21.  24.  27.  30.   0.]
 vector A donde copio
 [  1.65503965e-24   4.59149455e-41   6.00000000e+00   4.59149455e-41
   1.20000000e+01   0.00000000e+00   1.80000000e+01   0.00000000e+00
   2.40000000e+01   0.00000000e+00   0.00000000e+00   0.00000000e+00

Why the last vector is different to the seconds vector? What's I do bad?

Thanks

_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl

Reply via email to