2
0
mirror of https://github.com/boostorg/compute.git synced 2026-02-19 14:22:12 +00:00

Move is_device_iterator to the public API

This commit is contained in:
Kyle Lutz
2014-12-29 17:22:25 -08:00
parent a25cbbe233
commit cfdb10c808
25 changed files with 146 additions and 227 deletions

View File

@@ -22,14 +22,14 @@
#include <boost/compute/buffer.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/async/future.hpp>
#include <boost/compute/iterator/buffer_iterator.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/is_contiguous_iterator.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/algorithm/detail/copy_to_host.hpp>
#include <boost/compute/algorithm/detail/copy_on_device.hpp>
#include <boost/compute/algorithm/detail/copy_to_device.hpp>
#include <boost/compute/algorithm/detail/copy_to_host.hpp>
#include <boost/compute/async/future.hpp>
#include <boost/compute/detail/is_contiguous_iterator.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/iterator/buffer_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {

View File

@@ -18,6 +18,7 @@
#include <boost/compute/iterator/buffer_iterator.hpp>
#include <boost/compute/iterator/discard_iterator.hpp>
#include <boost/compute/memory/svm_ptr.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/work_size.hpp>

View File

@@ -23,6 +23,7 @@
#include <boost/compute/container/mapped_view.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/iterator/buffer_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {

View File

@@ -17,8 +17,8 @@
#include <boost/compute/buffer.hpp>
#include <boost/compute/config.hpp>
#include <boost/compute/detail/is_buffer_iterator.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/read_write_single_value.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -191,7 +191,7 @@ private:
size_t m_index;
};
// is_buffer_iterator specialization for buffer_iterator
// is_buffer_iterator specialization for device_ptr
template<class Iterator>
struct is_buffer_iterator<
Iterator,
@@ -203,19 +203,12 @@ struct is_buffer_iterator<
>::type
> : public boost::true_type {};
// is_device_iterator specialization for buffer_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
device_ptr<typename Iterator::value_type>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
// is_device_iterator specialization for device_ptr
template<class T>
struct is_device_iterator<detail::device_ptr<T> > : boost::true_type {};
} // end compute namespace
} // end boost namespace

View File

@@ -1,29 +0,0 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// 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://kylelutz.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_DETAIL_IS_DEVICE_ITERATOR_HPP
#define BOOST_COMPUTE_DETAIL_IS_DEVICE_ITERATOR_HPP
#include <boost/config.hpp>
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost {
namespace compute {
namespace detail {
template<class Iterator, class Enable = void>
struct is_device_iterator : public boost::false_type {};
} // end detail namespace
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_DETAIL_IS_DEVICE_ITERATOR_HPP

View File

@@ -13,8 +13,8 @@
#include <iterator>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/is_contiguous_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {

View File

@@ -23,9 +23,9 @@
#include <boost/compute/buffer.hpp>
#include <boost/compute/detail/buffer_value.hpp>
#include <boost/compute/detail/is_buffer_iterator.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/read_write_single_value.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -255,6 +255,10 @@ make_buffer_iterator(const buffer &buffer, size_t index = 0)
return buffer_iterator<T>(buffer, index);
}
/// \internal_ (is_device_iterator specialization for buffer_iterator)
template<class T>
struct is_device_iterator<buffer_iterator<T> > : boost::true_type {};
namespace detail {
// is_buffer_iterator specialization for buffer_iterator
@@ -269,20 +273,7 @@ struct is_buffer_iterator<
>::type
> : public boost::true_type {};
// is_device_iterator specialization for buffer_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
buffer_iterator<typename Iterator::value_type>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
} // end compute namespace
} // end boost namespace

View File

@@ -18,6 +18,7 @@
#include <boost/compute/buffer.hpp>
#include <boost/compute/iterator/buffer_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -183,6 +184,10 @@ make_constant_buffer_iterator(const buffer &buffer, size_t index = 0)
return constant_buffer_iterator<T>(buffer, index);
}
/// \internal_ (is_device_iterator specialization for constant_buffer_iterator)
template<class T>
struct is_device_iterator<constant_buffer_iterator<T> > : boost::true_type {};
namespace detail {
// is_buffer_iterator specialization for constant_buffer_iterator
@@ -197,20 +202,7 @@ struct is_buffer_iterator<
>::type
> : public boost::true_type {};
// is_device_iterator specialization for constant_buffer_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
constant_buffer_iterator<typename Iterator::value_type>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
} // end compute namespace
} // end boost namespace

View File

