Version 1.6 of ai12s/ai12-0355-2.txt

Unformatted version of ai12s/ai12-0355-2.txt version 1.6
Other versions for file ai12s/ai12-0355-2.txt

!standard 4.5.10(3/5)          20-10-02 AI12-0355-2/02
!standard 4.5.10(21/5)
!standard 5.5(3/5)
!standard 5.5(9/5)
!standard 5.5.3(27/5)
!standard 13.1.1(37/3)
!class Amendment 20-08-28
!status Amendment 1-2012 20-09-09
!status WG9 Approved 22-06-22
!status ARG Approved 9-0-5 20-09-09
!status work item 20-08-28
!status received 20-08-28
!priority Medium
!difficulty Medium
!subject Aspect specifications for parallel constructs
!summary
All constructs that include the word "parallel" now permit an aspect_specification as part of their syntax.
!problem
We need a mechanism to pass information through to a lightweight parallelism scheduler. Something like an aspect specification might be a good way to specify such options.
!proposal
We propose to add an aspect_specification to every place the PARALLEL keyword is envisioned currently
parallel [(chunk_specification)] [aspect_specification] for ...
This allows specifying options to control the scheduling of parallel constructs.
!wording
Replace 4.5.10 (3/5) with:
value_sequence ::= '[' [parallel[(chunk_specification)] [aspect_specification]] iterated_element_association ']'
Modify 4.5.10 (21/5):
For the evaluation of a value_sequence, the iterated_element_association{, the chunk_specification, and the aspect_specification, if any, are elaborated in an arbitrary order. Next} [is elaborated, then] an iteration is performed, and for each value conditionally produced by the iteration (see 5.5 and 5.5.2), the associated expression is evaluated with the loop parameter having this value, [to produce]{which produces} a result that is converted to Value_Type[,] and {is} used to define the next value in the sequence.
Replace 5.5 (3/5) with:
iteration_scheme ::= while condition | for loop_parameter_specification | for iterator_specification | [parallel [aspect_specification]] for procedural_iterator | parallel [(chunk_specification)] [aspect_specification] for loop_parameter_specification | parallel [(chunk_specification)] [aspect_specification] for iterator_specification
Modify 5.5 (9/5):
For the execution of a loop_statement that has an iteration_scheme including a loop_parameter_specification, after elaborating the chunk_specification {and aspect_specification}, if any, the loop_parameter_specification is elaborated. ...
Add to the end of 5.5.3 (27/5):
... The aspect_specification, if any, is elaborated prior to the invocation of the iterating procedure.
Modify 13.1.1 (37/3):
At the freezing point of the associated entity, the aspect_specification is elaborated. {When appearing in a construct other than a declaration, an aspect_specification is elaborated as part of the execution of the construct.} The elaboration of the aspect_specification {consists of the elaboration of each aspect_definition in an arbitrary order. The elaboration of an aspect_definition} includes the evaluation of [the]{any} name or expression[, if any,]{that is part of the aspect_definition} unless the [aspect itself is]{part is itself} an expression. If the corresponding aspect{ (or part thereof)} represents an expression (as in a precondition), the elaboration {of that part} has no effect; the expression is evaluated later at points within the execution as specified elsewhere in this International Standard for the particular aspect.
!examples
An implementation could support an aspect specification associated with a parallel loop such as:
parallel with Collapse => 2, Grainsize => 100_000 for I in 1 .. 10_000_000 loop ... end loop;
!discussion
To allow passing tuning parameters through an implementation-defined API to an underlying lightweight thread scheduler to control lightweight parallelism, it is useful to permit aspect specifications on all parallel constructs.
!corrigendum 4.5.10(0)
Insert new clause:
See the conflict file for the actual changes.
!corrigendum 5.5(3/3)
Replace the paragraph:
iteration_scheme ::= while condition
  | for loop_parameter_specification
  | for iterator_specification
by:
iteration_scheme ::= while condition
  | for loop_parameter_specification
  | for iterator_specification
  | [parallel [aspect_specification]]
    for procedural_iterator
  | parallel [(chunk_specification)] [aspect_specification]
    for loop_parameter_specification
  | parallel [(chunk_specification)] [aspect_specification]
    for iterator_specification
