MPI and GMP

Will Galway galway at math.uiuc.edu
Sat Dec 12 19:12:39 CET 2009


Yes, I'd guess that integer import/export WOULD be better.  I had 
thought I'd recalled those functions (but not their names), but I didn't 
turn them up with my first brief skim of the manual.  Thanks for 
pointing them out.

-- Regards, Will

F. G. Dorais wrote:
> 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 
>
>


More information about the gmp-discuss mailing list