问题
I noticed something in a snippet of code I was given:
var D: domain(2) dmapped Block(boundingBox=Space) = Space;
var A: [D] int;
[a in A] a = a.locale.id;
Is [a in A] equivalent to forall a in A a = a.locale.id?
回答1:
Yes, exactly. In Chapel, [a in A] expr is equivalent to forall a in A do expr.
With respect to the title of this question, note that this is independent of whether or not A is distributed. For example, you could also write [i in 1..n] rather than forall i in 1..n do.
Array types in Chapel, like [D] real can similarly be read as
"for all indices in
D, allocate an element of typereal."
来源:https://stackoverflow.com/questions/43728540/is-var-in-distributed-variable-equivalent-to-forall