@@ -19,7 +19,7 @@
#include <boost/iterator/iterator_facade.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -161,21 +161,9 @@ make_constant_iterator(const T &value, size_t index = 0)
return constant_iterator<T>(value, index);
}
namespace detail {
// is_device_iterator specialization for constant_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
constant_iterator<typename Iterator::value_type>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
/// \internal_ (is_device_iterator specialization for constant_iterator)
template<class T>
struct is_device_iterator<constant_iterator<T> > : boost::true_type {};
} // end compute namespace
} // end boost namespace

View File

@@ -19,7 +19,7 @@
#include <boost/iterator/iterator_facade.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -175,21 +175,9 @@ inline counting_iterator<T> make_counting_iterator(const T &init)
return counting_iterator<T>(init);
}
namespace detail {
// is_device_iterator specialization for counting_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
counting_iterator<typename Iterator::value_type>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
/// \internal_ (is_device_iterator specialization for counting_iterator)
template<class T>
struct is_device_iterator<counting_iterator<T> > : boost::true_type {};
} // end compute namespace
} // end boost namespace

View File

@@ -23,8 +23,8 @@
#include <boost/compute/image2d.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/image_sampler.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
#include <boost/compute/type_traits/make_vector_type.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -193,19 +193,12 @@ make_pixel_input_iterator(const image2d &image, size_t index = 0)
return pixel_input_iterator<T>(image, index);
}
// is_device_iterator specialization for pixel_input_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
pixel_input_iterator<typename Iterator::value_type>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
// is_device_iterator specialization for pixel_input_iterator
template<class T>
struct is_device_iterator<detail::pixel_input_iterator<T> > : boost::true_type {};
} // end compute namespace
} // end boost namespace

View File

@@ -22,9 +22,9 @@
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/type_traits/make_vector_type.hpp>
#include <boost/compute/detail/is_buffer_iterator.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/read_write_single_value.hpp>
#include <boost/compute/iterator/detail/get_base_iterator_buffer.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -176,22 +176,12 @@ make_swizzle_iterator(InputIterator iterator, const std::string &components)
return swizzle_iterator<InputIterator, Size>(iterator, components);
}
// is_device_iterator specialization for swizzle_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
swizzle_iterator<
typename Iterator::base_type,
Iterator::vector_size
>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
// is_device_iterator specialization for swizzle_iterator
template<size_t Size, class InputIterator>
struct is_device_iterator<detail::swizzle_iterator<InputIterator, Size> > : boost::true_type {};
} // end compute namespace
} // end boost namespace

View File

@@ -19,7 +19,7 @@
#include <boost/iterator/iterator_facade.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -160,13 +160,10 @@ inline discard_iterator make_discard_iterator(size_t index = 0)
return discard_iterator(index);
}
namespace detail {
// is_device_iterator specialization for discard_iterator
/// internal_ (is_device_iterator specialization for discard_iterator)
template<>
struct is_device_iterator<discard_iterator> : public boost::true_type {};
struct is_device_iterator<discard_iterator> : boost::true_type {};
} // end detail namespace
} // end compute namespace
} // end boost namespace

View File

@@ -18,7 +18,7 @@
#include <boost/iterator/iterator_facade.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
#include <boost/compute/type_traits/result_of.hpp>
namespace boost {
@@ -176,21 +176,9 @@ make_function_input_iterator(const Function &function, size_t index = 0)
return function_input_iterator<Function>(function, index);
}
namespace detail {
// is_device_iterator specialization for function_input_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
function_input_iterator<typename Iterator::function>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
/// \internal_ (is_device_iterator specialization for function_input_iterator)
template<class Function>
struct is_device_iterator<function_input_iterator<Function> > : boost::true_type {};
} // end compute namespace
} // end boost namespace

View File

@@ -21,9 +21,9 @@
#include <boost/compute/functional.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/is_buffer_iterator.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/read_write_single_value.hpp>
#include <boost/compute/iterator/detail/get_base_iterator_buffer.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -181,22 +181,10 @@ make_permutation_iterator(ElementIterator e, IndexIterator i)
return permutation_iterator<ElementIterator, IndexIterator>(e, i);
}
namespace detail {
// is_device_iterator specialization for permutation_iterator
template<class Iterator>
/// \internal_ (is_device_iterator specialization for permutation_iterator)
template<class ElementIterator, class IndexIterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
permutation_iterator<typename Iterator::base_type,
typename Iterator::index_iterator>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
permutation_iterator<ElementIterator, IndexIterator> > : boost::true_type {};
} // end compute namespace
} // end boost namespace

