This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Questions About buffer/image use CL_MEM_USE_HOST_PTR flag

Hi!when i was using CL_MEM_USE_HOST_PTR flag to create buffer or image, i hvae some questions about the driver's action. Hope for help.
Q1: Why Copies the data pointed to by the host memory pointer into the buffer when the first kernel using this buffer starts running?If the value has been modified after clCreateBuffer but before clEnqueueNDRangeKernel,is the GPU read before or after modification?

code like this :

void *host_ptr = malloc(size);

fill_buffer_with_random_values(host_ptr);

cl_mem buffer = clCreateBuffer(ctx, CL_MEM_USE_HOST_PTR , size, host_ptr, &err);

memset(host_ptr, 0, size);

clSetKernelArg(kernel, index, &buffer);

...

clEnqueueNDRangeKernel();

OpeCL ARM Guide:

developer.arm.com/.../about-memory-allocation

Q2:If I Create a buffer with CL_MEM_USE_HOST_PTR (ptr point to random data),and create a 2D image associated with this buffer. I can memset the gpu buffer to 0 by using API clEnqueueWriteBuffer, then, I write the 2D image in kernel func. But, when I map this image to host by using API clEnqueueMapImage,Only the values in image size range(target pixels) have been mapped correctly. The values out of image range but in row_pitch range are still same as the host_ptr when buffer are created.I think it should be 0.

Why MALI driver didn't map all the row_pitch region to host when using clEnqueuMapImage?

OpenCL Spec define the mapped region as follow:

Thanks!