如何有效地分散 Chapel 中的分布式数组元素?

How do I efficiently scatter distributed array elements in Chapel?

考虑以下分散操作:

var A : [DomA] EltType;
var Indices : [DomA] IndexType;
var B : [DomB] EltType;

[(iSrc, iDst) in zip(DomA, Indices)] B[iDst] = A[iSrc];

域分布在哪里。做这个的最好方式是什么?特别是,是否有一种简单的方法来聚合消息以避免发送许多小消息(假设 sizeOf(EltType) 很小)?

Chapel 团队正在积极致力于聚合,它在 Arkouda, but there is currently no built-in support for aggregation. See https://github.com/chapel-lang/chapel/issues/16963 中广泛使用,以获取有关当前工作的更多信息。

如果您想尝试当前的聚合器,您可以从 https://github.com/chapel-lang/chapel/tree/993f9bd/test/studies/bale/aggregation.

复制 AggregationPrimitives.chpl 和 CopyAggregation.chpl

你的主循环看起来像这样:

forall (iSrc, iDst) in zip(DomA, Indices) with (var agg = new DstAggregator(EltType)) {
  agg.copy(B[iDst], A[iSrc]);
}

或者更干净一点:

forall (iDst, a) in zip(Indices, A) with (var agg = new DstAggregator(EltType)) {
  agg.copy(B[iDst], a);
}

这些聚合器应该在非聚合循环上提供显着的性能加速:Cray Aries 网络上 2-3 倍,InfiniBand 网络上约 1000 倍,商品以太网网络上约 5000 倍或更多。

从长远来看,聚合器将成为标准库的一部分,在许多情况下,包括您的示例,编译器应该能够判断聚合是 safe/legal 并自动使用它。