Changes between Version 9 and Version 10 of Language
- Timestamp:
- 05/18/23 10:55:48 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Language
v9 v10 170 170 An expression of the form 171 171 172 `(``$domain``)` `{` ''r 1'' `,` ... `,` ''rn'' `}`173 174 where ''r 1'', . . . , ''rn'' are ''n'' expressions of type `$range`, is a ''Cartesian domain expression''.172 `(``$domain``)` `{` ''r,,1,,'' `,` ... `,` ''r,,n,,'' `}` 173 174 where ''r,,1,,'', . . . , ''r,,n,,'' are ''n'' expressions of type `$range`, is a ''Cartesian domain expression''. 175 175 It represents the domain of dimension ''n'' which is the Cartesian product of the ''n'' ranges, 176 i.e., it consists of all ''n''-tuples (''x 1'',...,''xn'') where ''x1'' ∈ ''r1'', ..., ''xn'' ∈ ''rn''.176 i.e., it consists of all ''n''-tuples (''x,,1,,'',...,''x,,n,,'') where ''x,,1,,'' ∈ ''r,,1,,'', ..., ''x,,n,,'' ∈ ''r,,n,,''. 177 177 The order on the domain is the dictionary order on tuples. 178 178 The type of this expression is `$domain(n)`. 179 179 When a Cartesian domain expression is used to initialize an object of domain type, the `($domain)` may be omitted. For example: 180 180 {{{ 181 $domain(3) dom = { 0 .. 3, r2, 10 .. 2 #-2 };181 $domain(3) dom = { 0..3, r2, 10..2#-2 }; 182 182 }}} 183 183 … … 332 332 A domain statement has the form 333 333 334 `$for` `(``int` ''i 1''`,` ...`,` ''in'' `:` ''dom''`)` ''S''335 336 where ''i 1'', . . . , ''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 336 where ''i,,1,,'', . . . , ''i,,n,,'' are ''n'' identifiers, ''dom'' is an expression of type `$domain(`''n''`)`, and ''S'' is a statement. 337 337 The identifiers declare ''n'' variables of integer type. 338 338 Control 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. … … 342 342 For example, 343 343 {{{ 344 $for (int i : 0 ..10) S344 $for (int i: 0..10) S 345 345 }}} 346 346 is equivalent to 347 347 {{{ 348 $for (int i: ($domain(1)){0 ..10}) S348 $for (int i: ($domain(1)){0..10}) S 349 349 }}} 350 350 … … 355 355 A parallel for loop statement has the form 356 356 357 `$parfor` `(``int` ''i 1''`,` ...`,` ''in'' `:` ''dom''`)` ''S''357 `$parfor` `(``int` ''i,,1,,''`,` ...`,` ''i,,n,,'' `:` ''dom''`)` ''S'' 358 358 359 359 The syntax is exactly the same as that for the sequential domain iteration loop `$for`, only with `$parfor` replacing `$for`. 360 360 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. 361 The semantics are as follows: when control reaches the loop, one process is spawned for each element of the domain. 362 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. 363 Each process executes the statement ''S'' in this context. 364 Finally, each of these processes is waited on at the end. 365 In particular, there is an effective barrier at the end of the loop, and all the spawned processes disappear after this point. 362 366 363 367 === Guarded commands: `$when`
