Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
| *[Home|COMP322]* | *[Owlspace Course Site - Section 1|https://owlspace-ccm.rice.edu/portal/site/COMP-322-ELEC-323-A01-Sp11]* | *[Owlspace Course Site - Section 2|https://owlspace-ccm.rice.edu/portal/site/COMP-322-ELEC-323-A02-Sp11]* | *[Office Hours|322OfficeHours]* | *[Turnin Guide|322TurninGuide]* | *[HJ Info|HJDownload]* |

h1. HJ Language Summary

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|http://habanero.rice.edu/hj].

{color:#ff0000}{*}async{*}{color} {color:#515151}*\[*{color}{color:#ff0000}{*}at{*}{color} {color:#515151}*(place)\] *{color}

{color:#515151}&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \[{color}{color:#ff0000}phased{color} {color:#515151}\[(ph{color}{color:#515151}{~}1{~}{color}{color:#515151}<mode{color}{color:#515151}{~}1{~}{color}{color:#515151}>, ...)\] \]&nbsp;{color}

{color:#515151}&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \[{color}{color:#ff0000}seq{color} {color:#515151}(condition)\]{color} {color:#515151}&nbsp;Stmt&nbsp;{color}

{color:#515151}•{color} {color:#515151}Asynchronously start a new child task to execute Stmt{color}

{color:#515151}•{color} {color:#515151}A destination place can optionally be specified in the{color} {color:#ff0000}at{color} {color:#515151}clause to specify where the task should execute{color}

{color:#515151}•{color} {color:#515151}Task may optionally be{color} {color:#ff0000}phased{color} {color:#515151}on a specified subset, (ph{color}{color:#515151}{~}1{~}{color}{color:#515151}<mode{color}{color:#515151}{~}1{~}{color}{color:#515151}>, ...), of its parent’s phasers or on the entire set (default){color}

{color:#515151}•{color} {color:#515151}Task may optionally be serialized when the{color} {color:#ff0000}seq{color} {color:#515151}condition evaluates to true{color}

{color:#ff1314}{*}finish{*}{color} {color:#ff1314}{*}Stmt{*}{color}

{color:#515151}•{color} {color:#515151}Execute Stmt, but wait until all (transitively) spawned asyncs and futures in Stmt’s scope have terminated{color}

{color:#515151}•{color} {color:#515151}Propagate multiset of all exceptions thrown by spawned asyncs in Stmt’s scope{color}

{color:#ff0000}{*}final futur{*}{color}{color:#515151}{*}e{*}{color}{color:#515151}*<T> f =*{color} {color:#ff0000}{*}async{*}{color}{color:#515151}*<T> \[*{color}{color:#ff0000}{*}at{*}{color}{color:#515151}*&nbsp;(place)\]&nbsp;*{color}

{color:#515151}*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \[*{color}{color:#ff0000}{*}phased{*}{color} {color:#515151}*\[(ph{*}{color}{color:#515151}{*}{~}1{~}{*}{color}{color:#515151}*<mode{*}{color}{color:#515151}{*}{~}1{~}{*}{color}{color:#515151}*>, ...)\] \] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;*{color}

{color:#515151}*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \[*{color}{color:#ff0000}{*}seq{*}{color}{color:#515151}*&nbsp;*{color}{color:#515151}*(condition)\]&nbsp;*{color}

{ Expr }

{color:#515151}•{color} {color:#515151}Asynchronously start a new child task to evaluate Expr with{color} {color:#ff0000}at{color}{color:#515151}/{color}{color:#ff0000}phased{color}{color:#515151}/{color}{color:#ff0000}seq{color} {color:#515151}options as in statement-level&nbsp;{color}{color:#ff0000}async{color}

{color:#515151}•{color} {color:#515151}f is a reference to object of type{color} {color:#ff0000}future{color}{color:#515151}<T> , which is a container for the value to be computed by the future&nbsp; task{color}

{color:#515151}•{color} {color:#515151}Expr is a statement sequence ending with{color} {color:#ff0000}return{color}

{color:#ff1314}{*}f.*{color}{color:#ff1314}{*}get()*{color}
* {color:#515151}Wait until future f has completed execution, and propagate its return value&nbsp; of type T{color}
* {color:#515151}if T = void, then{color} {color:#ff0000}f.get(){color} {color:#515151}is evaluated as a statement (like a method call with a void return value){color}
* {color:#515151}get() also propagates any exception thrown by Expr{color}

{color:#ff1314}{*}point{*}{color}

{color:#515151}•{color} {color:#515151}A{color} {color:#ff0000}point{color} {color:#515151}is an n-dimensional int tuple&nbsp;{color}

{color:#515151}•{color} {color:#515151}A{color} {color:#ff0000}point{color} {color:#515151}variable can hold values of different ranks e.g., point p; p = \[1\]; … p = \[2,3\]; …{color}

{color:#ff0000}{*}for{*}{color} {color:#515151}*(*{color}{color:#ff0000}{*}point{*}{color} {color:#515151}*\[i1, …\] : \[lo1:hi1, …\]) Stmt{*}{color}

{color:#515151}•{color} {color:#515151}Execute multiple instances of Stmt sequentially in lexicographic order, one per{color} {color:#515151}iteration in rectangular region \[lo1:hi1, …\]{color}

{color:#ff0000}{*}forall{*}{color} {color:#515151}*(*{color}{color:#ff0000}{*}point{*}{color} {color:#515151}*\[i1, …\] : \[lo1:hi1, …\]) Stmt{*}{color}

{color:#515151}•{color} {color:#515151}Create multiple parallel instances of Stmt as child{color} {color:#ff0000}async{color} {color:#515151}tasks, one per{color} {color:#ff0000}f{color}{color:#ff0000}orall{color} {color:#515151}iteration in rectangular region \[lo1:hi1, …\]{color}

{color:#515151}•{color} {color:#515151}Implicit{color} {color:#ff0000}finish{color} {color:#515151}at end of{color} {color:#515151}forall{color}

{color:#515151}•{color} {color:#515151}Each{color} {color:#515151}forall{color} {color:#515151}has a pre-allocated{color} {color:#ff0000}phaser{color}

{color:#ff0000}{*}foreach{*}{color} {color:#515151}*(*{color}{color:#ff0000}{*}point{*}{color} {color:#515151}*\[i1, …\] : \[lo1:hi1, …\]) \[*{color}{color:#ff0000}{*}phased{*}{color} {color:#515151}*\[(ph{*}{color}{color:#515151}{*}{~}1{~}{*}{color}{color:#515151}*<mode{*}{color}{color:#515151}{*}{~}1{~}{*}{color}{color:#515151}*>, ...)\] \] Stmt{*}{color}

{color:#515151}•{color} {color:#515151}Like{color} {color:#ff0000}forall{color}{color:#515151}, create multiple instances of Stmt as child{color} {color:#ff0000}async{color} {color:#515151}tasks, one per{color} {color:#ff0000}foreach{color} {color:#515151}iteration in rectangular region \[lo1:hi1, …\]{color}
* {color:#515151}&nbsp; No implicit finish in{color} {color:#515151}foreach{color}
* {color:#515151}&nbsp; As with{color} {color:#ff0000}async{color}{color:#515151}, a{color} {color:#ff0000}foreach{color} {color:#515151}iteration may optionally be{color} {color:#ff0000}phased{color} {color:#515151}on a specified subset, (ph{color}{color:#515151}{~}1{~}{color}{color:#515151}<mode{color}{color:#515151}{~}1{~}{color}{color:#515151}>, ...), of its parent’s phasers or on the entire set{color}

{color:#ff1314}{*}isolated{*}{color} {color:#ff1314}{*}Stmt{*}{color}

{color:#515151}•{color} {color:#515151}Execute Stmt in isolation (mutual exclusion) relative to all other instances of isolated statements{color}

{color:#515151}•{color} {color:#515151}Stmt must not contain any parallel constructs{color}

{color:#515151}•{color} {color:#515151}Weak atomicity: no guarantee on interactions with non-isolated statements&nbsp;{color}

{color:#ff1314}{*}new phaser{*}{color}{color:#ff1314}*(mode{*}{color}{color:#ff1314}{*}{~}1{~}{*}{color}{color:#ff1314}*);*{color}

{color:#515151}•{color} {color:#515151}Allocate a{color} {color:#ff0000}phaser{color} {color:#515151}with the specified mode, which can be one of SIG, WAIT, SIG_WAIT, SINGLE{color}

{color:#515151}•{color} {color:#515151}Scope of{color} {color:#ff0000}phaser{color} {color:#515151}is limited to immediately enclosing finish{color}

{color:#ff1314}{*}next{*}{color}{color:#ff1314}*;*{color}

{color:#515151}•{color} {color:#515151}Advance each{color} {color:#515151}phaser{color} {color:#515151}that this task is registered on to its{color} {color:#ff0000}next{color} {color:#515151}phase, in accordance with this task’s registration mode{color}

{color:#515151}•{color} {color:#515151}Wait on each{color} {color:#515151}phaser{color} {color:#515151}that task is registered on with a wait capability (WAIT, SIG_WAIT, SINGLE){color}

{color:#ff1314}{*}next single{*}{color} {color:#ff1314}{*}Stmt{*}{color}

{color:#515151}•{color} {color:#515151}Execute a{color} {color:#ff0000}single{color} {color:#515151}instance of Stmt during the phase transition performed by next{color}

{color:#515151}•{color} {color:#515151}All tasks executing the{color} {color:#515151}next single{color} {color:#515151}statement must be registered with all its phasers in SINGLE mode{color}

{color:#ff1314}{*}signal{*}{color}{color:#ff1314}*;&nbsp;*{color}

{color:#515151}•{color} {color:#515151}signal each{color} {color:#515151}phaser{color} {color:#515151}that task is registered on with a signal capability (SIG, SIG_WAIT, SIGNAL){color}

{color:#515151}•{color} {color:#515151}signal{color} {color:#515151}is a non-blocking operation \--\- computation between signal and next serves as a “split phase barrier”{color}

{color:#ff1314}{*}abstract performance metrics{*}{color}

{color:#515151}•{color} {color:#515151}Programmer inserts calls of the form, perf.addLocalOps(N), in sequential code{color}

{color:#515151}•{color} {color:#515151}HJ implementation computes total work and critical path length in units of programmer’s local ops{color}