[MPICH] Passing class in C++ MPI

John Robinson jr at vertica.com
Thu Apr 20 19:36:32 CDT 2006

Hi Pankaj,

In my project we have had much success using the boost::serialization 
extensions to ths C++ stdlib.  See www.boost.org.

The library comeas already prepared to serialize any containers in 
std::, and has straightforward ways to write serializers for your own 
classes.  The serialized output goes into a stream, and can be one of 
printable text, binary, or xml.  It understands about tracing pointers 
(and sending along the pointed-to object), and resolves multiple 
pointers to the same object.  All gets reinstantiated on the receiving 
side into a class, and so all the methods on that class are of course 

We use this approach both to pass classes over MPI connections and to 
save and restore objects from disk.

Pankaj Gupta wrote:
> Hi All,
>     I am trying to parallelize a distributed simulation written in C++ 
> having several classes. After reading several books, online manuals, and 
> this mailing list, I still could not figure out a way to pass the class 
> data from node 0 to all the processors or vice-versa. I came across 
> other possible approaches such as MPI_Pack/Unpack or creating a string 
> of the class data.
> My question is: Is it possible to pass a classes in C++ MPI (MPICH)? Any 
> example, suggestions, or alternative approach will really help me.
> I am using MPICH 1.2.6 under Debian-run beowulf cluster.
> Any help is sincerely appreciated.
> Regards,
> Pankaj

More information about the mpich-discuss mailing list