Volatile Keyword What exactly does it do?

What exactly does the volatile keyword do (on shared memory variables)?

Does it force synchronised access across all warps on the GPU?

Or is it simply there for the compiler so that the order of the code is maintained and not optimised differently?

It does not provide any synchronization. In the case you describe, it should force a read of the given smem location everytime it is used by an instruction, as opposed to reading once into a register and referring to the register in subsequent times.


double post

Okay, cool that is good news.

Is there a way to reinterpret the cast of a shared memory variable to volatile on a specific line? specifically I only need the threads in a warp to update at very specific points (after a single thread conditional divergence). So far I simply have to use the volatile keyword otherwise the other threads don’t register the new data in the shared memory.