Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send GMP or MPFR types with MPI

Tags:

c++

c

mpi

gmp

mpfr

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.

like image 304
Sidny Sho Avatar asked Nov 03 '22 22:11

Sidny Sho


1 Answers

You specified the sendcount as 5 and the datatype as MPI_BYTE. This seems odd. If you want to use MPI_BYTE and you want to send 5 mpfr_t values then specify a sendcount of 5*sizeof(mpfr_t). Another option would be to create your own MPI derived datatype (if you want to get rid of the sizeof()).

like image 131
timos Avatar answered Nov 09 '22 12:11

timos