Next: , Previous: , Up: Task descriptions   [Contents][Index]


4.3.2 Source tasks

A <source_task> specification takes one of six forms:

<source_task> ::= ALL TASKS
| ALL TASKS <ident>
| TASK <expr>
| TASKS <restricted_ident>
| TASK GROUP <ident>
| TASKS <range> [, <range>]*

ALL TASKS specifies that each task will perform a given operation. If followed by a variable name ( <ident>), each task will individually bind <ident> to its task ID—a number from zero to one less than the total number of tasks. That is, ‘ ALL TASKS me’ will bind ‘me’ to ‘0’ on task 0, ‘1’ on task 1, and so forth.

TASK <expr>’ specifies that only the task described by arithmetic expression <expr> will perform the given operation. For example, ‘TASK 2*3+1’ says that only task 7 will act; the other tasks will do nothing.

TASKS <restricted_ident>’ describes a set of tasks that will perform a given operation. For instance, ‘TASKS x SUCH THAT x>0 /\ x<num_tasks-1’—read as “tasks x such that x is greater than zero and x is less than num_tasks minus one”—expresses that a given operation should be performed on all tasks except the first and last in the computation. On each task that satisfies the relational expression, ‘x’ will be bound to the task ID as in ALL TASKS above. Hence, ‘x’ will be undefined on task 0 , ‘1’ on task 1 , ‘2’ on task 2 , and so forth up to task ‘num_tasks-1’, on which ‘x’ will again be undefined.

TASK GROUP <ident>’ specifies that a previously defined group of tasks will perform a given operation. This form of <source_task> is described further in Binding variables.

TASKS <range>’ is syntactic sugar for the <restricted_ident> case with an anonymous <ident> and an IS IN relation. For example, ‘ TASKS {3, 5, 8}’ is equivalent to ‘ TASKS var SUCH THAT var IS IN {3, 5, 8}’ except that it does not bind variable ‘var’.

As per the definitions in Primitives and Restricted identifiers, respectively, <ident>s and <restricted_ident>s do not accept parentheses. Hence, ‘TASKS (bad SUCH THAT bad IS EVEN)’ and ‘ALL TASKS (no_good)’ result in parse errors while ‘TASKS fine SUCH THAT fine IS EVEN’ and ‘ALL TASKS dandy’ are acceptable constructs. As an analogy, ‘x = 3’ is valid in many general-purpose programming languages while ‘(x) = 3’ is not.

Variables declared in a ‘source_task’ specification are limited in scope to the surrounding statement.


Next: , Previous: , Up: Task descriptions   [Contents][Index]

Scott Pakin, pakin@lanl.gov