opencl Writing an array


Writing an array consists of two steps:

  1. Allocating the memory
  2. Copying the data

To allocate the memory, a simple call to

_mem = clCreateBuffer($queue, $mem_flags, $size, $host_ptr, &err);

is enough. If you decided to copy the host pointer via the mem_flags, you are done. Otherwise you can copy the data whenever you like with

err = clEnqueueWriteBuffer($queue, _mem, $blocking, $offset, $size, $source, 0, null, null);