Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
// Copyright 2005 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Authors: Douglas Gregor
// Andrew Lumsdaine
#ifndef BOOST_GRAPH_PARALLEL_INPLACE_ALL_TO_ALL_HPP
#define BOOST_GRAPH_PARALLEL_INPLACE_ALL_TO_ALL_HPP
#ifndef BOOST_GRAPH_USE_MPI
#error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
#endif
//
// Implements the inplace all-to-all communication algorithm.
//
#include <vector>
#include <iterator>
namespace boost { namespace parallel {
template<typename ProcessGroup, typename T>
// where {LinearProcessGroup<ProcessGroup>, MessagingProcessGroup<ProcessGroup>}
void
inplace_all_to_all(ProcessGroup pg,
const std::vector<std::vector<T> >& outgoing,
std::vector<std::vector<T> >& incoming)
{
typedef typename std::vector<T>::size_type size_type;
typedef typename ProcessGroup::process_size_type process_size_type;
typedef typename ProcessGroup::process_id_type process_id_type;
process_size_type p = num_processes(pg);
// Make sure there are no straggling messages
synchronize(pg);
// Send along the count (always) and the data (if count > 0)
for (process_id_type dest = 0; dest < p; ++dest) {
if (dest != process_id(pg)) {
send(pg, dest, 0, outgoing[dest].size());
if (!outgoing[dest].empty())
send(pg, dest, 1, &outgoing[dest].front(), outgoing[dest].size());
}
}
// Make sure all of the data gets transferred
synchronize(pg);
// Receive the sizes and data
for (process_id_type source = 0; source < p; ++source) {
if (source != process_id(pg)) {
size_type size;
receive(pg, source, 0, size);
incoming[source].resize(size);
if (size > 0)
receive(pg, source, 1, &incoming[source].front(), size);
} else if (&incoming != &outgoing) {
incoming[source] = outgoing[source];
}
}
}
template<typename ProcessGroup, typename T>
// where {LinearProcessGroup<ProcessGroup>, MessagingProcessGroup<ProcessGroup>}
void
inplace_all_to_all(ProcessGroup pg, std::vector<std::vector<T> >& data)
{
inplace_all_to_all(pg, data, data);
}
} } // end namespace boost::parallel
#endif // BOOST_GRAPH_PARALLEL_INPLACE_ALL_TO_ALL_HPP

View File

