mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-13 19:29:02 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
// Copyright 2004 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_PARALLEL_ALGORITHM_HPP
|
||||
#define BOOST_PARALLEL_ALGORITHM_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/optional.hpp>
|
||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
namespace boost { namespace parallel {
|
||||
template<typename BinaryOp>
|
||||
struct is_commutative
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct minimum : std::binary_function<T, T, T>
|
||||
{
|
||||
const T& operator()(const T& x, const T& y) const { return x < y? x : y; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct maximum : std::binary_function<T, T, T>
|
||||
{
|
||||
const T& operator()(const T& x, const T& y) const { return x < y? y : x; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct sum : std::binary_function<T, T, T>
|
||||
{
|
||||
const T operator()(const T& x, const T& y) const { return x + y; }
|
||||
};
|
||||
|
||||
template<typename ProcessGroup, typename InputIterator,
|
||||
typename OutputIterator, typename BinaryOperation>
|
||||
OutputIterator
|
||||
reduce(ProcessGroup pg, typename ProcessGroup::process_id_type root,
|
||||
InputIterator first, InputIterator last, OutputIterator out,
|
||||
BinaryOperation bin_op);
|
||||
|
||||
template<typename ProcessGroup, typename T, typename BinaryOperation>
|
||||
inline T
|
||||
all_reduce(ProcessGroup pg, const T& value, BinaryOperation bin_op)
|
||||
{
|
||||
T result;
|
||||
all_reduce(pg,
|
||||
const_cast<T*>(&value), const_cast<T*>(&value+1),
|
||||
&result, bin_op);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename ProcessGroup, typename T, typename BinaryOperation>
|
||||
inline T
|
||||
scan(ProcessGroup pg, const T& value, BinaryOperation bin_op)
|
||||
{
|
||||
T result;
|
||||
scan(pg,
|
||||
const_cast<T*>(&value), const_cast<T*>(&value+1),
|
||||
&result, bin_op);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template<typename ProcessGroup, typename InputIterator, typename T>
|
||||
void
|
||||
all_gather(ProcessGroup pg, InputIterator first, InputIterator last,
|
||||
std::vector<T>& out);
|
||||
} } // end namespace boost::parallel
|
||||
|
||||
#include <boost/graph/parallel/detail/inplace_all_to_all.hpp>
|
||||
|
||||
#endif // BOOST_PARALLEL_ALGORITHM_HPP
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2004-2006 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
|
||||
|
||||
//
|
||||
// This file contains traits that describe
|
||||
//
|
||||
#ifndef BOOST_GRAPH_PARALLEL_CONTAINER_TRAITS_HPP
|
||||
#define BOOST_GRAPH_PARALLEL_CONTAINER_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_GRAPH_USE_MPI
|
||||
#error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
|
||||
#endif
|
||||
|
||||
namespace boost { namespace graph { namespace parallel {
|
||||
|
||||
template<typename T>
|
||||
struct process_group_type
|
||||
{
|
||||
typedef typename T::process_group_type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline typename process_group_type<T>::type
|
||||
process_group(const T& x)
|
||||
{ return x.process_group(); }
|
||||
|
||||
// Helper function that algorithms should use to get the process group
|
||||
// out of a container.
|
||||
template<typename Container>
|
||||
inline typename process_group_type<Container>::type
|
||||
process_group_adl(const Container& container)
|
||||
{
|
||||
return process_group(container);
|
||||
}
|
||||
|
||||
|
||||
} } } // end namespace boost::graph::parallel
|
||||
|
||||
#endif // BOOST_GRAPH_PARALLEL_CONTAINER_TRAITS_HPP
|
||||
@@ -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
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2004 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
|
||||
|
||||
// File moved
|
||||
#include <boost/property_map/parallel/process_group.hpp>
|
||||
@@ -0,0 +1,113 @@
|
||||
// Copyright 2004 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_PROPERTIES_HPP
|
||||
#define BOOST_GRAPH_PARALLEL_PROPERTIES_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/graph/properties.hpp>
|
||||
#include <boost/property_map/parallel/distributed_property_map.hpp>
|
||||
|
||||
namespace boost {
|
||||
/***************************************************************************
|
||||
* Property map reduction operations
|
||||
***************************************************************************/
|
||||
/**
|
||||
* Metafunction that produces a reduction operation for the given
|
||||
* property. The default behavior merely forwards to @ref
|
||||
* basic_reduce, but it is expected that this class template will be
|
||||
* specified for important properties.
|
||||
*/
|
||||
template<typename Property>
|
||||
struct property_reduce
|
||||
{
|
||||
template<typename Value>
|
||||
class apply : public parallel::basic_reduce<Value> {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Reduction of vertex colors can only darken, not lighten, the
|
||||
* color. Black cannot turn black, grey can only turn black, and
|
||||
* white can be changed to either color. The default color is white.
|
||||
*/
|
||||
template<>
|
||||
struct property_reduce<vertex_color_t>
|
||||
{
|
||||
template<typename Color>
|
||||
class apply
|
||||
{
|
||||
typedef color_traits<Color> traits;
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, non_default_resolver = true);
|
||||
|
||||
template<typename Key>
|
||||
Color operator()(const Key&) const { return traits::white(); }
|
||||
|
||||
template<typename Key>
|
||||
Color operator()(const Key&, Color local, Color remote) const {
|
||||
if (local == traits::white()) return remote;
|
||||
else if (remote == traits::black()) return remote;
|
||||
else return local;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Reduction of a distance always takes the shorter distance. The
|
||||
* default distance value is the maximum value for the data type.
|
||||
*/
|
||||
template<>
|
||||
struct property_reduce<vertex_distance_t>
|
||||
{
|
||||
template<typename T>
|
||||
class apply
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, non_default_resolver = true);
|
||||
|
||||
template<typename Key>
|
||||
T operator()(const Key&) const { return (std::numeric_limits<T>::max)(); }
|
||||
|
||||
template<typename Key>
|
||||
T operator()(const Key&, T x, T y) const { return x < y? x : y; }
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_reduce<vertex_predecessor_t>
|
||||
{
|
||||
template<typename T>
|
||||
class apply
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, non_default_resolver = true);
|
||||
|
||||
template<typename Key>
|
||||
T operator()(Key key) const { return key; }
|
||||
template<typename Key>
|
||||
T operator()(Key key, T, T y) const { return y; }
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Property, typename PropertyMap>
|
||||
inline void set_property_map_role(Property p, PropertyMap pm)
|
||||
{
|
||||
typedef typename property_traits<PropertyMap>::value_type value_type;
|
||||
typedef property_reduce<Property> property_red;
|
||||
typedef typename property_red::template apply<value_type> reduce;
|
||||
|
||||
pm.set_reduce(reduce());
|
||||
}
|
||||
|
||||
} // end namespace boost
|
||||
#endif // BOOST_GRAPH_PARALLEL_PROPERTIES_HPP
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2007 Douglas Gregor
|
||||
|
||||
// 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)
|
||||
|
||||
// This file contains a simplification of the "trigger" method for
|
||||
// process groups. The simple trigger handles the common case where
|
||||
// the handler associated with a trigger is a member function bound to
|
||||
// a particular pointer.
|
||||
|
||||
// File moved
|
||||
#include <boost/property_map/parallel/simple_trigger.hpp>
|
||||
Reference in New Issue
Block a user