Site Tools


flush-openmp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

flush-openmp [June 11, 2026 at 09:19] – created - external edit 127.0.0.1flush-openmp [June 11, 2026 at 09:23] (current) Ivan Janevski
Line 1: Line 1:
 # Flush (OpenMP) # Flush (OpenMP)
-C's `volatile` keyword tells the compiler that a variable can change outside normal program flow and must not be cached in a register: every read goes to memory and every write is committed immediately. OpenMP threads face a similar problem at a larger scale: the compiler and CPU are free to keep shared variables in registers or store-buffers, so one thread's writes may not be visible to another without explicit synchronisation. **Flush** is OpenMP's mechanism for enforcing that visibility: it commits all pending writes to shared memory and invalidates locally cached reads, making the calling thread's view consistent with every other thread. Barriers, critical sections, and atomics all imply a flush, so the directive is only needed when synchronising through a bare shared variable with no other construct present.+C's `volatile` keyword tells the compiler that a variable can change outside normal program flow and must not be cached in a register: every read goes to memory and every write is committed immediately. OpenMP threads face a similar problem at a larger scale: the compiler and CPU are free to keep shared variables in registers or store-buffers, so one thread's writes may not be visible to another without explicit synchronisation. 
 + 
 +**Flush** is OpenMP's mechanism for enforcing that visibility: it commits all pending writes to shared memory and invalidates locally cached reads, making the calling thread's view consistent with every other thread. Barriers, critical sections, and atomics all imply a flush, so the directive is only needed when synchronising through a bare shared variable with no other construct present.
  
 ```c ```c
flush-openmp.1781169574.txt.gz · Last modified: by 127.0.0.1