I would like to understand what the difference is when I create a buffer with read-only property and use it with __constant address space qualifier in the kernel or use it with const __global address space qualifier.
What I have already found those are not really answers for my question but they contain some useful information:
http://www.khronos.org/message_boards/showthread.php/6466-__constant-vs-const-__global
Is the access performance of __constant memory as same as __global memory on OpenCL
If I understand well the allocation in GPU's memory happens at clCreateBuffer function call. So what I do not understand is how the compiler decides the buffer is in the constant memory (which has a 64 KB limit) or in the global memory. (I know that in most of the cases the constant memory is a part of the global memory space.) If it depends on the address qualifier that means the 64 KB limit can be ignored using const __global.
Is there any difference in performance between __constant and const __global? The __global memory may be cached so both of them is read-only and (may be) cached.
(Source: 3.3 Memory Model/Global memory section and Figure 3.3; http://www.khronos.org/registry/cl/specs/opencl-1.x-latest.pdf#page=24)