An OpenCL memory model, being a relaxed memory architecture, specifies some restrictions or undefined behavior around the cl_mem
object. These undefined behaviors occur mostly when there is a simultaneous read and write to a buffer. Following are listed some undefined scenarios:
If the buffer is created with
CL_MEM_WRITE_ONLY
flag and the kernel reads from this buffer pointer on the devices side, then it's an undefined behavior. That means reading from aCL_MEM_WRITE_ONLY
buffer inside the kernel is undefined.Similarly writing to a buffer created using the flag
CL_MEM_READ_ONLY
is undefined inside the kernel.It is possible to create two OpenCL
cl_mem
buffers from the same host memory using theCL_MEM_USE_HOST_PTR
flag. There may be an overlapping memory region. If one or more commands enqueued to the command queue operate on the twocl_mem
objects but pointing to the same host memoryhost_ptr
, then such an operation is not defined. It is the application...