XL Fortran for AIX 8.1

Language Reference

ASSERT

Purpose

The ASSERT directive provides information to the compiler about the characteristics of DO loops. This assists the compiler in optimizing the source code.

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

Format



>>-ASSERT--(--assertion_list--)--------------------------------><
 
 

assertion
is ITERCNT(n) or NODEPS. ITERCNT(n) and NODEPS are not mutually exclusive, and you can specify both for the same DO loop. You can use at most one of each argument for the same DO loop.

ITERCNT(n)
where n specifies the number of iterations for a given DO loop. n must be a positive, scalar, integer initialization expression.

NODEPS
specifies that no loop-carried dependencies exist within a given DO loop.

Rules

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

ITERCNT provides an estimate to the compiler about roughly how many iterations the DO loop will typically run. There is no requirement that the value be accurate; ITERCNT will only affect performance, never correctness.

When NODEPS is specified, the user is explicitly declaring to the compiler that no loop-carried dependencies exist within the DO loop or any procedures invoked from within the DO loop. A loop-carried dependency involves two iterations within a DO loop interfering with one another. Interference occurs in the following situations:

It is possible for two complementary ASSERT directives to apply to any given DO loop. However, an ASSERT directive cannot be followed by a contradicting ASSERT directive for a given DO loop:

   !SMP$ ASSERT
(ITERCNT(10))
   !SMP$ INDEPENDENT, REDUCTION (A)
   !SMP$ ASSERT (ITERCNT(20))     ! invalid
         DO I = 1, N
             A(I) = A(I) * I
         END DO
 

In the example above, the ASSERT(ITERCNT(20)) directive contradicts the ASSERT(ITERCNT(10)) directive and is invalid.

The ASSERT directive overrides the -qassert compiler option for the DO loop on which the ASSERT directive is specified.

Examples

Example 1:

! An example of the ASSERT directive with NODEPS.
         PROGRAM EX1
           INTEGER A(100)
  !SMP$    ASSERT (NODEPS)
           DO I = 1, 100
             A(I) = A(I) * FNC1(I)
           END DO
         END PROGRAM EX1
 
         FUNCTION FNC1(I)
           FNC1 = I * I
         END FUNCTION FNC1

Example 2:

! An example of the ASSERT directive with NODEPS and
ITERCNT.
         SUBROUTINE SUB2 (N)
           INTEGER A(N)
    !SMP$  ASSERT (NODEPS,ITERCNT(100))
           DO I = 1, N
             A(I) = A(I) * FNC2(I)
           END DO
         END SUBROUTINE SUB2
 
         FUNCTION FNC2 (I)
           FNC2 = I * I
         END FUNCTION FNC2

Related Information


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