@@ -0,0 +1,152 @@
// Copyright (C) 2007 Douglas Gregor and Matthias Troyer
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
//
// This file contains helper data structures for use in transmitting
// properties. The basic idea is to optimize away any storage for the
// properties when no properties are specified.
#ifndef BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP
#define BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP
#ifndef BOOST_GRAPH_USE_MPI
#error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
#endif
#include <boost/mpi/datatype.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/mpl/and.hpp>
#include <boost/graph/parallel/detail/untracked_pair.hpp>
namespace boost { namespace detail { namespace parallel {
/**
* This structure contains an instance of @c Property, unless @c
* Property is a placeholder for "no property". Always access the
* property through @c get_property. Typically used as a base class.
*/
template<typename Property>
struct maybe_store_property
{
maybe_store_property() {}
maybe_store_property(const Property& p) : p(p) {}
Property& get_property() { return p; }
const Property& get_property() const { return p; }
private:
Property p;
friend class boost::serialization::access;
template<typename Archiver>
void serialize(Archiver& ar, const unsigned int /*version*/)
{
ar & p;
}
};
template<>
struct maybe_store_property<no_property>
{
maybe_store_property() {}
maybe_store_property(no_property) {}
no_property get_property() const { return no_property(); }
private:
friend class boost::serialization::access;
template<typename Archiver>
void serialize(Archiver&, const unsigned int /*version*/) { }
};
/**
* This structure is a simple pair that also contains a property.
*/
template<typename T, typename U, typename Property>
class pair_with_property
: public boost::parallel::detail::untracked_pair<T, U>
, public maybe_store_property<Property>
{
public:
typedef boost::parallel::detail::untracked_pair<T, U> pair_base;
typedef maybe_store_property<Property> property_base;
pair_with_property() { }
pair_with_property(const T& t, const U& u, const Property& property)
: pair_base(t, u), property_base(property) { }
private:
friend class boost::serialization::access;
template<typename Archiver>
void serialize(Archiver& ar, const unsigned int /*version*/)
{
ar & boost::serialization::base_object<pair_base>(*this)
& boost::serialization::base_object<property_base>(*this);
}
};
template<typename T, typename U, typename Property>
inline pair_with_property<T, U, Property>
make_pair_with_property(const T& t, const U& u, const Property& property)
{
return pair_with_property<T, U, Property>(t, u, property);
}
} } } // end namespace boost::parallel::detail
namespace boost { namespace mpi {
template<>
struct is_mpi_datatype<boost::detail::parallel::maybe_store_property<no_property> > : mpl::true_ { };
template<typename Property>
struct is_mpi_datatype<boost::detail::parallel::maybe_store_property<Property> >
: is_mpi_datatype<Property> { };
template<typename T, typename U, typename Property>
struct is_mpi_datatype<boost::detail::parallel::pair_with_property<T, U, Property> >
: boost::mpl::and_<is_mpi_datatype<boost::parallel::detail::untracked_pair<T, U> >,
is_mpi_datatype<Property> > { };
} } // end namespace boost::mpi
BOOST_IS_BITWISE_SERIALIZABLE(boost::detail::parallel::maybe_store_property<no_property>)
namespace boost { namespace serialization {
template<typename Property>
struct is_bitwise_serializable<boost::detail::parallel::maybe_store_property<Property> >
: is_bitwise_serializable<Property> { };
template<typename Property>
struct implementation_level<boost::detail::parallel::maybe_store_property<Property> >
: mpl::int_<object_serializable> {} ;
template<typename Property>
struct tracking_level<boost::detail::parallel::maybe_store_property<Property> >
: mpl::int_<track_never> {} ;
template<typename T, typename U, typename Property>
struct is_bitwise_serializable<
boost::detail::parallel::pair_with_property<T, U, Property> >
: boost::mpl::and_<is_bitwise_serializable<boost::parallel::detail::untracked_pair<T, U> >,
is_bitwise_serializable<Property> > { };
template<typename T, typename U, typename Property>
struct implementation_level<
boost::detail::parallel::pair_with_property<T, U, Property> >
: mpl::int_<object_serializable> {} ;
template<typename T, typename U, typename Property>
struct tracking_level<
boost::detail::parallel::pair_with_property<T, U, Property> >
: mpl::int_<track_never> {} ;
} } // end namespace boost::serialization
#endif // BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP

View File

@@ -0,0 +1,85 @@
// Copyright (C) 2007 Matthias Troyer
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
//
// This file contains helper data structures for use in transmitting
// properties. The basic idea is to optimize away any storage for the
// properties when no properties are specified.
#ifndef BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP
#define BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP
#ifndef BOOST_GRAPH_USE_MPI
#error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
#endif
#include <boost/mpi/datatype.hpp>
#include <utility> // for std::pair
#include <boost/serialization/utility.hpp>
namespace boost { namespace parallel { namespace detail {
/**
* This structure is like std::pair, with the only difference
* that tracking in the serialization library is turned off.
*/
template<typename T, typename U>
struct untracked_pair : public std::pair<T,U>
{
untracked_pair() {}
untracked_pair(const T& t, const U& u)
: std::pair<T,U>(t,u) {}
template<class T1, class U1>
untracked_pair(std::pair<T1,U1> const& p)
: std::pair<T,U>(p) {}
};
template<typename T, typename U>
inline untracked_pair<T, U>
make_untracked_pair(const T& t, const U& u)
{
return untracked_pair<T,U>(t,u);
}
} } } // end namespace boost::parallel::detail
namespace boost { namespace mpi {
template<typename T, typename U>
struct is_mpi_datatype<boost::parallel::detail::untracked_pair<T, U> >
: is_mpi_datatype<std::pair<T,U> > {};
} } // end namespace boost::mpi
namespace boost { namespace serialization {
// pair
template<class Archive, class F, class S>
inline void serialize(
Archive & ar,
boost::parallel::detail::untracked_pair<F, S> & p,
const unsigned int /* file_version */
){
ar & boost::serialization::make_nvp("first", p.first);
ar & boost::serialization::make_nvp("second", p.second);
}
template<typename T, typename U>
struct is_bitwise_serializable<
boost::parallel::detail::untracked_pair<T, U> >
: is_bitwise_serializable<std::pair<T, U> > {};
template<typename T, typename U>
struct implementation_level<boost::parallel::detail::untracked_pair<T, U> >
: mpl::int_<object_serializable> {} ;
template<typename T, typename U>
struct tracking_level<boost::parallel::detail::untracked_pair<T, U> >
: mpl::int_<track_never> {} ;
} } // end namespace boost::serialization
#endif // BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP