Intel® Fortran Compiler 18.0 Developer Guide and Reference

SYNC MEMORY

Statement: Ends one image segment and begins another. Each segment can then be ordered in some way with respect to segments on other images. It takes the following form:

SYNC MEMORY [([STAT=stat-var][, ERRMSG=err-var])]

stat-var

Is a scalar integer variable in which the status of the synchronization is stored.

err-var

Is a scalar default character variable in which an error condition is stored if such a condition occurs.

STAT= and ERRMSG= can appear in either order, but only once in a SYNC IMAGES statement.

Description

Unlike the other image control statements, this statement does not have any built-in synchronization effect.

The action regarding X on image Q precedes the action regarding Y on image Q if, by execution of statements on image P, the following is true:

User-defined ordering of segment Pi on image P to precede segment Qj on image Q occurs when the following happens:

Execution of the cooperative synchronization between images P and Q must include a dependency that forces execution on image P of the statements that initiate the synchronization to precede the execution on image Q of the statements that complete the synchronization. The mechanisms available for creating such a dependency are processor dependent.

NOTE

SYNC MEMORY usually suppresses compiler optimizations that may reorder memory operations across the segment boundary defined by the SYNC MEMORY statement. It ensures that all memory operations initiated in the preceding segments in its image complete before any memory operations in the subsequent segment in its image are started.

Example

The following example should be run on two images:

use, intrinsic :: iso_fortran_env
logical (atomic_logical_kind), save :: locked[*] = .true.
logical val
integer :: iam

iam = this_image()

if (iam == 1) then
   sync memory
   call atomic_define(locked[2], .false.)
else if (iam == 2) then
   val = .true.
   do while (val)
      call atomic_ref(val, locked)
   end do
   sync memory
end if

print *, 'success'
end

See Also