View Full Version : Using CL_MEM_USE_HOST_PTR with clEnqueueReadBuffer

11-26-2012, 10:59 AM
Suppose I first create a buffer using CL_MEM_USE_HOST_PTR:

mybuffer = clCreateBuffer(context, CL_MEM_READ_WRITE| CL_MEM_USE_HOST_PTR, sizeof(float)*n,myvec,&err);

where myvec is a float array of length n.

Next, some operations are performed in a kernel involving writing on array y.

Next, read the results using:

clEnqueueReadBuffer(queue, mybuffer, CL_TRUE, 0, sizeof(float)*n, myvec, 0, NULL, NULL);

Is this defined? Is this valid?

11-29-2012, 07:47 AM
Yes, this is valid under the following requirements, as explained in the OpenCL specification document:

All commands that use this buffer object have finished execution before the read command begins execution.[/*:m:v56mx2ur]
The buffer object is not mapped.[/*:m:v56mx2ur]
The buffer object is not used by any command-queue until the read command has finished execution.[/*:m:v56mx2ur]

11-30-2012, 06:07 AM
All right, thank you for the reply.