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

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to