15.2.3.6 FLUSH Directive (TU*X only)

The FLUSH directive identifies synchronization points at which the implementation must provide a consistent view of memory. It takes the following form:

c$OMP FLUSH [(list)]

c
Is one of the following: C (or c), !, or * (see Section 15.2.1).


list
Is the name of one or more variables to be flushed. Names must be separated by commas.

Rules and Behavior

The FLUSH directive must appear at the precise point in the code at which the synchronization is required. To avoid flushing all variables, specify a list.

Thread-visible variables are written back to memory at the point at which this directive appears. Modifications to thread-visible variables are visible to all threads after this point. Subsequent reads of thread-visible variables fetch the latest copy of the data.

Thread-visible variables include the following data items:

The FLUSH directive is implied for the following directives (unless the NOWAIT keyword is used):

Examples

The following example uses the FLUSH directive for point-to-point synchronization between pairs of threads:

  c$OMP PARALLEL DEFAULT(PRIVATE) SHARED(ISYNC)
        IAM = OMP_GET_THREAD_NUM()
        ISYNC(IAM) = 0
  c$OMP BARRIER
        CALL WORK( )
  C I AM DONE WITH MY WORK, SYNCHRONIZE WITH MY NEIGHBOR
        ISYNC(IAM) = 1
  c$OMP FLUSH(ISYNC)
  C WAIT TILL NEIGHBOR IS DONE
        DO WHILE (ISYNC(NEIGH) .EQ. 0)
  c$OMP FLUSH(ISYNC)
        END DO
  c$OMP END PARALLEL


Previous Page Next Page Table of Contents