Is `[<var> in <distributed variable>]` equivalent to `forall`?

狂风中的少年 提交于 2019-12-01 19:03:53

问题


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 type real."



来源:https://stackoverflow.com/questions/43728540/is-var-in-distributed-variable-equivalent-to-forall

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!