PDA

View Full Version : Initializing array on the GPU!



Atmapuri
06-28-2011, 04:49 AM
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

Atmapuri
06-28-2011, 05:51 AM
Hi!

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

Thanks!
Atmapuri