I've gotten nothing but positive feedback on this proposed change, so now I'm 
looking for a review for the patch.  It's a one-line parser change along with 
the proposed mods to the spec (which included some rewording while here).  I 
also updated the spectral-norm test that motivated this for me.

I'd be happy to convert all 'serial true' tests to just use 'serial' if that's 
what people would like (seems like a good way to put our best foot forward, so 
I'd vote "yes").

Thanks,
-Brad


________________________________
From: Brad Chamberlain
Sent: Saturday, January 25, 2014 4:02 PM
To: Chapel Sourceforge Developers List
Subject: Request for feedback: serial do == serial (true) do

Hi Chapel Developers --

We've recently started exploring various ways for the compiler, runtime, and/or 
user to squash task-based nested parallelism in Chapel.  For example, imagine 
the following:

config var n = 1000000;

var A: [1..n][1..3] real;
var res: [1..n] real;

forall i in 1..n do
  res[i] = + reduce [j in 1..3] A[i][j];

Here, a user probably doesn't want to apply task parallelism to the 3-element 
reductions in the inner loop; yet writing this without a reduction is annoying. 
 The serial statement is one way to address this:

forall i in 1..n do
  serial (true) do
    res[i] = + reduce [j in 1..3] A[i][j];

But currently the serial statement always requires a boolean expression, which 
seems somewhat silly in cases like this.  I'd like to propose that we permit 
the boolean expression to be dropped, in which case the intention is the same 
as expressing "true".  Thus:

forall i in 1..n do
  serial do
    res[i] = + reduce [j in 1..3] A[i][j];


Happily, the implementation is trivial:

Index: compiler/parser/chapel.ypp
===================================================================
--- compiler/parser/chapel.ypp (revision 22581)
+++ compiler/parser/chapel.ypp (working copy)
@@ -231,6 +231,7 @@
 | TLOCAL stmt                { $$ = buildLocalStmt($2); }
 | TON expr do_stmt           { $$ = buildOnStmt($2, $3); }
 | TSERIAL expr do_stmt       { $$ = buildSerialStmt($2, $3); }
+| TSERIAL do_stmt            { $$ = buildSerialStmt(new SymExpr(gTrue), $2); }
 | TSYNC stmt                 { $$ = buildSyncStmt($2); }
 | TUSE expr_ls TSEMI         { $$ = buildUseStmt($2); }
 | TYIELD expr TSEMI          { $$ = buildPrimitiveStmt(PRIM_YIELD, $2); }

Any objections to making this addition/simplification to the language and 
committing this patch?

Ultimately, I think we may also want to look at supporting an expression-level 
serial clause, to support things like:

res[i] = serial + reduce [j in 1..3] A[i,j];

but that wasn't as much of a five-minute weekend fix (TM).

Thanks,
-Brad

Attachment: serialOptionalExpression.patch
Description: serialOptionalExpression.patch

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to