如何在 Chapel 中使用原子变量设置数组大小?

How do I set an array size using an atomic variable in Chapel?

在追求A3C I need to set multiple global and local parameters. The global parameters need to have shared size. I think this means atomic变量,但对我来说还是新的。

var n: atomic int,
    x: [1..n] real;  # a vector of global size

proc localDude(){
  n +=1;  # increase the size of n
}

我知道数组会随着 domain 变大和变小,但我很难将语义整合在一起。谢谢!

所以有几件事。

  1. 域按值而不是引用来限定它们的界限。因此,修改域用于构造其边界的变量 不会 修改域 (example)。
  2. 数组 do 通过引用获取它们的域,因此分配给使用的域变量 do 使数组发生变化(example).
  3. 域还不是受支持的原子类型,因此拥有全局原子域将不起作用。但是,您可以在底部附近使用 sync variable as a lock so that modifications are serialized. There is an example of this on the learn Chapel in Y minutes tutorial(搜索互斥量)