Hi,
As per your example, it'll create a image in device memory and initialize the contents from the host memory buffer. So, updating the host memory buffer will not update the image stored in device.
There are several ways you can transfer data from host to device memory or even you can access the host memory directly from the kernel. But, if the memory object is needed to be access heavily by the kernels, then it is better to place it in device memory and copy the data from host to device as necessary. Your program flow may be look like:
image_dev = createImage() // in device memory // one time operation
// copy the data from host to device [FYI: there are other ways to achieve the same]
img_ptr = clEnqueueMapImage(image_dev, CL_MAP_WRITE)
// write the data using img_ptr as normal pointer
clEnqueueUnmapMemObject( image_dev, img_ptr)
// Access image_dev by several kernels
Note: synchronization is required (e.g. blocking call for mapping/un-mapping) to ensure that reading from and writing to image data are not done same time.
For details, I recommend you to go through the following sections in AMD APP OpenCL programming guide:
5.5 OpenCL Memory Objects
5.6 OpenCL Data Transfer Optimization
5.6.2.4 Application Scenarios and Recommended OpenCL Paths
Regards,