2
0
mirror of https://github.com/boostorg/mpi.git synced 2026-02-25 04:22:17 +00:00

Changes required to make Boost.MPI work with Boost.Serialization after breaking changes for 1.44

[SVN r64423]
This commit is contained in:
Matthias Troyer
2010-07-29 03:27:09 +00:00
parent 60d5bdcfdd
commit 50f71c9b00
16 changed files with 72 additions and 52 deletions

View File

@@ -26,6 +26,8 @@
#include <boost/mpl/and.hpp>
#include <boost/mpi/detail/mpi_datatype_cache.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/archive/basic_archive.hpp>
#include <boost/serialization/item_version_type.hpp>
#include <utility> // for std::pair
namespace boost { namespace mpi {
@@ -298,6 +300,7 @@ BOOST_MPI_DATATYPE(unsigned __int64, MPI_UNSIGNED_LONG_LONG, builtin);
BOOST_MPI_DATATYPE(signed char, MPI_SIGNED_CHAR, builtin);
#endif
#endif // Doxygen
namespace detail {
@@ -325,6 +328,23 @@ struct is_mpi_datatype<bool>
: boost::mpl::bool_<true>
{};
#ifndef BOOST_MPI_DOXYGEN
// direct support for special primitive data types of the serialization library
BOOST_MPI_DATATYPE(boost::archive::library_version_type, get_mpi_datatype(uint_least16_t()), integer);
BOOST_MPI_DATATYPE(boost::archive::version_type, get_mpi_datatype(uint_least8_t()), integer);
BOOST_MPI_DATATYPE(boost::archive::class_id_type, get_mpi_datatype(int_least16_t()), integer);
BOOST_MPI_DATATYPE(boost::archive::class_id_reference_type, get_mpi_datatype(int_least16_t()), integer);
BOOST_MPI_DATATYPE(boost::archive::class_id_optional_type, get_mpi_datatype(int_least16_t()), integer);
BOOST_MPI_DATATYPE(boost::archive::object_id_type, get_mpi_datatype(uint_least32_t()), integer);
BOOST_MPI_DATATYPE(boost::archive::object_reference_type, get_mpi_datatype(uint_least32_t()), integer);
BOOST_MPI_DATATYPE(boost::archive::tracking_type, get_mpi_datatype(bool()), builtin);
BOOST_MPI_DATATYPE(boost::serialization::collection_size_type, get_mpi_datatype(std::size_t()), integer);
BOOST_MPI_DATATYPE(boost::serialization::item_version_type, get_mpi_datatype(uint_least8_t()), integer);
#endif // Doxygen
} } // end namespace boost::mpi
// define a macro to make explicit designation of this more transparent

View File

@@ -25,7 +25,9 @@ template<typename T> struct is_mpi_logical_datatype;
template<typename T> struct is_mpi_complex_datatype;
template<typename T> struct is_mpi_byte_datatype;
template<typename T> struct is_mpi_datatype;
template<typename T> MPI_Datatype get_mpi_datatype(const T& x = T());
template<typename T> MPI_Datatype get_mpi_datatype(const T& x);
template<typename T> MPI_Datatype get_mpi_datatype()
{ return get_mpi_datatype(T());}
/// a dummy data type giving MPI_PACKED as its MPI_Datatype
struct packed {};

View File

@@ -88,7 +88,8 @@ public:
load_impl(&t, sizeof(T));
}
void load( std::string & s)
template<class CharType>
void load(std::basic_string<CharType> & s)
{
unsigned int l;
load(l);

View File

@@ -79,7 +79,8 @@ public:
save_impl(&t, sizeof(T));
}
void save(const std::string &s)
template<class CharType>
void save(const std::basic_string<CharType> &s)
{
unsigned int l = static_cast<unsigned int>(s.size());
save(l);

View File

@@ -42,13 +42,6 @@ public:
typedef is_mpi_datatype<mpl::_1> use_array_optimization;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
friend class archive::load_access;
protected:
#else
public:
#endif
/// don't do anything when loading primitive types
template<class T>
void load(T & t)

View File

@@ -17,6 +17,7 @@
#include <boost/archive/detail/oserializer.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/item_version_type.hpp>
namespace boost { namespace mpi { namespace detail {
@@ -53,6 +54,7 @@ protected:
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::class_id_optional_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::version_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::library_version_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::class_id_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::class_id_reference_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::object_id_type)
@@ -60,6 +62,7 @@ BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::object_reference_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::tracking_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::class_name_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(serialization::collection_size_type)
BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(serialization::item_version_type)
void save_override(std::string const & s, int)
{

View File

@@ -86,7 +86,8 @@ public:
load_impl(&t, get_mpi_datatype(t), 1);
}
void load( std::string & s)
template<class CharType>
void load(std::basic_string<CharType> & s)
{
unsigned int l;
load(l);
@@ -96,7 +97,7 @@ public:
#endif
s.resize(l);
// note breaking a rule here - could be a problem on some platform
load_impl(const_cast<char *>(s.data()),MPI_CHAR,l);
load_impl(const_cast<char *>(s.data()),get_mpi_datatype(CharType()),l);
}
private:

View File

@@ -77,11 +77,12 @@ public:
save_impl(&t, get_mpi_datatype<T>(t), 1);
}
void save(const std::string &s)
template<class CharType>
void save(const std::basic_string<CharType> &s)
{
unsigned int l = static_cast<unsigned int>(s.size());
save(l);
save_impl(s.data(),MPI_CHAR,s.size());
save_impl(s.data(),get_mpi_datatype(CharType()),s.size());
}
private:

View File

@@ -59,9 +59,9 @@ private:
* underlying MPI_Comm. This operation is used for "casting" from a
* communicator to an intercommunicator.
*/
explicit intercommunicator(const shared_ptr<MPI_Comm>& comm_ptr)
explicit intercommunicator(const shared_ptr<MPI_Comm>& cp)
{
this->comm_ptr = comm_ptr;
this->comm_ptr = cp;
}
public:

View File

@@ -20,10 +20,13 @@
#include <boost/mpi/datatype.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/basic_binary_iarchive.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/archive/shared_ptr_helper.hpp>
#include <boost/mpi/detail/packed_iprimitive.hpp>
#include <boost/mpi/detail/binary_buffer_iprimitive.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/serialization/item_version_type.hpp>
#include <boost/assert.hpp>
namespace boost { namespace mpi {
@@ -44,7 +47,7 @@ namespace boost { namespace mpi {
*/
class BOOST_MPI_DECL packed_iarchive
: public iprimitive
, public archive::basic_binary_iarchive<packed_iarchive>
, public archive::detail::common_iarchive<packed_iarchive>
, public archive::detail::shared_ptr_helper
{
public:
@@ -67,7 +70,7 @@ public:
*/
packed_iarchive(MPI_Comm const & comm, buffer_type & b, unsigned int flags = boost::archive::no_header, int position = 0)
: iprimitive(b,comm,position),
archive::basic_binary_iarchive<packed_iarchive>(flags)
archive::detail::common_iarchive<packed_iarchive>(flags)
{}
/**
@@ -87,7 +90,7 @@ public:
( MPI_Comm const & comm , std::size_t s=0,
unsigned int flags = boost::archive::no_header)
: iprimitive(internal_buffer_,comm)
, archive::basic_binary_iarchive<packed_iarchive>(flags)
, archive::detail::common_iarchive<packed_iarchive>(flags)
, internal_buffer_(s)
{}
@@ -95,7 +98,7 @@ public:
template<class T>
void load_override(T& x, int version, mpl::false_)
{
archive::basic_binary_iarchive<packed_iarchive>::load_override(x,version);
archive::detail::common_iarchive<packed_iarchive>::load_override(x,version);
}
// Load it directly using the primnivites
@@ -115,6 +118,16 @@ public:
load_override(x, version, use_optimized());
}
void load_override(archive::class_name_type & t, int)
{
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
* this->This() >> cn;
std::memcpy(t, cn.data(), cn.size());
// borland tweak
t.t[cn.size()] = '\0';
}
private:
/// An internal buffer to be used when the user does not supply his
/// own buffer.

View File

@@ -20,9 +20,12 @@
#include <boost/mpi/datatype.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/basic_binary_oarchive.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/mpi/detail/packed_oprimitive.hpp>
#include <boost/mpi/detail/binary_buffer_oprimitive.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/serialization/item_version_type.hpp>
namespace boost { namespace mpi {
@@ -43,7 +46,7 @@ namespace boost { namespace mpi {
class BOOST_MPI_DECL packed_oarchive
: public oprimitive,
public archive::basic_binary_oarchive<packed_oarchive>
public archive::detail::common_oarchive<packed_oarchive>
{
public:
/**
@@ -62,7 +65,7 @@ public:
*/
packed_oarchive( MPI_Comm const & comm, buffer_type & b, unsigned int flags = boost::archive::no_header)
: oprimitive(b,comm),
archive::basic_binary_oarchive<packed_oarchive>(flags)
archive::detail::common_oarchive<packed_oarchive>(flags)
{}
/**
@@ -78,14 +81,14 @@ public:
*/
packed_oarchive ( MPI_Comm const & comm, unsigned int flags = boost::archive::no_header)
: oprimitive(internal_buffer_,comm),
archive::basic_binary_oarchive<packed_oarchive>(flags)
archive::detail::common_oarchive<packed_oarchive>(flags)
{}
// Save everything else in the usual way, forwarding on to the Base class
template<class T>
void save_override(T const& x, int version, mpl::false_)
{
archive::basic_binary_oarchive<packed_oarchive>::save_override(x,version);
archive::detail::common_oarchive<packed_oarchive>::save_override(x,version);
}
// Save it directly using the primnivites
@@ -103,6 +106,12 @@ public:
save_override(x, version, use_optimized());
}
// explicitly convert to char * to avoid compile ambiguities
void save_override(const archive::class_name_type & t, int){
const std::string s(t);
* this->This() << s;
}
private:
/// An internal buffer to be used when the user does not supply his
/// own buffer.

View File

@@ -11,15 +11,11 @@
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
#include <boost/archive/impl/basic_binary_iarchive.ipp>
namespace boost { namespace archive {
// explicitly instantiate all required templates
template class basic_binary_iarchive<mpi::packed_iarchive> ;
template class detail::archive_serializer_map<mpi::packed_iarchive> ;
} } // end namespace boost::archive

View File

@@ -8,17 +8,12 @@
#define BOOST_ARCHIVE_SOURCE
#include <boost/mpi/packed_oarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
#include <boost/archive/impl/basic_binary_oarchive.ipp>
namespace boost { namespace archive {
// explicitly instantiate all required templates
template class detail::archive_serializer_map<mpi::packed_oarchive> ;
template class basic_binary_oarchive<mpi::packed_oarchive> ;
} } // end namespace boost::archive

View File

@@ -10,22 +10,16 @@
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/mpi/skeleton_and_content.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
#include <boost/archive/impl/basic_binary_iarchive.ipp>
namespace boost { namespace archive {
// explicitly instantiate all required templates
template class basic_binary_iarchive<mpi::packed_skeleton_iarchive> ;
// template class basic_binary_iarchive<mpi::packed_skeleton_iarchive> ;
template class detail::archive_serializer_map<mpi::packed_skeleton_iarchive> ;
template class detail::archive_serializer_map<
mpi::detail::forward_skeleton_iarchive<
boost::mpi::packed_skeleton_iarchive, boost::mpi::packed_iarchive> > ;
//template class binary_iarchive_impl<packed_skeleton_iarchive> ;
} } // end namespace boost::archive

View File

@@ -8,12 +8,8 @@
#define BOOST_ARCHIVE_SOURCE
#include <boost/mpi/skeleton_and_content.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
#include <boost/archive/impl/basic_binary_oarchive.ipp>
namespace boost { namespace archive {
// explicitly instantiate all required templates
@@ -22,7 +18,5 @@ template class detail::archive_serializer_map<mpi::packed_skeleton_oarchive> ;
template class detail::archive_serializer_map<
mpi::detail::forward_skeleton_oarchive<
boost::mpi::packed_skeleton_oarchive, boost::mpi::packed_oarchive> > ;
template class basic_binary_oarchive<mpi::packed_skeleton_oarchive> ;
//template class binary_oarchive_impl<mpi_packed_oarchive> ;
} } // end namespace boost::archive

View File

@@ -11,13 +11,10 @@
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
#include <boost/archive/impl/basic_binary_oarchive.ipp>
namespace boost { namespace archive {
// explicitly instantiate all required templates
template class detail::archive_serializer_map<text_oarchive>;
// template class detail::archive_serializer_map<text_oarchive>;
} } // end namespace boost::archive