2

私は10台のコンピューターのクラスターとc++の2つの変数を持っています-結果:size int 100; --result_final :(ホストのみ)size int 1000; サイズが異なるため、「result」の断片を収集して「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 に答える