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:

Syntax

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 iconNote

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 demonstrates how SYNC MEMORY can be used to implement segment ordering. The example uses a specialized DO loop called a spin-wait loop:

LOGICAL, VOLATILE :: LOCKED[*] = .TRUE.
INTEGER(4) :: test, G, H

test = THIS_IMAGE()
IF (test == G) THEN
   SYNC MEMORY
   LOCKED[b] = .FALSE.
   SYNC MEMORY
ELSE IF (test == H) then
   DO WHILE (LOCKED)
   END DO
   SYNC MEMORY
END IF

Once image H starts executing the spin-wait loop, it will continue until it finds the value .FALSE. for LOCKED. The VOLATILE attribute causes the value to be retested during each loop execution. The effect is that the segment on image G before the first SYNC MEMORY statement precedes the segment on image H that follows the third SYNC MEMORY statement.

The second SYNC MEMORY statement tells the compiler to release the lock immediately rather than later in the following segment.

See Also


Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.