openclreadonlyqualifiers

read_only vs const on non-image OpenCL parameters


Reading the OpenCL documentation, I know that the access qualifiers read_only and write_only are intended for image memory.

However, I'm noticing some people use these qualifiers on regular, non-image-memory, parameters, e.g.:

void foo(unsigned n, __global read_only int* data)

Note the lack of const.

My questions:

  1. Does read_only imply, in particular, const?
  2. Does read_only imply anything other than const? Something else that an OpenCL compiler can utilize?

... or is it just meaningless for non-image-memory, and ignored?


Solution

  • With recent CUDA versions, OpenCL compilation rejects such uses of read_only, with the message:

    error: access qualifier can only be used for pipe and image type
    

    so - I suppose this means that read_only isn't really meaningful for non-images. Just use const and forget about it.