Changes between Version 9 and Version 10 of Language


Ignore:
Timestamp:
05/18/23 10:55:48 (3 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Language

    v9 v10  
    170170An expression of the form
    171171
    172   `(``$domain``)`  `{` ''r1'' `,` ... `,` ''rn'' `}`
    173 
    174 where ''r1'', . . . , ''rn'' are ''n'' expressions of type `$range`, is a ''Cartesian domain expression''.
     172  `(``$domain``)`  `{` ''r,,1,,'' `,` ... `,` ''r,,n,,'' `}`
     173
     174where ''r,,1,,'', . . . , ''r,,n,,'' are ''n'' expressions of type `$range`, is a ''Cartesian domain expression''.
    175175It represents the domain of dimension ''n'' which is the Cartesian product of the ''n'' ranges,
    176 i.e., it consists of all ''n''-tuples (''x1'',...,''xn'') where ''x1'' ∈ ''r1'', ..., ''xn'' ∈ ''rn''.
     176i.e., it consists of all ''n''-tuples (''x,,1,,'',...,''x,,n,,'') where ''x,,1,,'' ∈ ''r,,1,,'', ..., ''x,,n,,'' ∈ ''r,,n,,''.
    177177The order on the domain is the dictionary order on tuples.
    178178The type of this expression is `$domain(n)`.
    179179When a Cartesian domain expression is used to initialize an object of domain type, the `($domain)` may be omitted. For example:
    180180{{{
    181 $domain(3) dom = { 0 .. 3, r2, 10 .. 2 # -2 };
     181$domain(3) dom = { 0..3, r2, 10..2#-2 };
    182182}}}
    183183
     
    332332A domain statement has the form
    333333
    334   `$for` `(``int` ''i1''`,` ...`,` ''in'' `:` ''dom''`)` ''S''
    335 
    336 where ''i1'', . . . , ''in'' are ''n'' identifiers, ''dom'' is an expression of type `$domain(`''n''`)`, and ''S'' is a statement.
     334  `$for` `(``int` ''i,,1,,''`,` ...`,` ''i,,n,,'' `:` ''dom''`)` ''S''
     335
     336where ''i,,1,,'', . . . , ''i,,n,,'' are ''n'' identifiers, ''dom'' is an expression of type `$domain(`''n''`)`, and ''S'' is a statement.
    337337The identifiers declare ''n'' variables of integer type.
    338338Control iterates over the values of the domain, assigning the integer variables the components of the current tuple in the domain at the start of each iteration.
     
    342342For example,
    343343{{{
    344 $for (int i : 0 .. 10) S
     344$for (int i: 0..10) S
    345345}}}
    346346is equivalent to
    347347{{{
    348 $for (int i: ($domain(1)){0 .. 10}) S
     348$for (int i: ($domain(1)){0..10}) S
    349349}}}
    350350
     
    355355A parallel for loop statement has the form
    356356
    357   `$parfor` `(``int` ''i1''`,` ...`,` ''in'' `:` ''dom''`)` ''S''
     357  `$parfor` `(``int` ''i,,1,,''`,` ...`,` ''i,,n,,'' `:` ''dom''`)` ''S''
    358358
    359359The syntax is exactly the same as that for the sequential domain iteration loop `$for`, only with `$parfor` replacing `$for`.
    360360
    361 The semantics are as follows: when control reaches the loop, one process is spawned for each element of the domain. That process has local variables corresponding to the iteration variables, and those local variables are initialized with the components of the tuple for the element of the domain that process is assigned. Each process executes the statement ''S'' in this context. Finally, each of these processes is waited on at the end. In particular, there is an effective barrier at the end of the loop, and all the spawned processes disappear after this point.
     361The semantics are as follows: when control reaches the loop, one process is spawned for each element of the domain.
     362That process has local variables corresponding to the iteration variables, and those local variables are initialized with the components of the tuple for the element of the domain that process is assigned.
     363Each process executes the statement ''S'' in this context.
     364Finally, each of these processes is waited on at the end.
     365In particular, there is an effective barrier at the end of the loop, and all the spawned processes disappear after this point.
    362366
    363367=== Guarded commands: `$when`