MPI and GMP

F. G. Dorais dorais at umich.edu
Sat Dec 12 17:40:33 CET 2009


Scott Bucholtz wrote:
> It requires a little more work then just sending the Lib-GMP variables 
> directly over MPI.  You have to:
>     1) determine the length of the Lib-GMP variable in the desired base 
> (e.g., mpz_sizeinbase); plus 1
>     2) send #1 as an MPI_UNSIGNED_LONG
>     3) convert the Lib-GMP variable in its base to a string (e.g., 
> mpz_get_str)
>     4) allocate a new string of that size on the other side (realloc)
>     5) send the string from #3 as an MPI_CHAR
>     6) convert the string at the other end to a Lib-GMP variable (e.g., 
> mpz_set_str)
>     7) clean up (i.e., free string memory)

I never tried, but wouldn't mpz_import and mpz_export be better suited 
for this?

http://gmplib.org/manual/Integer-Import-and-Export.html#Integer-Import-and-Export

-- 
François G. Dorais
Department of Mathematics
University of Michigan


More information about the gmp-discuss mailing list