5

I trying to send variables of type mpfr_t using MPI_Scatter. For example:

mpfr_t *v1 = new mpfr_t[10];  
mpfr_t *v2 = new mpfr_t[10];   
MPI_Scatter(v1, 5, MPI_BYTE, v2, 5, MPI_BYTE, 0, MPI_COMM_WORLD ); 
for (int i = 0; i < 5; i++) 
    mpfr_printf("value rank %d -  %RNf \n", ProcRank, v2[i]);

It prints:

value rank 0 - nan
value rank 0 - nan
value rank 0 - nan
.....
value rank 1 - nan
value rank 0 - nan

But it's work of MPI_Bcast. What I do wrong. Code C/C++, MPI lib is OpenMPI-1.6.

4

1 回答 1

2

您将 sendcount 指定为 5,将数据类型指定为 MPI_BYTE。这似乎很奇怪。如果要使用 MPI_BYTE 并且要发送 5 个 mpfr_t 值,则指定发送计数为 5*sizeof(mpfr_t)。另一种选择是创建您自己的 MPI 派生数据类型(如果您想摆脱 sizeof())。

于 2012-06-19T00:06:43.137 回答