AnsweredAssumed Answered

accessing cl_mem buffer elements directly and modifying it.

Question asked by hemantp on Jul 21, 2013
Latest reply on Jul 23, 2013 by himanshu.gautam


is it possoble to directly access the elemts of of a buffer nad modify them ??

if so please list the syntax



//X is a vector of size M//

//some operations on bufX//

bufX = clCreateBuffer(ctx, CL_MEM_READ_WRITE, M*sizeof(cl_float), NULL, &err);

err = clEnqueueWriteBuffer(queue, bufX, CL_TRUE, 0,

        M * sizeof(cl_float), X, 0, NULL, NULL);

//now,i wish to set the first element of bufx to 0.//


but i have to read buffer to X

set 1 element to zero

and then write to bufX.


is there an easier way around??

i could find any support from the cl_mem struct for this action in the cl.h file.


thank you