|
Boost Users : |
Subject: Re: [Boost-users] [Boost.MPI] question about serializing custom object
From: Matthias Troyer (troyer_at_[hidden])
Date: 2010-08-26 14:21:04
On 26 Aug 2010, at 20:56, Robert Ramey wrote:
> Cristobal Navarro wrote:
>> the other question is
>> on the tutorials i only found examples of serializing objects to
>> archive and saving to file, but i didnt find any example where they
>> serialize it to a binary form and send them through mpi, is there any
>> example of this type on the documentation?
>
> no
>
Actually the answer is yes. This is exactly what is done by Boost.MPI!
When you send an object using Boost.MPI, it is serialized into an MPI buffer by the packed_oarchive. Then that buffer's content is sent via MPI and it is unpacked at the other end. All this is transparently done by the send and recv calls of Boost.MPI.
> Feel free to contribute one.
No need since it already exists.
>
> If I had nothing else to do, I would
>
> a) make a stream_buf which uses MPI
> b) use binary_iarchive and binary_oarchive with this new stream_buf
we avoid streambufs by directly packing using detail::mpi_[io]primitive. This allows us to make use of conversion facilities in MPI, rather than packing as native binary.
> c) open one program with binary_oarchive and the other with binary_iarchive
we call them packed_oarchive and packed_iarchive
> d) do ar << on one end and ar >> at the other
That is what the send and recv functions do, but in addition we have the MPI_Send and MPI_Recv calls that transfer the buffer.
Matthias
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net