Skip to content

Commit

Permalink
Move is_distributed_vector<T> to separate header
Browse files Browse the repository at this point in the history
  • Loading branch information
jszuppe committed Aug 23, 2016
1 parent 1c9fd33 commit 745e88f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 23 deletions.
18 changes: 2 additions & 16 deletions include/boost/compute/distributed/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,26 @@
#include <boost/mpl/not.hpp>
#include <boost/mpl/or.hpp>

#include <boost/type_traits/integral_constant.hpp>

#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/wait_list.hpp>

#include <boost/compute/distributed/context.hpp>
#include <boost/compute/distributed/command_queue.hpp>
#include <boost/compute/distributed/detail/weight_func.hpp>
#include <boost/compute/distributed/detail/is_distributed_vector.hpp>

namespace boost {
namespace compute {
namespace distributed {

// forward declaration for distributed::vector
// forward declaration for distributed::vector<T, weight_func, Alloc>
template<
class T,
weight_func weight,
class Alloc
>
class vector;

namespace detail {

template<class T>
struct is_distributed_vector : boost::false_type {};

template<class T>
struct is_distributed_vector<const T> : is_distributed_vector<T> {};

template< class T, weight_func w, class Alloc>
struct is_distributed_vector< vector<T, w, Alloc> > : boost::true_type {};

} // end detail namespace

// host -> distributed::vector
/// Copies the values in the range [\p first, \p last) allocated on host to
/// distributed::vector \p result. The copy is performed asynchronously.
Expand Down
35 changes: 35 additions & 0 deletions include/boost/compute/distributed/detail/is_distributed_vector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2016 Jakub Szuppe <[email protected]>
//
// Distributed under 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
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//

#ifndef BOOST_COMPUTE_DISTRIBUTED_DETAIL_IS_DISTRIBUTED_VECTOR_HPP
#define BOOST_COMPUTE_DISTRIBUTED_DETAIL_IS_DISTRIBUTED_VECTOR_HPP


#include <boost/type_traits/integral_constant.hpp>

namespace boost {
namespace compute {
namespace distributed {

namespace detail {

template<class T>
struct is_distributed_vector : boost::false_type {};

template<class T>
struct is_distributed_vector<const T> : is_distributed_vector<T> {};

} // end detail namespace

} // end distributed namespace
} // end compute namespace
} // end boost namespace

#endif /* BOOST_COMPUTE_DISTRIBUTED_DETAIL_IS_DISTRIBUTED_VECTOR_HPP */
12 changes: 5 additions & 7 deletions include/boost/compute/distributed/detail/weight_func.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ namespace distributed {

typedef std::vector<double> (*weight_func)(const command_queue&);

std::vector<double> default_weight_func(const command_queue& queue)
{
return std::vector<double>(queue.size(), 1.0/queue.size());
}

namespace detail {

/// \internal_
Expand All @@ -33,8 +38,6 @@ size_t round_up(size_t n, size_t m)
return (n + m - 1) & ~(m - 1);
}

/// \internal_
///
std::vector<size_t> partition(const command_queue& queue,
weight_func weight_func,
const size_t size,
Expand Down Expand Up @@ -66,11 +69,6 @@ std::vector<size_t> partition(const command_queue& queue,

} // end distributed detail

std::vector<double> default_weight_func(const command_queue& queue)
{
return std::vector<double>(queue.size(), 1.0/queue.size());
}

} // end distributed namespace
} // end compute namespace
} // end boost namespace
Expand Down
9 changes: 9 additions & 0 deletions include/boost/compute/distributed/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <boost/compute/distributed/command_queue.hpp>
#include <boost/compute/distributed/copy.hpp>
#include <boost/compute/distributed/detail/weight_func.hpp>
#include <boost/compute/distributed/detail/is_distributed_vector.hpp>

namespace boost {
namespace compute {
Expand Down Expand Up @@ -551,6 +552,14 @@ class vector
std::vector<allocator_type> m_allocators;
};


namespace detail {

template<class T, weight_func w, class Alloc>
struct is_distributed_vector< vector<T, w, Alloc> > : boost::true_type {};

} // end detail namespace

} // end distributed namespace
} // end compute namespace
} // end boost namespace
Expand Down

0 comments on commit 745e88f

Please sign in to comment.