__global memory model within kernel

Hi,

In one of my own comments (in a kernel) I have just read that for __global memory only one read and one write access must occur. I wanted to check the details for this (i.e. if this refers to the whole kernel, the kernel until a barrier is encountered, statement level etc., or if it is simply a plain wrong comment); can anyone please enlighten me and also point me to the relevant sections in the standard (or does it simply take over the C guarantees)?

thanks, Thomas

No such limitation. You can do multiple reads and writes to global memory from within a kernel. You should go back and ask your past self what they meant in the comment.

Correct me if I am wrong, but IIRC then something like this:
y = ++x[i] - x[i]++;
is ill-formed in C. (obviously it’s hardly written intentionally that way, but x can simply be two different pointer variables that refer to the same memory address).
Does OpenCL provide any guarantee with respect to this expression (e.g. a strict left-to-right evaluation order) or is it equally ill-formed?

OpenCL C is based on C99, so if it is ill-defined in C99, it’s ill-defined in OpenCL C.