Efficiently importing/export GMP floats

Jack Poulson jack.poulson at gmail.com
Mon Jan 17 04:00:49 CET 2011


I have been scouring the manual and related archived conversations, but I
can't seem to find a sufficient means of importing/exporting a large
collection of mpf_t's as a binary format without a loss in precision (e.g.,
converting to double-precision).

The reason I ask is that I have written a templated parallel linear algebra
library that I would like to stick GMP under the hood for in the cases where
the user wanted higher than double-precision arithmetic. The main constraint
is in importing/exporting large arrays of mpf_t's into a contiguous buffer
so that I could use the Message Passing Interface (MPI) to communicate the
data between a large number of nodes. I should also be able to handle
distributed summations (e.g., MPI_Reduce with the MPI_SUM operation) by
defining a MPI reduce operation and then calling mpf_add from within it.

Does anyone have a suggestion as to how to efficiently pack/unpack a large
number of mpf_t's *without losing precision*?

Best Regards,
Jack Poulson


More information about the gmp-discuss mailing list