gpt4 book ai didi

c++ - 为什么 MPI_Scatterv 的 recvcount 是一个固定的 int 而 sendcount 是一个数组?

转载 作者:太空宇宙 更新时间:2023-11-04 08:08:03 27 4
gpt4 key购买 nike

这是 MPI_Scatterv() 的概要

    int MPI_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype,
int root, MPI_Comm comm)

我似乎无法理解这是如何工作的。如果 MPI_Scatterv() 正在发送存储在 *sendcounts 中的不同 block 大小的元素,那么为什么 recvcount 是固定整数而不是 block 数组还有尺寸吗?

而且由于它是一个固定整数,因此该值应该是多少。它应该等于 sendcount 数组的最大值吗?例如,如果我有

   int sendcount[4] = {1,5,10,8};

recvcount 应该等于 10 吗?

最佳答案

sendcounts 指定要发送的实际 block 大小。 recvcount 指定本地接收缓冲区的大小,例如recvcount=sendcounts[排名]

详细来说它有点复杂:接收缓冲区的大小至少需要足够大以存储给定等级的 block 。如果涉及不同类型,则类型范围也很重要。

关于c++ - 为什么 MPI_Scatterv 的 recvcount 是一个固定的 int 而 sendcount 是一个数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41303231/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com