chapel-lang/chapel — pull request #1042 by vasslitvinov (2014-12-19 09:07:04+00:00)
Title: Added other task intents.

Specifically: blank,const,in,const in,const ref.
Also, changed how 'ref' intent is implemented.

HIGHLIGHTS

* Task intents are now implemented via passing the outer variables
as arguments to task functions during createTaskFunctions().
Before this change 'ref' intents were implemented by hiding
the corresponding variables from task intents altogether.
They remained references to Symbols in the outer scopes
and converted to arguments during flattenNesteFunctions().

* The contents of byrefVars changed to allow the parser to
convey the intents to createTaskFunctions() and implementForallIntents.

* For now, only 'ref' forall intents are allowed.
Other forall intents will be added later.

COMPILER DETAILS

* I am using "tiMarkXXX" ArgSymbols to pass the contents of with-clauses
from the parser to createTaskFunctions and to resolution,
where that information is consumed.

The parser builds byrefVars as a CallExpr, as before. The change
in this commit is that the CallExpr has twice as many actuals.
If the with-clause is (INTENT1 VAR1, INTENT2 VAR2), then the actuals are:
tiMarkForIntent(INTENT1), VAR1, tiMarkForIntent(INTENT2), VAR2

* I placed tiMarkForIntent() in symbol.h.
This is to make it is accessible in chapel.ypp.

* I added code to avoid counting variables in with-clause as "outer"
for forall intents. That way the variables referenced in a with-clause
and not in the loop body are not considered. This is a nicety,
should not affect the semantics, and should be rarely noticeable.

TEST CHANGES

* I replaced sleep() with sync variables in the following test:

test/parallel/begin/deitz/test_global_for_begin.chpl

to comply with our memory consistency model, which our compiler
optimizations started to rely on more aggressively. E.g. in this code:

var j = 0;
cobegin with (ref j) {
{ sleep(1); writeln(j); }
j = 3;
}

the compiler can legally optimize writeln(j) to writeln(0).
See the spec for details.

* I deleted the following test:

test/multilocale/vass/coforall-ref-private.chpl

This test verified that updating a pragma-"private" global variable
within a coforall+on worked as expected. I.e. that locale-private
copies of that variable get updated. This was needed to initialize
rootLocale.

This, correctly, no longer works that way. Thankfully, we do initialize
rootLocale in that manner any more, making this test irrelevant.