Next: Examples of the
Up: The FORALL Statement
Previous: General Form of
Execution of an element array assignment consists of the following steps:
- 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.
- 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.
-
Evaluation in any order of 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.
In the case of pointer assignment where the target is not a
pointer, the evaluation consists of identifying the object referenced
rather than computing its value.
-
Assignment of the computed expr values to the corresponding
variable locations (in the case of assignment-stmt) or the
association of the target values with the corresponding pointer-object locations (in the case of pointer-assignment-stmt) for all active combinations of index-name values. The assignments or associations may be made in
any order. In the case of a pointer assignment where the target
is not a pointer, this assignment consists of associating the pointer-object with the object referenced.
If the scalar mask expression is omitted, it is as if it were present
with the value .TRUE.
The scope of an index-name is the
FORALL statement itself.
A forall-stmt is not
HPF-conforming if the result of evaluating any expression in the forall-header affects or is affected by the evaluation of any other
expression in the forall-header.
- []Rationale.
This is consistent with the handling of DO loop bounds and
strides. Disallowing references to impure functions in a forall-triplet-spec-list was suggested, but the analogy to DO
bounds was considered too strong to overlook. Note that the scalar-mask-expr can only invoke pure functions, which are
side-effect free. Therefore, the scalar-mask-expr cannot
affect the values of the bounds.
(End of rationale.)
A forall-stmt is not HPF-conforming if it causes any atomic data object
to be assigned more than one value.
A data object is atomic if it contains no subobjects.
For the purposes of this restriction, any assignment (including array
assignment or assignment to a variable of derived type) to a non-atomic
object is considered to
assign to all subobjects contained by that object.
- []Rationale.
For example, an integer
variable is an atomic object, but an array of integers is an object
that is not atomic.
Similarly, assignment to an array section is equivalent to assignments to
each individual element (which may require further reductions when the
array contains objects of derived type).
This restriction allows cases such as
FORALL ( i = 1:10 ) a(indx(i)) = b(i)
if and only if indx contains no repeated values. Note that it
restricts FORALL behavior, but not syntax. Syntactic restrictions
to enforce this behavior would be either incomplete (ie. allow
undefined behavior) or exclude conceptually legal programs.
Since a function called from a forall-asssignment must be pure, it
is impossible for that function's evaluation to affect other expressions'
evaluations, either for the same combination of
index-name values or for a different combination.
In addition, it is possible that the compiler can perform
more extensive optimizations because all functions are pure.
(End of rationale.)
Next: Examples of the
Up: The FORALL Statement
Previous: General Form of
paula@erc.msstate.edu
Thu Jul 21 17:05:43 CDT 1994