XL Fortran for AIX 8.1

Language Reference



The INDEPENDENT directive, if used, must precede a DO loop, FORALL statement, or FORALL construct. It specifies that each operation in the FORALL statement or FORALL construct, can be executed in any order without affecting the semantics of the program. It also specifies each iteration of the DO loop, can be executed without affecting the semantics of the program.

This directive only takes effect if you specify either the -qsmp or -qhot compiler option.


                V                                             |


The first noncomment line (not including other directives) following the INDEPENDENT directive must be a DO loop, FORALL statement, or the first statement of a FORALL construct. This line cannot be an infinite DO or DO WHILE loop. The INDEPENDENT directive applies only to the DO loop that is immediately following the directive and not to any nested DO loops.

An INDEPENDENT directive can have at most one NEW clause and at most one REDUCTION clause.

If the directive applies to a DO loop, no iteration of the loop can interfere with any other iteration. Interference occurs in the following situations:

If the NEW clause is specified, the directive must apply to a DO loop. The NEW clause modifies the directive and any surrounding INDEPENDENT directives by accepting any assertions made by such directive(s) as true. It does this even if the variables specified in the NEW clause are modified by each iteration of the loop. Variables specified in the NEW clause behave as if they are private to the body of the DO loop. That is, the program is unaffected if these variables (and any variables associated with them) were to become undefined both before and after each iteration of the loop.

Any variable you specify in the NEW clause or REDUCTION clause must not:

For FORALL, no combination of index values affected by the INDEPENDENT directive assigns to an atomic storage unit that is required by another combination. If a DO loop, FORALL statement, or FORALL construct all have the same body and each is preceded by an INDEPENDENT directive, they behave the same way.

The REDUCTION clause asserts that updates to named variables will occur within REDUCTION statements in the INDEPENDENT loop. Furthermore, the intermediate values of the REDUCTION variables are not used within the parallel section, other than in the updates themselves. Thus, the value of the REDUCTION variable after the construct is the result of a reduction tree.

If you specify the REDUCTION clause, the directive must apply to a DO loop. The only reference to a REDUCTION variable in an INDEPENDENT DO loop must be within a reduction statement.

A REDUCTION variable must be of intrinsic type, but must not be of type character. A REDUCTION variable must not be an allocatable array.

A REDUCTION variable must not occur in:

A REDUCTION statement can have one of the following forms:

>>-reduction_var_ref =--reduction_function--(expr,--reduction_var_ref)-><
>>-reduction_var_ref =--reduction_function--(reduction_var_ref,--expr)-><


is a variable or subobject of a variable that appears in a REDUCTION clause

is one of: +, -, *, .AND., .OR., .EQV., .NEQV., or .XOR.

is one of: MAX, MIN, IAND, IOR, or IEOR

The following rules apply to REDUCTION statements:

  1. A reduction statement is an assignment statement that occurs in the range of an INDEPENDENT DO loop. A variable in the REDUCTION clause must only occur in a REDUCTION statement within the INDEPENDENT DO loop.
  2. The two reduction_var_refs that appear in a REDUCTION statement must be lexically identical.
  3. The syntax of the INDEPENDENT directive does not allow you to designate an array element or array section as a REDUCTION variable in the REDUCTION clause. Although such a subobject may occur in a REDUCTION STATEMENT, it is the entire array that is treated as a REDUCTION variable.
  4. You cannot use the following form of the REDUCTION statement:

    >>-reduction_var_ref-- = --expr-- - --reduction_var_ref--------><


Example 1:

       INTEGER A(10),B(10,12),F
!IBM*  INDEPENDENT                    ! The NEW clause cannot be
       FORALL (I=1:9:2) A(I)=A(I+1)   ! specified before a FORALL
       DO M=1,10
         J=F(M)                       ! 'J' is used as a scratch
         A(M)=J*J                     ! variable in the loop
         DO N=1,12                    ! The first executable statement
           B(M,N)=M+N*N               ! following the INDEPENDENT must
         END DO                       ! be either a DO or FORALL
       END DO

Example 2:

       DO J = 1, M
         X = X + J**2
       END DO

Example 3:

       INTEGER A(100), B(100, 100)
!SMP$  INDEPENDENT, REDUCTION(A), NEW(J)   ! Example showing an array used
       DO I=1,100                          ! for a reduction variable
         DO J=1, 100
           A(I)=A(I)+B(J, I)
         END DO
       END DO

Related Information

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]