...
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
at (place)] Wiki Markup *\[*
phased Wiki Markup \[
1<mode1>, ...)] ] Wiki Markup \[(ph
...
• 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
at (place)] Wiki Markup *<T> \[*
phased Wiki Markup * \[*
1<mode1>, ...)] ] Wiki Markup *\[(ph{*}
seq (condition)] Wiki Markup * \[*
Wiki Markup {*}{ Expr }{*}
• Asynchronously start a new child task to evaluate Expr with at/phased/seq options as in statement-level async
...
• 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 Markup A point variable 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 Markup iteration 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 forall Wiki Markup iteration in rectangular region \[lo1:hi1, …\]
...
• Each forall has a pre-allocated phaser
foreach (point
phased Wiki Markup *\[i1, …\] : \[lo1:hi1, …\]) \[*
1<mode1>, ...)] ] Stmt Wiki Markup *\[(ph{*}
• Like forall, create multiple instances of Stmt as child async tasks, one per foreach Wiki Markup iteration 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
...
• 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”
complex32, complex64
• HJ includes complex as a primitive type e.g.,
complex32 cf = (1.0f, 2.0f); complex64 cd = (1.0, 2.0);
• The following operations are supported on complex:
+,-,*,/, ==, !=, toString(), exp(), sin(), cos(), sqrt(), pow()
array views
Wiki Markup T\[.\] declares a view on a 1-D Java array e.g.,
Wiki Markup double\[.\] view = new arrayView(baseArray, offset, \[lo1:hi1, …\])
where
baseArray = base 1-D Java array
offset = starting offset in baseArray for view
Wiki Markup \[lo1:hi1, …\] = rectangular region for view
abstract performance metrics
• Programmer inserts calls of the form, perf.addLocalOps(N), in sequential code
...