MPI and GMP
Will Galway
galway at math.uiuc.edu
Sat Dec 12 17:27:18 CET 2009
Again, not being familiar with MPI (nor with MPI_BYTE) I can't comment
on that aspect. However, without knowing the details I'm sure that
gmp_get_str and gmp_set_str routines do something very-much what I was
suggesting, but using slower divide and mod functions since it cannot
assume that the base is a power of 2.
-- Regards, Will
Scott Bucholtz wrote:
> This could definitely save some overhead. There is an MPI_BYTE type
> that I assume these Lib-GMP variables could be packed into for
> transmission (though I have never tried that myself). If someone were
> brave enough to write a wrapper for MPI to use Lib-GMP variables; it
> would likely involve this approach behind the scenes.
>
> I would think, however, that there would come a time when the numbers
> became large enough, though that the multiple MPI_BYTE transmissions
> would exceed the overhead in converting to a string and back.
>
>
> Scott Bucholtz
> http://www.linuxmanland.com/
>
> On Sat, 12 Dec 2009, Will Galway wrote:
>
>> 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