MPI and GMP
Will Galway
galway at math.uiuc.edu
Sat Dec 12 16:33:59 CET 2009
One comment on Scott's suggestion: I'm not familiar with MPI so I could
be missing something here, but instead of converting back-and-forth
between strings using, e.g., mpz_get_str and mpz_set_str, you could
instead convert the mpz_t variable into a sequence of bytes (or unsigned
longs) using GMP's shift-right and mask operations (e.g.,
mpz_fdiv_q_2exp and mpz_fdiv_r_2exp) -- and on the other machine convert
the data sequence back into an mpz_t using shift-left and add functions.
This way you'd save quite a bit of communication overhead and perhaps,
depending on the size of your numbers, quite a bit of memory.
-- Regards, Will
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)
>
>
> Hope this helps.
>
>
> Scott Bucholtz
> http://www.linuxmanland.com/
>
>
> On Fri, 11 Dec 2009, selcukkeskin at live.com wrote:
>
>> i'm sorry. i didn't write library. i'm using gmp primitives embedded
>> in it
>>
>> best wishes
>>
>> --------------------------------------------------
>> From: "Allan Menezes" <amenezes007 at sympatico.ca>
>> Sent: Friday, December 11, 2009 10:53 PM
>> To: <selcukkeskin at live.com>
>> Cc: <gmp-discuss at gmplib.org>
>> Subject: Re: MPI and GMP
>>
>>> selcukkeskin at live.com wrote:
>>>> Hi,
>>>>
>>>> I'm working on MPI with GMP. It works perfectly but i can't send
>>>> gmp variables like mpz_t, mpf_t
>>>>
>>>> -------------------------------------------------------
>>>> Sel�uk Keskin
>>>>
>>>> Ege University
>>>> The feasibility of Mathematics in Computer
>>>> _______________________________________________
>>>> gmp-discuss mailing list
>>>> gmp-discuss at gmplib.org
>>>> https://gmplib.org/mailman/listinfo/gmp-discuss
>>>>
>>>>
>>>>
>>> Hi Selcuk,
>>> Are you emedding MPI in GMP functions at a higher level to create a
>>> new gmp library with mpi?or just writing an mpi program in C/C++
>>> with gmp primitives embedded in it and compiled like this
>>> mpicc -o foo -m64 -lgmp -lm foo.c? If you are writing a library are
>>> you going to LGPL it and submit it to the gmplib website?
>>> Thank you very much for your response,
>>> Best wishes,
>>> Allan MeneZes
>>>
>> _______________________________________________
>> gmp-discuss mailing list
>> gmp-discuss at gmplib.org
>> https://gmplib.org/mailman/listinfo/gmp-discuss
>>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>
More information about the gmp-discuss
mailing list