I need a way to create an memory object which can be accessed parallelly both in CPU and GPU, this memory will be read only. How can I do it?
OpenCL 2.0 supports memory coherence, and that is supported by the Bifrost & Valhall series of Arm Mali GPUs.
Details on its use here: https://developer.arm.com/documentation/101574/0400/OpenCL-2-0/Shared-virtual-memory
and here: https://developer.arm.com/documentation/101574/0400/Optimizing-OpenCL-for-Mali-GPUs/Optimizing-memory-allocation
If you need the memory object to wrap existing host memory, I suggest you look into using the host import feature of https://www.khronos.org/registry/OpenCL/extensions/arm/cl_arm_import_memory.txt. This will allow you to create a buffer from an existing application-supplied pointer. Parallel access is allowed as long as both the CPU and GPU are treating the memory as read-only.
If the memory object doesn't have to be created from an existing pointer, then you can just use clCreateBuffer and map the buffer for reading on the host (CL_MAP_READ) and simultaneously access it on the GPU from a kernel.
As Ben suggested, you can also do this with Shared Virtual Memory.
Regards,
Kevin