Boost logo

Boost Users :

Subject: Re: [Boost-users] [mpi] many undefined references to serialize<boost::mpi::detail::mpi_datatype_oarchive>
From: Brian Budge (brian.budge_at_[hidden])
Date: 2012-09-11 12:22:00


On Tue, Sep 11, 2012 at 8:50 AM, Riccardo Murri
<riccardo.murri_at_[hidden]> wrote:
> Hello,
>
> On Tue, Sep 11, 2012 at 12:51 AM, Brian Budge <brian.budge_at_[hidden]> wrote:
>> I've got a class hierarchy that can already be serialized into text or
>> binary archives. I'm explicitly instantiating the template functions
>> for serialize and/or load/save.
>>
>> I'm trying to add the capability to have boost mpi perform the
>> serialization through send/recv/broadcast.
>
> If your class has serialization support, that's enough. You should
> not provide specialization for mpi::detail classes.
>
> (Of course, YMMV - since you didn't provide any code, my comment above
> could be completely off ...)
>
> Cheers,
> Riccardo

Thanks for the replies. Here are the macros I made to perform the
explicit instantiation:

#define INSTANTIATE_FUNCTION_FOR_INPUT_ARCHIVES(FUNC) \
template void FUNC(boost::archive::binary_iarchive &archive, \
                   const unsigned int version); \
template void FUNC(boost::mpi::packed_iarchive &archive, \
                   const unsigned int version); \
template void FUNC(boost::archive::text_iarchive &archive, \
                   const unsigned int version)

#define INSTANTIATE_FUNCTION_FOR_OUTPUT_ARCHIVES(FUNC) \
template void FUNC(boost::archive::binary_oarchive &archive, \
                   const unsigned int version); \
template void FUNC(boost::mpi::packed_oarchive &archive, \
                   const unsigned int version); \
template void FUNC(boost::mpi::detail::mpi_datatype_oarchive &archive, \
                   const unsigned int version); \
template void FUNC(boost::archive::text_oarchive &archive, \
                   const unsigned int version)

#define MAKE_SERIALIZE_FUNCTIONS(CLASS) \
INSTANTIATE_FUNCTION_FOR_INPUT_ARCHIVES(CLASS::serialize); \
INSTANTIATE_FUNCTION_FOR_OUTPUT_ARCHIVES(CLASS::serialize)

Then, along with implementing the templatized versions of serialize
for each class, I will call the MAKE_SERIALIZE_FUNCTIONS(myclass) in
each myclass.cpp.

So to Robert's question, I don't think this is something that could be
baked into the boost_mpi.so library, since they rely on my own
classes. I was just surprised to find that I needed to explicitly
instantiate with something from detail rather than just the packed
archives.

Thanks,
  Brian

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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