HOME
| OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"

5.6  scan Directive

Name: scan

Association: separating

Category: subsidiary

Properties: default

Separated directives

do, for, simd

Clauses

exclusive, inclusive

Clause set

Properties: unique, required, exclusive

Members: exclusive, inclusive

Semantics

The scan directive separates the final-loop-body of an enclosing simd construct or worksharing-loop construct (or a composite construct that combines them) into a structured block sequence that serves as an input phase and a structured block sequence that serves as a scan phase. The input phase contains all computations that update the list item in the iteration, and the scan phase ensures that any statement that reads the list item uses the result of the scan computation for that iteration. Thus, it specifies that a scan computation updates each list item on each logical iteration of the enclosing loop nest that is associated with the separated directive.

If the inclusive clause is specified, the input phase includes the preceding structured block sequence and the scan phase includes the following structured block sequence and, thus, the directive specifies that an inclusive scan computation is performed for each list item of list. If the exclusive clause is specified, the input phase excludes the preceding structured block sequence and instead includes the following structured block sequence, while the scan phase includes the preceding structured block sequence and, thus, the directive specifies that an exclusive scan computation is performed for each list item of list.

The result of a scan computation for a given iteration is calculated according to the last generalized prefix sum (PRESUMlast) applied over the sequence of values given by the original value of the list item prior to the loop and all preceding updates to the list item in the logical iteration space of the loop. The operation PRESUMlast(op, a1, …, aN ) is defined for a given binary operator op and a sequence of N values a1, …, aN as follows:

At the beginning of the input phase of each iteration, the list item is initialized with the value of the initializer expression of the reduction-identifier specified by the reduction clause on the separated construct. The update value of a list item is, for a given iteration, the value of the list item on completion of its input phase.

Let orig-val be the value of the original list item on entry to the separated construct. Let combiner be the combiner expression for the reduction-identifier specified by the reduction clause on the construct. Let ui be the update value of a list item for iteration i. For list items that appear in an inclusive clause on the scan directive, at the beginning of the scan phase for iteration i the list item is assigned the result of the operation PRESUMlast( combiner, orig-val, u0, …, ui). For list items that appear in an exclusive clause on the scan directive, at the beginning of the scan phase for iteration i = 0 the list item is assigned the value orig-val, and at the beginning of the scan phase for iteration i > 0 the list item is assigned the result of the operation PRESUMlast( combiner, orig-val, u0, …, ui-1).

For list items that appear in an inclusive clause, at the end of the separated construct, the original list item is assigned the private copy from the last logical iteration of the loops associated with the separated construct. For list items that appear in an exclusive clause, let k be the last logical iteration of the loops associated with the separated construct. At the end of the separated construct, the original list item is assigned the result of the operation PRESUMlast( combiner, orig-val, u0, …, uk).

Restrictions

Restrictions to the scan directive are as follows:

Cross References