[ HPF Home | Versions | Compilers | Projects | Publications | Applications | Benchmarks | Events | Contact ]



Next:
Examples of the Up: The FORALL Construct Previous: General Form of

Interpretation of the FORALL Construct

Execution of a FORALL construct consists of the following steps:

  1. Evaluation in any order of the subscript and stride expressions in the forall-triplet-spec-list. The set of valid combinations of index-name values is then the Cartesian product of the sets defined by these triplets.

  2. Evaluation of the scalar-mask-expr for all valid combinations of index-name values. The mask elements may be evaluated in any order. The set of active combinations of index-name values is the subset of the valid combinations for which the mask evaluates to .TRUE.

  3. Execute the forall-body-stmts in the order they appear. Each statement is executed completely (that is, for all active combinations of index-name values) according to the following interpretation:

    1. Statements in the forall-assignment category (i.e. assignment statements and pointer assignment statements) evaluate the expr and all expressions within variable (in the case of assignment-stmt) or target and all expressions within pointer-object (in the case of pointer-assignment-stmt) of the forall-assignment for all active combinations of index-name values. These evaluations may be done in any order. The expr values are then assigned to the corresponding variable locations (in the case of assignment-stmt) or the target values are associated with the corresponding pointer-object locations (in the case of pointer-assignment-stmt). The assignment or association operations may also be performed in any order.

    2. Statements in the where-stmt and where-construct categories evaluate their mask-expr for all active combinations of values of index-names. All elements of all masks may be evaluated in any order. The WHERE statement's assignment (or assignments within the WHERE branch of the construct) are then executed in order using the above interpretation of array assignments within the FORALL, but the only array elements assigned are those selected by both the active index-name values and the WHERE mask. Finally, the assignments in the ELSEWHERE branch are executed if that branch is present. The assignments here are also treated as array assignments, but elements are only assigned if they are selected by both the active combinations and by the negation of the WHERE mask.

    3. Statements in the forall-stmt and forall-construct categories first evaluate the subscript and stride expressions in the forall-triplet-spec-list for all active combinations of the outer FORALL constructs. The set of valid combinations of index-names for the inner FORALL is then the union of the sets defined by these bounds and strides for each active combination of the outer index-names, the outer index names being included in the combinations generated for the inner FORALL. The scalar mask expression is then evaluated for all valid combinations of the inner FORALL's index-names to produce the set of active combinations. If there is no scalar mask expression, it is as if it were present with the constant value .TRUE. Each statement in the inner FORALL is then executed for each active combination (of the inner FORALL), recursively following the interpretations given in this section.

If the scalar mask expression is omitted, it is as if it were present with the value .TRUE.

Each forall-assignment must obey the same restrictions in a forall-construct as in a simple forall-stmt. In addition, each where-stmt or assignment nested within a where-construct must obey these restrictions. (Note that any innermost statement within nested FORALL constructs must fall into one of these two categories.) For example, an assignment may not cause the same array element to be assigned more than once. Different statements may, however, assign to the same array element, and assignments made in one statement may affect the execution of a later statement.



Next:
Examples of the Up: The FORALL Construct Previous: General Form of



©2000-2006 Rice University [ Contact Us | HiPerSoft | Computer Science ]

paula@erc.msstate.edu
Thu Dec 8 16:17:11 CST 1994