next up previous contents
Next: The GEOMETRY Directive Up: HPF_CRAFT Functional Summary Previous: The RESIDENT Directive

The ATOMIC UPDATE Directive

In HPF_CRAFT, the ATOMIC UPDATE directive tells the compiler that a particular data item or the elements of a particular array for a specified operation must be updated atomically. This can be used within loops or in array syntax and applies to both the elements of an array with an assignment of a permutation and the elements of an array within a loop.

In the following example, all references to R(IX(I)) occur atomically, thus eliminating the possibility that different iterations might try to modify the same element concurently.

REAL R(200), S(1000)

INTEGER IX(1000)

!HPF$ DISTRIBUTE R(BLOCK), S(BLOCK), IX(BLOCK)

!HPF$ INDEPENDENT (I) ON S(I)

DO I = 1, 1000

!HPF$ ATOMIC UPDATE

R(IX(I)) = R(IX(I)) + S(I)

END DO