Initializing array on the GPU!

Hi!

I am running the following kernel:

__kernel void InitArray(const float Val, __global float *Dst, const int DstIdx)
{
int gid = get_global_id(0);
Dst[DstIdx + gid] = Val;
}

But can never get the array to be modified. I can use clEnqueueReadBuffer and clEnqueueWriteBuffer and both are able to read and write from the buffer and data persists. But if I call InitArray and then clEnqueueReadBuffer, what comes back is different from what it should be. The buffer is created with CL_MEM_READ_WRITE flag and reads and writes to buffer are all blocking (CL_TRUE).

I also tried to read uninitialized buffer and the clEnqueueReadBuffer returns an array full of zeros. (expected random numbers).

Thanks!
Atmapuri

Hi!

Found the problem: the offset parameter clEnqueueReadBuffer was not in bytes. <g>

Thanks!
Atmapuri