View File

@@ -20,9 +20,9 @@
#include <boost/compute/functional.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/is_buffer_iterator.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/read_write_single_value.hpp>
#include <boost/compute/iterator/detail/get_base_iterator_buffer.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
#include <boost/compute/type_traits/result_of.hpp>
namespace boost {
@@ -106,8 +106,7 @@ inline meta_kernel& operator<<(meta_kernel &kernel,
/// \see buffer_iterator, make_transform_iterator()
template<class InputIterator, class UnaryFunction>
class transform_iterator :
public detail::transform_iterator_base<InputIterator,
UnaryFunction>::type
public detail::transform_iterator_base<InputIterator, UnaryFunction>::type
{
public:
typedef typename
@@ -217,22 +216,11 @@ make_transform_iterator(InputIterator iterator, UnaryFunction transform)
UnaryFunction>(iterator, transform);
}
namespace detail {
// is_device_iterator specialization for transform_iterator
template<class Iterator>
/// \internal_ (is_device_iterator specialization for transform_iterator)
template<class InputIterator, class UnaryFunction>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
transform_iterator<typename Iterator::base_type,
typename Iterator::unary_function>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
transform_iterator<InputIterator, UnaryFunction> > : boost::true_type {};
} // end detail namespace
} // end compute namespace
} // end boost namespace

View File

@@ -26,11 +26,11 @@
#include <boost/compute/config.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/types/tuple.hpp>
#include <boost/compute/type_traits/type_name.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/detail/mpl_vector_to_tuple.hpp>
#include <boost/compute/types/tuple.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
#include <boost/compute/type_traits/type_name.hpp>
namespace boost {
namespace compute {
@@ -278,19 +278,11 @@ make_zip_iterator(IteratorTuple iterators)
return zip_iterator<IteratorTuple>(iterators);
}
namespace detail {
/// \internal_ (is_device_iterator specialization for zip_iterator)
template<class IteratorTuple>
struct is_device_iterator<zip_iterator<IteratorTuple> > : boost::true_type {};
// is_device_iterator specialization for zip_iterator
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
zip_iterator<typename Iterator::iterator_tuple>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
namespace detail {
// get<N>() specialization for zip_iterator
/// \internal_

View File

@@ -12,7 +12,7 @@
#define BOOST_COMPUTE_MEMORY_SVM_PTR_HPP
#include <boost/compute/cl.hpp>
#include <boost/compute/detail/is_device_iterator.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -70,21 +70,10 @@ private:
T *m_ptr;
};
namespace detail {
/// \internal_ (is_device_iterator specialization for svm_ptr)
template<class T>
struct is_device_iterator<svm_ptr<T> > : boost::true_type {};
// is_device_iterator specialization for svm_ptr
template<class Iterator>
struct is_device_iterator<
Iterator,
typename boost::enable_if<
boost::is_same<
svm_ptr<typename Iterator::value_type>,
typename boost::remove_const<Iterator>::type
>
>::type
> : public boost::true_type {};
} // end detail namespace
} // end compute namespace
} // end boost namespace

View File

@@ -12,6 +12,7 @@
#define BOOST_COMPUTE_TYPE_TRAITS_HPP
#include <boost/compute/type_traits/common_type.hpp>
#include <boost/compute/type_traits/is_device_iterator.hpp>
#include <boost/compute/type_traits/is_fundamental.hpp>
#include <boost/compute/type_traits/is_vector_type.hpp>
#include <boost/compute/type_traits/make_vector_type.hpp>

View File

@@ -0,0 +1,39 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// 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://kylelutz.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_TYPE_TRAITS_IS_DEVICE_ITERATOR_HPP
#define BOOST_COMPUTE_TYPE_TRAITS_IS_DEVICE_ITERATOR_HPP
#include <boost/type_traits/integral_constant.hpp>
namespace boost {
namespace compute {
/// Meta-function returning \c true if \c Iterator is a device-iterator.
///
/// By default, this function returns false. Device iterator types (such as
/// buffer_iterator) should specialize this trait and return \c true.
///
/// For example:
/// \code
/// is_device_iterator<buffer_iterator<int>>::value == true
/// is_device_iterator<std::vector<int>::iterator>::value == false
/// \endcode
template<class Iterator>
struct is_device_iterator : boost::false_type {};
/// \internal_
template<class Iterator>
struct is_device_iterator<const Iterator> : is_device_iterator<Iterator> {};
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_TYPE_TRAITS_IS_DEVICE_ITERATOR_HPP