If I have *3D data of arbitrairy size*, how do I get the x, y and z
coordinates in the kernel?

Lets say I set up the 3D data like this

================================
import pyopencl as cl
import numpy
import numpy.linalg as la

a = numpy.random.rand((2,3,4)).astype(numpy.float32)

==========================================


And have a kernel something like this,


==============================================
prg = cl.Program(ctx, """
    __kernel void polyn(__global const float *a, __global float *b)
    {
      int gid = get_global_id(0);
      int x = ???????????????????????
      int y = ???????????????????????
      int z = ???????????????????????

      b[gid] = a[gid] * x + 3 * y + 5 * z;
    }
    """).build()

prg.polyn(queue, a.shape, a_buf, dest_buf)
cl.enqueue_read_buffer(queue, dest_buf, a).wait()
print a
==============================================

1) How do upload the "a" array ?
2) How I get the x y and z coordinates for the current index in the volume?
I want to different things in the data depending on the x y and z
coordinates.

Thank you very much for your help

Christine
_______________________________________________
PyOpenCL mailing list
[email protected]
http://tiker.net/mailman/listinfo/pyopencl_tiker.net

Reply via email to