[mpi] Sending derived classes via MPI and serialize
I'm trying to send polymorphic objects using boost::mpi, but I'm getting extensive "undefined reference" errors for the simple test case below. If I #include <boost/archive/text_oarchive.hpp> instead of the mpi/communicator, everything compiles fine. Any help greatly appreciated, Simon #include <boost/mpi/communicator.hpp> #include <boost/serialization/export.hpp> struct Base { virtual ~Base() {} virtual int id() const { return 1; } template<class Archive> void serialize(Archive &ar, const unsigned int) { ar & data; } int data; }; struct Derived : public Base { virtual int id() const { return 2; } }; BOOST_CLASS_EXPORT(Base) BOOST_CLASS_EXPORT(Derived) int main(int argc, char *argv[]) { Base *b = new Base; Base *d = new Derived; delete b; delete d; return 0; }
On 4 Mar 2008, at 10:39, Number Cruncher wrote:
I'm trying to send polymorphic objects using boost::mpi, but I'm getting extensive "undefined reference" errors for the simple test case below.
Do you use the latest version from svn or an older version? Matthias
I'm using a snapshot of http://svn.boost.org/trac/boost/browser/branches/release from 2008-02-20, so almost the latest... I've done a little more digging and I think it might be related to the BOOST_SERIALIZATION_REGISTER_ARCHIVE stuff. Specifically, the errors are of the form include/boost/archive/detail/oserializer.hpp:162: undefined reference to `boost::archive::detail::archive_pointer_oserializer< boost::mpi::detail::ignore_skeleton_oarchive <boost::mpi::detail::mpi_datatype_oarchive>
::~archive_pointer_oserializer()'
and I noticed that communicator.hpp only includes forward declarations of skeleton archives via #include <boost/mpi/skeleton_and_content_fwd.hpp> Perhaps these forward declarations are not sufficient to instantiate the archive pointer serialization code?? Thanks for responding, Simon Matthias Troyer wrote:
On 4 Mar 2008, at 10:39, Number Cruncher wrote:
I'm trying to send polymorphic objects using boost::mpi, but I'm getting extensive "undefined reference" errors for the simple test case below.
Do you use the latest version from svn or an older version?
Matthias
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Can you try to add BOOST_SERIALIZATION_REGISTER_ARCHIVE (boost::mpi::detail::ignore_skeleton_oarchive) in line 69 of boost/mpi/detail/ignore_skeleton_oarchive.hpp Matthias On 6 Mar 2008, at 10:40, Number Cruncher wrote:
I'm using a snapshot of http://svn.boost.org/trac/boost/browser/branches/release
from 2008-02-20, so almost the latest...
I've done a little more digging and I think it might be related to the BOOST_SERIALIZATION_REGISTER_ARCHIVE stuff. Specifically, the errors are of the form
include/boost/archive/detail/oserializer.hpp:162: undefined reference to `boost::archive::detail::archive_pointer_oserializer< boost::mpi::detail::ignore_skeleton_oarchive <boost::mpi::detail::mpi_datatype_oarchive>
::~archive_pointer_oserializer()'
and I noticed that communicator.hpp only includes forward declarations of skeleton archives via
#include <boost/mpi/skeleton_and_content_fwd.hpp>
Perhaps these forward declarations are not sufficient to instantiate the archive pointer serialization code??
Thanks for responding, Simon
Matthias Troyer wrote:
On 4 Mar 2008, at 10:39, Number Cruncher wrote:
I'm trying to send polymorphic objects using boost::mpi, but I'm getting extensive "undefined reference" errors for the simple test case below.
Do you use the latest version from svn or an older version?
Matthias
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Matthias Troyer wrote:
Can you try to add
BOOST_SERIALIZATION_REGISTER_ARCHIVE (boost::mpi::detail::ignore_skeleton_oarchive)
in line 69 of boost/mpi/detail/ignore_skeleton_oarchive.hpp
This doesn't compile because ignore_skeleton_oarchive is a template class not a specific type. There is a similar macro in mpi_datatype_oarchive.hpp with an mpi_datatype_oarchive specialization: BOOST_SERIALIZATION_REGISTER_ARCHIVE( boost::mpi::detail::ignore_skeleton_oarchive <boost::mpi::detail::mpi_datatype_oarchive>) but with all the forward declaration includes, I can't actually work out which classes have been fully defined when this indirectly invoked via the #include "communicator.hpp". I'm guessing the instantiation is not actually built because at the point of BOOST_SERIALIZATION_REGISTER_ARCHIVE, ignore_skeleton_oarchive<mpi_datatype_oarchive> is somehow incomplete??? Thanks, Simon
Sorry, that was nonsense ... forget it please can you please check whether line 45 of mpi_datatype_oarchive.hpp contains BOOST_SERIALIZATION_REGISTER_ARCHIVE (boost ::mpi ::detail ::ignore_skeleton_oarchive<boost::mpi::detail::mpi_datatype_oarchive>) and can you then please check whether serializing and deserializing work if you use a text archive instead of MPI? Matthias On 6 Mar 2008, at 21:47, Matthias Troyer wrote:
Can you try to add
BOOST_SERIALIZATION_REGISTER_ARCHIVE (boost::mpi::detail::ignore_skeleton_oarchive)
in line 69 of boost/mpi/detail/ignore_skeleton_oarchive.hpp
Matthias
On 6 Mar 2008, at 10:40, Number Cruncher wrote:
I'm using a snapshot of http://svn.boost.org/trac/boost/browser/branches/release
from 2008-02-20, so almost the latest...
I've done a little more digging and I think it might be related to the BOOST_SERIALIZATION_REGISTER_ARCHIVE stuff. Specifically, the errors are of the form
include/boost/archive/detail/oserializer.hpp:162: undefined reference to `boost::archive::detail::archive_pointer_oserializer< boost::mpi::detail::ignore_skeleton_oarchive <boost::mpi::detail::mpi_datatype_oarchive>
::~archive_pointer_oserializer()'
and I noticed that communicator.hpp only includes forward declarations of skeleton archives via
#include <boost/mpi/skeleton_and_content_fwd.hpp>
Perhaps these forward declarations are not sufficient to instantiate the archive pointer serialization code??
Thanks for responding, Simon
Matthias Troyer wrote:
On 4 Mar 2008, at 10:39, Number Cruncher wrote:
I'm trying to send polymorphic objects using boost::mpi, but I'm getting extensive "undefined reference" errors for the simple test case below.
Do you use the latest version from svn or an older version?
Matthias
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Matthias Troyer
-
Number Cruncher