!corrigendum 5.5(9/4)
Replace the paragraph:
For the execution of a loop_statement with the iteration_scheme being for loop_parameter_specification, the loop_parameter_specification is first elaborated. This elaboration creates the loop parameter and elaborates the discrete_subtype_definition. If the discrete_subtype_definition defines a subtype with a null range, the execution of the loop_statement is complete. Otherwise, the sequence_of_statements is executed once for each value of the discrete subtype defined by the discrete_subtype_definition that satisfies the predicates of the subtype (or until the loop is left as a consequence of a transfer of control). Prior to each such iteration, the corresponding value of the discrete subtype is assigned to the loop parameter. These values are assigned in increasing order unless the reserved word reverse is present, in which case the values are assigned in decreasing order.
by:
For the execution of a loop_statement that has an iteration_scheme including a loop_parameter_specification, after elaborating the chunk_specification and aspect_specification, if any, the loop_parameter_specification is elaborated. This elaborates the discrete_subtype_definition, which defines the subtype of the loop parameter. If the discrete_subtype_definition defines a subtype with a null range, the execution of the loop_statement is complete. Otherwise, the sequence_of_statements is conditionally executed once for each value of the discrete subtype defined by the discrete_subtype_definition that satisfies the predicates of the subtype (or until the loop is left as a consequence of a transfer of control). Prior to each such iteration, the corresponding value of the discrete subtype is assigned to the loop parameter associated with the given iteration. If the loop is a parallel loop, each chunk has its own logical thread of control with its own copy of the loop parameter; otherwise (a sequential loop), a single logical thread of control performs the loop, and there is a single copy of the loop parameter. Each logical thread of control handles a distinct subrange of the values of the subtype of the loop parameter such that all values are covered with no overlaps. Within each logical thread of control, the values are assigned to the loop parameter in increasing order unless the reserved word reverse is present, in which case the values are assigned in decreasing order.
!corrigendum 5.5.3(0)
Insert new clause:
See the conflict file for the actual changes.
!corrigendum 13.1.1(37/3)
Replace the paragraph:
At the freezing point of the associated entity, the aspect_specification is elaborated. The elaboration of the aspect_specification includes the evaluation of the name or expression, if any, unless the aspect itself is an expression. If the corresponding aspect represents an expression (as in a precondition), the elaboration has no effect; the expression is evaluated later at points within the execution as specified elsewhere in this International Standard for the particular aspect.
by:
At the freezing point of the associated entity, the aspect_specification is elaborated. When appearing in a construct other than a declaration, an aspect_specification is elaborated as part of the execution of the construct. The elaboration of the aspect_specification consists of the elaboration of each aspect_definition in an arbitrary order. The elaboration of an aspect_definition includes the evaluation of any name or expression that is part of the aspect_definition unless the part is itself an expression. If the corresponding aspect (or part thereof) represents an expression (as in a precondition), the elaboration of that part has no effect; the expression is evaluated later at points within the execution as specified elsewhere in this document for the particular aspect.
!ASIS
[Not sure. It seems like some new capabilities might be needed, but I didn't check - Editor.]
!ACATS test
ACATS B- and C-Tests are needed to check that the new capabilities are supported.
!appendix

From: Randy Brukardt
Sent: Friday, October 2, 2020  10:02 PM

One of the changes in AI12-0355-2 results in the following sentence/paragraph:

  For the evaluation of a value_sequence, the
  iterated_element_association, the chunk_specification, and the
  aspect_specification, if any, are elaborated in an arbitrary order,
  then an iteration is performed, and for each value
  conditionally produced by the iteration (see 5.5 and 5.5.2), the
  associated expression is evaluated with the loop parameter having this
  value, to produce a result that is converted to Value_Type, and used
  to define the next value in the sequence.

This guy has ten(!) commas, and they're used in a number of different ways. 
The original paragraph only used commas for sequencing, but Tucker added a 
list and "if any".

The easiest fix is to separate this into two sentences:

  For the evaluation of a value_sequence, the
  iterated_element_association, the chunk_specification, and the
  aspect_specification, if any, are elaborated in an arbitrary order.
  Then an iteration is performed, and for each value
  conditionally produced by the iteration (see 5.5 and 5.5.2), the
  associated expression is evaluated with the loop parameter having this
  value, to produce a result that is converted to Value_Type, and used
  to define the next value in the sequence.

But this is still pretty hard to read, so perhaps it would be better to use 
some bullets:

  For the evaluation of a value_sequence:
     * the iterated_element_association, the chunk_specification, and the
       aspect_specification, if any, are elaborated in an arbitrary order;
     * then an iteration is performed, and for each value
       conditionally produced by the iteration (see 5.5 and 5.5.2), the
       associated expression is evaluated with the loop parameter having this
       value, to produce a result that is converted to Value_Type, and used
       to define the next value in the sequence.

That only helps a little; the latter part is still a mouthful. Perhaps there 
is a better way to write this? Ideas?

Whatever we come up with can be my editorial review of this AI.

****************************************************************

From: Brad Moore
Sent: Saturday, October 3, 2020  11:05 PM

...
> That only helps a little; the latter part is still a mouthful. Perhaps 
> there is a better way to write this? Ideas?

I think I am not a fan of using bullets to imply a sequence of chronological 
events. To me bullets are better to illustrate a list of items and concepts.

How about these minor tweaks?

" For the evaluation of a value_sequence, the
  iterated_element_association, the chunk_specification, and the
  aspect_specification, if any, are elaborated in an arbitrary order.
  {Next}[Then] an iteration is performed, and for each value
  conditionally produced by the iteration (see 5.5 and 5.5.2), the
  associated expression is evaluated with the loop parameter having this
  value,[ to]{which} produce{s} a result that is converted to Value_Type[,] and used
  to define the next value in the sequence."

i.e.
 - Replacing "Then" with "Next". It feels weird to begin a sentence with "Then".
 - Replacing "to produce" with "which produces". This reads better to me.
 - Deleting the last comma which seems unnecessary, and simplifies the mental processing.

****************************************************************

From: Jeff Cousins
Sent: Tuesday, October 6, 2020  3:34 PM

Just to say I agree with Brad.

****************************************************************

Questions? Ask the ACAA Technical Agent