Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

This page summarizes the Habanero-Java (HJ) language constructs used in COMP 322. For a summary of all HJ language constructs, see the HJ web page.

async Wiki Markup*\[*at (place)] 

Wiki Markup
           \[
phased Wiki Markup

\           [phased [(ph1<mode1>, ...)] ] 

Wiki Markup
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \[
           [seq (condition)]  Stmt 

Asynchronously start a new child task to execute Stmt

A destination place can optionally be specified in the at clause to specify where the task should execute

Task may optionally be phased on a specified subset, (ph1<mode1>, ...), of its parent’s phasers or on the entire set (default)

Task may optionally be serialized when the seq condition evaluates to true

finish Stmt

Execute Stmt, but wait until all (transitively) spawned asyncs and futures in Stmt’s scope have terminated

Propagate multiset of all exceptions thrown by spawned asyncs in Stmt’s scope

final future<T> f = async Wiki Markup*<T> \ [*at (place)] 

Wiki Markup
*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \[*
phased
Wiki Markup
*\[(ph{*}
                      [phased [(ph1<mode1>, ...)] ]                                             
Wiki Markup
*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \[*

                      [seq (condition)] { Expr }

Asynchronously start a new child task to evaluate Expr with at/phased/seq options as in statement-level async

f is a reference to object of type future<T> , which is a container for the value to be computed by the future  task

Expr is a statement sequence ending with return

f.get()

  • Wait until future f has completed execution, and propagate its return value  of type T
  • if T = void, then f.get() is evaluated as a statement (like a method call with a void return value)
  • get() also propagates any exception thrown by Expr

point

A point is an n-dimensional int tuple 

A point Wiki Markupvariable can hold values of different ranks e.g., point p; p = \ [1\]; p = \ [2,3\];

for (point Wiki Markup*\[i1, \] : \ [lo1:hi1, \]) Stmt{*}

Execute multiple instances of Stmt sequentially in lexicographic order, one per Wiki Markupiteration in rectangular region \ [lo1:hi1, \]

forall (point Wiki Markup*\[i1, \] : \ [lo1:hi1, \]) Stmt{*}

Create multiple parallel instances of Stmt as child async tasks, one per forall Wiki Markupiteration in rectangular region \ [lo1:hi1, \]

Implicit finish at end of forall

Each forall has a pre-allocated phaser

foreach (point Wiki Markup*\[i1, \] : \ [lo1:hi1, \]) \ [*phased Wiki Markup*\[(ph{*}1<mode1>, ...)] ] Stmt

Like forall, create multiple instances of Stmt as child async tasks, one per foreach Wiki Markupiteration in rectangular region \ [lo1:hi1, \]

  •   No implicit finish in foreach
  •   As with async, a foreach iteration may optionally be phased on a specified subset, (ph1<mode1>, ...), of its parent’s phasers or on the entire set

isolated Stmt

Execute Stmt in isolation (mutual exclusion) relative to all other instances of isolated statements

Stmt must not contain any parallel constructs

Weak atomicity: no guarantee on interactions with non-isolated statements 

new phaser(mode1);

Allocate a phaser with the specified mode, which can be one of SIG, WAIT, SIG_WAIT, SINGLE

Scope of phaser is limited to immediately enclosing finish

next;

Advance each phaser that this task is registered on to its next phase, in accordance with this task’s registration mode

Wait on each phaser that task is registered on with a wait capability (WAIT, SIG_WAIT, SINGLE)

next single Stmt

Execute a single instance of Stmt during the phase transition performed by next

All tasks executing the next single statement must be registered with all its phasers in SINGLE mode

signal

signal each phaser that task is registered on with a signal capability (SIG, SIG_WAIT, SIGNAL)

signal is a non-blocking operation --- computation between signal and next serves as a “split phase barrier”

abstract performance metrics

Programmer inserts calls of the form, perf.addLocalOps(N), in sequential code

HJ implementation computes total work and critical path length in units of programmer’s local ops