2

我在 C++ 中有 10 台计算机和 2 个变量的集群 - 结果:size int 100; - result_final : (仅在主机上) size int 1000; 如何收集“结果”的碎片并创建“result_final”,因为它们的大小不同。谢谢!

int *rcounts = (int *) malloc(commSize * sizeof(int));
int *displs = (int *) malloc(commSize * sizeof(int));
for (i = 0; i < commSize; ++i) {
    displs[i] = commRank * result_size * size;
    rcounts[i] = result_size * size;
}
MPI_Gatherv(h_result, result_size * size, MPI_INT, h_result_final, rcounts,
        displs, MPI_INT, 0, MPI_COMM_WORLD);
4

1 回答 1

4

如果每件的尺寸不同,您将MPI_Gatherv()使用MPI_Gather(). MPI_Scatter()对于vs也是如此MPI_Scatterv()

于 2012-05-08T08:37:54.787 回答