Hello,
I'm confused about the result of inquiring the variable's locale info
inside a parallel block:
code:
proc main() {
var gVar = 100;
coforall loc in Locales {
on loc {
writeln("Pos2: from loc.id"+loc.id+", gVar="+gVar+",
gVar.loc="+gVar.locale.id);
}
}
}
output:
Pos2: from loc.id0, gVar=100, gVar.loc=0
Pos2: from loc.id2, gVar=100, gVar.loc=2
Pos2: from loc.id1, gVar=100, gVar.loc=1
Same results by using forall/begin/cobegin.
Variable gVar is defined in locale 0, if I use serial "for" instead of
"coforall", then the gVar.locale.id will all print "0", which makes sense.
However, why locale.id of the same variable gVar is changed to be where
it's accessed (loc.id) in the parallel cases (while using
coforall/forall/begin/cobegin) ???
Besides, since Chapel has this global view of variables no matter where
they are defined, it seems like a little dangerous to use because any
locale can easily modify the value of a variable that's defined in another
locale if someone happens to misuse variable names...Is there a
locale-specific (like private to the particular locale) variable mechanism
that can prevent such mistake in Chapel ?
Thanks !
Thanks
--
Best regards
Hui Zhang
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers