summaryrefslogtreecommitdiff
path: root/boost/compute/algorithm
diff options
context:
space:
mode:
Diffstat (limited to 'boost/compute/algorithm')
-rw-r--r--boost/compute/algorithm/accumulate.hpp5
-rw-r--r--boost/compute/algorithm/adjacent_difference.hpp7
-rw-r--r--boost/compute/algorithm/adjacent_find.hpp5
-rw-r--r--boost/compute/algorithm/all_of.hpp4
-rw-r--r--boost/compute/algorithm/any_of.hpp4
-rw-r--r--boost/compute/algorithm/binary_search.hpp4
-rw-r--r--boost/compute/algorithm/copy_if.hpp7
-rw-r--r--boost/compute/algorithm/count.hpp4
-rw-r--r--boost/compute/algorithm/count_if.hpp4
-rw-r--r--boost/compute/algorithm/equal.hpp7
-rw-r--r--boost/compute/algorithm/equal_range.hpp4
-rw-r--r--boost/compute/algorithm/exclusive_scan.hpp9
-rw-r--r--boost/compute/algorithm/fill.hpp5
-rw-r--r--boost/compute/algorithm/fill_n.hpp4
-rw-r--r--boost/compute/algorithm/find.hpp4
-rw-r--r--boost/compute/algorithm/find_end.hpp6
-rw-r--r--boost/compute/algorithm/find_if.hpp4
-rw-r--r--boost/compute/algorithm/find_if_not.hpp4
-rw-r--r--boost/compute/algorithm/for_each.hpp5
-rw-r--r--boost/compute/algorithm/for_each_n.hpp4
-rw-r--r--boost/compute/algorithm/gather.hpp7
-rw-r--r--boost/compute/algorithm/generate.hpp4
-rw-r--r--boost/compute/algorithm/includes.hpp6
-rw-r--r--boost/compute/algorithm/inclusive_scan.hpp7
-rw-r--r--boost/compute/algorithm/inner_product.hpp7
-rw-r--r--boost/compute/algorithm/inplace_merge.hpp4
-rw-r--r--boost/compute/algorithm/iota.hpp4
-rw-r--r--boost/compute/algorithm/is_partitioned.hpp4
-rw-r--r--boost/compute/algorithm/is_permutation.hpp5
-rw-r--r--boost/compute/algorithm/is_sorted.hpp5
-rw-r--r--boost/compute/algorithm/lexicographical_compare.hpp6
-rw-r--r--boost/compute/algorithm/lower_bound.hpp4
-rw-r--r--boost/compute/algorithm/max_element.hpp5
-rw-r--r--boost/compute/algorithm/merge.hpp9
-rw-r--r--boost/compute/algorithm/min_element.hpp5
-rw-r--r--boost/compute/algorithm/minmax_element.hpp5
-rw-r--r--boost/compute/algorithm/mismatch.hpp7
-rw-r--r--boost/compute/algorithm/next_permutation.hpp4
-rw-r--r--boost/compute/algorithm/none_of.hpp4
-rw-r--r--boost/compute/algorithm/nth_element.hpp5
-rw-r--r--boost/compute/algorithm/partial_sum.hpp5
-rw-r--r--boost/compute/algorithm/partition.hpp4
-rw-r--r--boost/compute/algorithm/partition_copy.hpp7
-rw-r--r--boost/compute/algorithm/partition_point.hpp10
-rw-r--r--boost/compute/algorithm/prev_permutation.hpp4
-rw-r--r--boost/compute/algorithm/random_shuffle.hpp13
-rw-r--r--boost/compute/algorithm/reduce.hpp5
-rw-r--r--boost/compute/algorithm/reduce_by_key.hpp16
-rw-r--r--boost/compute/algorithm/remove.hpp4
-rw-r--r--boost/compute/algorithm/remove_if.hpp4
-rw-r--r--boost/compute/algorithm/replace.hpp4
-rw-r--r--boost/compute/algorithm/replace_copy.hpp6
-rw-r--r--boost/compute/algorithm/reverse.hpp4
-rw-r--r--boost/compute/algorithm/reverse_copy.hpp6
-rw-r--r--boost/compute/algorithm/scatter.hpp6
-rw-r--r--boost/compute/algorithm/scatter_if.hpp12
-rw-r--r--boost/compute/algorithm/search.hpp6
-rw-r--r--boost/compute/algorithm/search_n.hpp5
-rw-r--r--boost/compute/algorithm/set_difference.hpp7
-rw-r--r--boost/compute/algorithm/set_intersection.hpp7
-rw-r--r--boost/compute/algorithm/set_symmetric_difference.hpp7
-rw-r--r--boost/compute/algorithm/set_union.hpp7
-rw-r--r--boost/compute/algorithm/sort_by_key.hpp7
-rw-r--r--boost/compute/algorithm/stable_partition.hpp4
-rw-r--r--boost/compute/algorithm/stable_sort.hpp6
-rw-r--r--boost/compute/algorithm/stable_sort_by_key.hpp7
-rw-r--r--boost/compute/algorithm/swap_ranges.hpp6
-rw-r--r--boost/compute/algorithm/transform.hpp13
-rw-r--r--boost/compute/algorithm/transform_if.hpp5
-rw-r--r--boost/compute/algorithm/transform_reduce.hpp8
-rw-r--r--boost/compute/algorithm/unique.hpp5
-rw-r--r--boost/compute/algorithm/unique_copy.hpp9
-rw-r--r--boost/compute/algorithm/upper_bound.hpp4
73 files changed, 424 insertions, 6 deletions
diff --git a/boost/compute/algorithm/accumulate.hpp b/boost/compute/algorithm/accumulate.hpp
index be20bee60e..025b0a9c8a 100644
--- a/boost/compute/algorithm/accumulate.hpp
+++ b/boost/compute/algorithm/accumulate.hpp
@@ -11,6 +11,7 @@
#ifndef BOOST_COMPUTE_ALGORITHM_ACCUMULATE_HPP
#define BOOST_COMPUTE_ALGORITHM_ACCUMULATE_HPP
+#include <boost/static_assert.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/compute/system.hpp>
@@ -20,6 +21,7 @@
#include <boost/compute/algorithm/detail/serial_accumulate.hpp>
#include <boost/compute/container/array.hpp>
#include <boost/compute/container/vector.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
namespace boost {
@@ -167,6 +169,8 @@ inline T accumulate(InputIterator first,
BinaryFunction function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+
return detail::dispatch_accumulate(first, last, init, function, queue);
}
@@ -177,6 +181,7 @@ inline T accumulate(InputIterator first,
T init,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type IT;
return detail::dispatch_accumulate(first, last, init, plus<IT>(), queue);
diff --git a/boost/compute/algorithm/adjacent_difference.hpp b/boost/compute/algorithm/adjacent_difference.hpp
index c3b0e7d191..3d23f645b8 100644
--- a/boost/compute/algorithm/adjacent_difference.hpp
+++ b/boost/compute/algorithm/adjacent_difference.hpp
@@ -13,12 +13,15 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/functional/operator.hpp>
#include <boost/compute/container/vector.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -76,6 +79,8 @@ adjacent_difference(InputIterator first,
BinaryFunction op,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
if(first == last) {
@@ -106,6 +111,8 @@ adjacent_difference(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
return ::boost::compute::adjacent_difference(
diff --git a/boost/compute/algorithm/adjacent_find.hpp b/boost/compute/algorithm/adjacent_find.hpp
index a71a817f57..b492600849 100644
--- a/boost/compute/algorithm/adjacent_find.hpp
+++ b/boost/compute/algorithm/adjacent_find.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/command_queue.hpp>
#include <boost/compute/lambda.hpp>
#include <boost/compute/system.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/functional/operator.hpp>
#include <boost/compute/type_traits/vector_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -124,6 +127,7 @@ adjacent_find(InputIterator first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
size_t count = detail::iterator_range_size(first, last);
if(count < 32){
return detail::serial_adjacent_find(first, last, compare, queue);
@@ -140,6 +144,7 @@ adjacent_find(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
using ::boost::compute::lambda::_1;
diff --git a/boost/compute/algorithm/all_of.hpp b/boost/compute/algorithm/all_of.hpp
index 56c5809992..147de4fcfc 100644
--- a/boost/compute/algorithm/all_of.hpp
+++ b/boost/compute/algorithm/all_of.hpp
@@ -11,8 +11,11 @@
#ifndef BOOST_COMPUTE_ALGORITHM_ALL_OF_HPP
#define BOOST_COMPUTE_ALGORITHM_ALL_OF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/find_if_not.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -29,6 +32,7 @@ inline bool all_of(InputIterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return ::boost::compute::find_if_not(first, last, predicate, queue) == last;
}
diff --git a/boost/compute/algorithm/any_of.hpp b/boost/compute/algorithm/any_of.hpp
index 54031fbac5..e3c52daee3 100644
--- a/boost/compute/algorithm/any_of.hpp
+++ b/boost/compute/algorithm/any_of.hpp
@@ -11,8 +11,11 @@
#ifndef BOOST_COMPUTE_ALGORITHM_ANY_OF_HPP
#define BOOST_COMPUTE_ALGORITHM_ANY_OF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/find_if.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -33,6 +36,7 @@ inline bool any_of(InputIterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return ::boost::compute::find_if(first, last, predicate, queue) != last;
}
diff --git a/boost/compute/algorithm/binary_search.hpp b/boost/compute/algorithm/binary_search.hpp
index 880f3628fb..ba555166f8 100644
--- a/boost/compute/algorithm/binary_search.hpp
+++ b/boost/compute/algorithm/binary_search.hpp
@@ -11,9 +11,12 @@
#ifndef BOOST_COMPUTE_ALGORITHM_BINARY_SEARCH_HPP
#define BOOST_COMPUTE_ALGORITHM_BINARY_SEARCH_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/lower_bound.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -28,6 +31,7 @@ inline bool binary_search(InputIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
InputIterator position = lower_bound(first, last, value, queue);
return position != last && position.read(queue) == value;
diff --git a/boost/compute/algorithm/copy_if.hpp b/boost/compute/algorithm/copy_if.hpp
index bdedcb8536..7cccaa572e 100644
--- a/boost/compute/algorithm/copy_if.hpp
+++ b/boost/compute/algorithm/copy_if.hpp
@@ -11,8 +11,11 @@
#ifndef BOOST_COMPUTE_ALGORITHM_COPY_IF_HPP
#define BOOST_COMPUTE_ALGORITHM_COPY_IF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/transform_if.hpp>
#include <boost/compute/functional/identity.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -27,6 +30,8 @@ inline OutputIterator copy_index_if(InputIterator first,
Predicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type T;
return detail::transform_if_impl(
@@ -47,6 +52,8 @@ inline OutputIterator copy_if(InputIterator first,
Predicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type T;
return ::boost::compute::transform_if(
diff --git a/boost/compute/algorithm/count.hpp b/boost/compute/algorithm/count.hpp
index 7a502c6791..bb46ee24c9 100644
--- a/boost/compute/algorithm/count.hpp
+++ b/boost/compute/algorithm/count.hpp
@@ -11,11 +11,14 @@
#ifndef BOOST_COMPUTE_ALGORITHM_COUNT_HPP
#define BOOST_COMPUTE_ALGORITHM_COUNT_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/lambda.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/count_if.hpp>
#include <boost/compute/type_traits/vector_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -33,6 +36,7 @@ inline size_t count(InputIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
using ::boost::compute::_1;
diff --git a/boost/compute/algorithm/count_if.hpp b/boost/compute/algorithm/count_if.hpp
index 81996dc828..1a6865f758 100644
--- a/boost/compute/algorithm/count_if.hpp
+++ b/boost/compute/algorithm/count_if.hpp
@@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_ALGORITHM_COUNT_IF_HPP
#define BOOST_COMPUTE_ALGORITHM_COUNT_IF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/device.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
@@ -19,6 +21,7 @@
#include <boost/compute/algorithm/detail/count_if_with_threads.hpp>
#include <boost/compute/algorithm/detail/serial_count_if.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -34,6 +37,7 @@ inline size_t count_if(InputIterator first,
Predicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
const device &device = queue.get_device();
size_t input_size = detail::iterator_range_size(first, last);
diff --git a/boost/compute/algorithm/equal.hpp b/boost/compute/algorithm/equal.hpp
index c3c8053b71..8c8f25293a 100644
--- a/boost/compute/algorithm/equal.hpp
+++ b/boost/compute/algorithm/equal.hpp
@@ -11,9 +11,12 @@
#ifndef BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
#define BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/mismatch.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -28,6 +31,8 @@ inline bool equal(InputIterator1 first1,
InputIterator2 first2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
return ::boost::compute::mismatch(first1,
last1,
first2,
@@ -42,6 +47,8 @@ inline bool equal(InputIterator1 first1,
InputIterator2 last2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
if(std::distance(first1, last1) != std::distance(first2, last2)){
return false;
}
diff --git a/boost/compute/algorithm/equal_range.hpp b/boost/compute/algorithm/equal_range.hpp
index d7008e3cf4..6163e3c103 100644
--- a/boost/compute/algorithm/equal_range.hpp
+++ b/boost/compute/algorithm/equal_range.hpp
@@ -13,10 +13,13 @@
#include <utility>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/lower_bound.hpp>
#include <boost/compute/algorithm/upper_bound.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -32,6 +35,7 @@ equal_range(InputIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return std::make_pair(
::boost::compute::lower_bound(first, last, value, queue),
::boost::compute::upper_bound(first, last, value, queue)
diff --git a/boost/compute/algorithm/exclusive_scan.hpp b/boost/compute/algorithm/exclusive_scan.hpp
index 806a172cf4..f1059e406e 100644
--- a/boost/compute/algorithm/exclusive_scan.hpp
+++ b/boost/compute/algorithm/exclusive_scan.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_EXCLUSIVE_SCAN_HPP
#define BOOST_COMPUTE_ALGORITHM_EXCLUSIVE_SCAN_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/functional.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/scan.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -58,6 +61,8 @@ exclusive_scan(InputIterator first,
BinaryOperator binary_op,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
return detail::scan(first, last, result, true, init, binary_op, queue);
}
@@ -70,6 +75,8 @@ exclusive_scan(InputIterator first,
T init,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename
std::iterator_traits<OutputIterator>::value_type output_type;
@@ -86,6 +93,8 @@ exclusive_scan(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename
std::iterator_traits<OutputIterator>::value_type output_type;
diff --git a/boost/compute/algorithm/fill.hpp b/boost/compute/algorithm/fill.hpp
index 646d8acda4..87ca95cbe9 100644
--- a/boost/compute/algorithm/fill.hpp
+++ b/boost/compute/algorithm/fill.hpp
@@ -13,6 +13,7 @@
#include <iterator>
+#include <boost/static_assert.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/contains.hpp>
@@ -27,6 +28,8 @@
#include <boost/compute/iterator/discard_iterator.hpp>
#include <boost/compute/detail/is_buffer_iterator.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
+
namespace boost {
namespace compute {
@@ -280,6 +283,7 @@ inline void fill(BufferIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<BufferIterator>::value);
size_t count = detail::iterator_range_size(first, last);
if(count == 0){
return;
@@ -294,6 +298,7 @@ inline future<void> fill_async(BufferIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(detail::is_buffer_iterator<BufferIterator>::value);
size_t count = detail::iterator_range_size(first, last);
if(count == 0){
return future<void>();
diff --git a/boost/compute/algorithm/fill_n.hpp b/boost/compute/algorithm/fill_n.hpp
index 6be2d280a6..c1e913e2d6 100644
--- a/boost/compute/algorithm/fill_n.hpp
+++ b/boost/compute/algorithm/fill_n.hpp
@@ -11,9 +11,12 @@
#ifndef BOOST_COMPUTE_ALGORITHM_FILL_N_HPP
#define BOOST_COMPUTE_ALGORITHM_FILL_N_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/fill.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -29,6 +32,7 @@ inline void fill_n(BufferIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<BufferIterator>::value);
::boost::compute::fill(first, first + count, value, queue);
}
diff --git a/boost/compute/algorithm/find.hpp b/boost/compute/algorithm/find.hpp
index a6225b8c99..338b5af0c3 100644
--- a/boost/compute/algorithm/find.hpp
+++ b/boost/compute/algorithm/find.hpp
@@ -11,11 +11,14 @@
#ifndef BOOST_COMPUTE_ALGORITHM_FIND_HPP
#define BOOST_COMPUTE_ALGORITHM_FIND_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/lambda.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/find_if.hpp>
#include <boost/compute/type_traits/vector_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -30,6 +33,7 @@ inline InputIterator find(InputIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
using ::boost::compute::_1;
diff --git a/boost/compute/algorithm/find_end.hpp b/boost/compute/algorithm/find_end.hpp
index a0a1b2e8c9..35f0f418f8 100644
--- a/boost/compute/algorithm/find_end.hpp
+++ b/boost/compute/algorithm/find_end.hpp
@@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_ALGORITHM_FIND_END_HPP
#define BOOST_COMPUTE_ALGORITHM_FIND_END_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/algorithm/detail/search_all.hpp>
#include <boost/compute/container/detail/scalar.hpp>
@@ -18,6 +20,7 @@
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -99,6 +102,9 @@ inline TextIterator find_end(TextIterator t_first,
PatternIterator p_last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<TextIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<PatternIterator>::value);
+
const context &context = queue.get_context();
// there is no need to check if pattern starts at last n - 1 indices
diff --git a/boost/compute/algorithm/find_if.hpp b/boost/compute/algorithm/find_if.hpp
index 074b47e280..42aec79a98 100644
--- a/boost/compute/algorithm/find_if.hpp
+++ b/boost/compute/algorithm/find_if.hpp
@@ -11,9 +11,12 @@
#ifndef BOOST_COMPUTE_ALGORITHM_FIND_IF_HPP
#define BOOST_COMPUTE_ALGORITHM_FIND_IF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/find_if_with_atomics.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -28,6 +31,7 @@ inline InputIterator find_if(InputIterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return detail::find_if_with_atomics(first, last, predicate, queue);
}
diff --git a/boost/compute/algorithm/find_if_not.hpp b/boost/compute/algorithm/find_if_not.hpp
index a008a99469..08a8bd36ad 100644
--- a/boost/compute/algorithm/find_if_not.hpp
+++ b/boost/compute/algorithm/find_if_not.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_FIND_IF_NOT_HPP
#define BOOST_COMPUTE_ALGORITHM_FIND_IF_NOT_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/find_if.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -31,6 +34,7 @@ inline InputIterator find_if_not(InputIterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return ::boost::compute::find_if(
first,
last,
diff --git a/boost/compute/algorithm/for_each.hpp b/boost/compute/algorithm/for_each.hpp
index 7afba2b5f5..f571c2a5da 100644
--- a/boost/compute/algorithm/for_each.hpp
+++ b/boost/compute/algorithm/for_each.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_FOR_EACH_HPP
#define BOOST_COMPUTE_ALGORITHM_FOR_EACH_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -54,6 +57,8 @@ inline UnaryFunction for_each(InputIterator first,
UnaryFunction function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+
detail::for_each_kernel<InputIterator, UnaryFunction> kernel(first, last, function);
kernel.exec(queue);
diff --git a/boost/compute/algorithm/for_each_n.hpp b/boost/compute/algorithm/for_each_n.hpp
index 77932ab209..4fd981d952 100644
--- a/boost/compute/algorithm/for_each_n.hpp
+++ b/boost/compute/algorithm/for_each_n.hpp
@@ -11,7 +11,10 @@
#ifndef BOOST_COMPUTE_ALGORITHM_FOR_EACH_N_HPP
#define BOOST_COMPUTE_ALGORITHM_FOR_EACH_N_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/for_each.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -28,6 +31,7 @@ inline UnaryFunction for_each_n(InputIterator first,
UnaryFunction function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return ::boost::compute::for_each(first, first + count, function, queue);
}
diff --git a/boost/compute/algorithm/gather.hpp b/boost/compute/algorithm/gather.hpp
index 62442587f7..9d217837c3 100644
--- a/boost/compute/algorithm/gather.hpp
+++ b/boost/compute/algorithm/gather.hpp
@@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_ALGORITHM_GATHER_HPP
#define BOOST_COMPUTE_ALGORITHM_GATHER_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/command_queue.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
@@ -18,6 +20,7 @@
#include <boost/compute/iterator/buffer_iterator.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/type_traits/type_name.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -72,6 +75,10 @@ inline void gather(MapIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<MapIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
detail::gather_kernel<InputIterator, MapIterator, OutputIterator> kernel;
kernel.set_range(first, last, input, result);
diff --git a/boost/compute/algorithm/generate.hpp b/boost/compute/algorithm/generate.hpp
index 9ac76a3dca..7e096291a6 100644
--- a/boost/compute/algorithm/generate.hpp
+++ b/boost/compute/algorithm/generate.hpp
@@ -11,11 +11,14 @@
#ifndef BOOST_COMPUTE_ALGORITHM_GENERATE_HPP
#define BOOST_COMPUTE_ALGORITHM_GENERATE_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/iterator/function_input_iterator.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -30,6 +33,7 @@ inline void generate(OutputIterator first,
Generator generator,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
size_t count = detail::iterator_range_size(first, last);
if(count == 0){
return;
diff --git a/boost/compute/algorithm/includes.hpp b/boost/compute/algorithm/includes.hpp
index cfef9540a7..452ca64b7f 100644
--- a/boost/compute/algorithm/includes.hpp
+++ b/boost/compute/algorithm/includes.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/detail/balanced_path.hpp>
#include <boost/compute/algorithm/fill_n.hpp>
#include <boost/compute/algorithm/find.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/read_write_single_value.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -118,6 +121,9 @@ inline bool includes(InputIterator1 first1,
InputIterator2 last2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+
size_t tile_size = 1024;
size_t count1 = detail::iterator_range_size(first1, last1);
diff --git a/boost/compute/algorithm/inclusive_scan.hpp b/boost/compute/algorithm/inclusive_scan.hpp
index 84f1b8cbf7..428f174253 100644
--- a/boost/compute/algorithm/inclusive_scan.hpp
+++ b/boost/compute/algorithm/inclusive_scan.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_INCLUSIVE_SCAN_HPP
#define BOOST_COMPUTE_ALGORITHM_INCLUSIVE_SCAN_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/functional.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/scan.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -55,6 +58,8 @@ inclusive_scan(InputIterator first,
BinaryOperator binary_op,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename
std::iterator_traits<OutputIterator>::value_type output_type;
@@ -71,6 +76,8 @@ inclusive_scan(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename
std::iterator_traits<OutputIterator>::value_type output_type;
diff --git a/boost/compute/algorithm/inner_product.hpp b/boost/compute/algorithm/inner_product.hpp
index 0aeaf9110e..6cf7e81a6d 100644
--- a/boost/compute/algorithm/inner_product.hpp
+++ b/boost/compute/algorithm/inner_product.hpp
@@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_ALGORITHM_INNER_PRODUCT_HPP
#define BOOST_COMPUTE_ALGORITHM_INNER_PRODUCT_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/command_queue.hpp>
@@ -19,6 +21,7 @@
#include <boost/compute/iterator/transform_iterator.hpp>
#include <boost/compute/iterator/zip_iterator.hpp>
#include <boost/compute/functional/detail/unpack.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -36,6 +39,8 @@ inline T inner_product(InputIterator1 first1,
T init,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
typedef typename std::iterator_traits<InputIterator1>::value_type input_type;
ptrdiff_t n = std::distance(first1, last1);
@@ -72,6 +77,8 @@ inline T inner_product(InputIterator1 first1,
BinaryTransformFunction transform_function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
typedef typename std::iterator_traits<InputIterator1>::value_type value_type;
size_t count = detail::iterator_range_size(first1, last1);
diff --git a/boost/compute/algorithm/inplace_merge.hpp b/boost/compute/algorithm/inplace_merge.hpp
index 91f5be5335..7ed91b7905 100644
--- a/boost/compute/algorithm/inplace_merge.hpp
+++ b/boost/compute/algorithm/inplace_merge.hpp
@@ -13,10 +13,13 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/merge.hpp>
#include <boost/compute/container/vector.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -31,6 +34,7 @@ inline void inplace_merge(Iterator first,
Iterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
BOOST_ASSERT(first < middle && middle < last);
typedef typename std::iterator_traits<Iterator>::value_type T;
diff --git a/boost/compute/algorithm/iota.hpp b/boost/compute/algorithm/iota.hpp
index 4cd7aa9c7b..d0916500b5 100644
--- a/boost/compute/algorithm/iota.hpp
+++ b/boost/compute/algorithm/iota.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_IOTA_HPP
#define BOOST_COMPUTE_ALGORITHM_IOTA_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/iterator/counting_iterator.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -34,6 +37,7 @@ inline void iota(BufferIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<BufferIterator>::value);
T count = static_cast<T>(detail::iterator_range_size(first, last));
copy(
diff --git a/boost/compute/algorithm/is_partitioned.hpp b/boost/compute/algorithm/is_partitioned.hpp
index 6ad24f240f..f3c3789086 100644
--- a/boost/compute/algorithm/is_partitioned.hpp
+++ b/boost/compute/algorithm/is_partitioned.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_IS_PARTITIONED_HPP
#define BOOST_COMPUTE_ALGORITHM_IS_PARTITIONED_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/find_if.hpp>
#include <boost/compute/algorithm/find_if_not.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -29,6 +32,7 @@ inline bool is_partitioned(InputIterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return ::boost::compute::find_if(
::boost::compute::find_if_not(first,
last,
diff --git a/boost/compute/algorithm/is_permutation.hpp b/boost/compute/algorithm/is_permutation.hpp
index 88b89b7973..643009c307 100644
--- a/boost/compute/algorithm/is_permutation.hpp
+++ b/boost/compute/algorithm/is_permutation.hpp
@@ -13,12 +13,15 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/algorithm/equal.hpp>
#include <boost/compute/algorithm/sort.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -44,6 +47,8 @@ inline bool is_permutation(InputIterator1 first1,
InputIterator2 last2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
typedef typename std::iterator_traits<InputIterator1>::value_type value_type1;
typedef typename std::iterator_traits<InputIterator2>::value_type value_type2;
diff --git a/boost/compute/algorithm/is_sorted.hpp b/boost/compute/algorithm/is_sorted.hpp
index 7441620978..6159d8a57a 100644
--- a/boost/compute/algorithm/is_sorted.hpp
+++ b/boost/compute/algorithm/is_sorted.hpp
@@ -11,11 +11,14 @@
#ifndef BOOST_COMPUTE_ALGORITHM_IS_SORTED_HPP
#define BOOST_COMPUTE_ALGORITHM_IS_SORTED_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/command_queue.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/functional/bind.hpp>
#include <boost/compute/functional/operator.hpp>
#include <boost/compute/algorithm/adjacent_find.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -39,6 +42,7 @@ inline bool is_sorted(InputIterator first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
using ::boost::compute::placeholders::_1;
using ::boost::compute::placeholders::_2;
@@ -53,6 +57,7 @@ inline bool is_sorted(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
return ::boost::compute::is_sorted(
diff --git a/boost/compute/algorithm/lexicographical_compare.hpp b/boost/compute/algorithm/lexicographical_compare.hpp
index 952e678a68..a638ec44b3 100644
--- a/boost/compute/algorithm/lexicographical_compare.hpp
+++ b/boost/compute/algorithm/lexicographical_compare.hpp
@@ -8,12 +8,15 @@
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/context.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/any_of.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/utility/program_cache.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -113,6 +116,9 @@ inline bool lexicographical_compare(InputIterator1 first1,
InputIterator2 last2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+
return detail::dispatch_lexicographical_compare(first1, last1, first2, last2, queue);
}
diff --git a/boost/compute/algorithm/lower_bound.hpp b/boost/compute/algorithm/lower_bound.hpp
index f78bbd6364..a0b928157e 100644
--- a/boost/compute/algorithm/lower_bound.hpp
+++ b/boost/compute/algorithm/lower_bound.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_LOWER_BOUND_HPP
#define BOOST_COMPUTE_ALGORITHM_LOWER_BOUND_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/lambda.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/binary_find.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -32,6 +35,7 @@ lower_bound(InputIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
using ::boost::compute::_1;
InputIterator position =
diff --git a/boost/compute/algorithm/max_element.hpp b/boost/compute/algorithm/max_element.hpp
index f9df37420c..aa6fa1f674 100644
--- a/boost/compute/algorithm/max_element.hpp
+++ b/boost/compute/algorithm/max_element.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_MAX_ELEMENT_HPP
#define BOOST_COMPUTE_ALGORITHM_MAX_ELEMENT_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/algorithm/detail/find_extrema.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -54,6 +57,7 @@ max_element(InputIterator first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return detail::find_extrema(first, last, compare, false, queue);
}
@@ -64,6 +68,7 @@ max_element(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
return ::boost::compute::max_element(
diff --git a/boost/compute/algorithm/merge.hpp b/boost/compute/algorithm/merge.hpp
index ff3e6e879a..a2b7c3c2ae 100644
--- a/boost/compute/algorithm/merge.hpp
+++ b/boost/compute/algorithm/merge.hpp
@@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_ALGORITHM_MERGE_HPP
#define BOOST_COMPUTE_ALGORITHM_MERGE_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy.hpp>
@@ -18,6 +20,7 @@
#include <boost/compute/algorithm/detail/serial_merge.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/parameter_cache.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -52,6 +55,9 @@ inline OutputIterator merge(InputIterator1 first1,
Compare comp,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename std::iterator_traits<InputIterator1>::value_type input1_type;
typedef typename std::iterator_traits<InputIterator2>::value_type input2_type;
typedef typename std::iterator_traits<OutputIterator>::value_type output_type;
@@ -96,6 +102,9 @@ inline OutputIterator merge(InputIterator1 first1,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
typedef typename std::iterator_traits<InputIterator1>::value_type value_type;
less<value_type> less_than;
return merge(first1, last1, first2, last2, result, less_than, queue);
diff --git a/boost/compute/algorithm/min_element.hpp b/boost/compute/algorithm/min_element.hpp
index b52e2670cb..18ba8ffd06 100644
--- a/boost/compute/algorithm/min_element.hpp
+++ b/boost/compute/algorithm/min_element.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_MIN_ELEMENT_HPP
#define BOOST_COMPUTE_ALGORITHM_MIN_ELEMENT_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/algorithm/detail/find_extrema.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -54,6 +57,7 @@ min_element(InputIterator first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return detail::find_extrema(first, last, compare, true, queue);
}
@@ -64,6 +68,7 @@ min_element(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
return ::boost::compute::min_element(
diff --git a/boost/compute/algorithm/minmax_element.hpp b/boost/compute/algorithm/minmax_element.hpp
index 4b2aae6dee..ab1614f3fa 100644
--- a/boost/compute/algorithm/minmax_element.hpp
+++ b/boost/compute/algorithm/minmax_element.hpp
@@ -13,10 +13,13 @@
#include <utility>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/max_element.hpp>
#include <boost/compute/algorithm/min_element.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -42,6 +45,7 @@ minmax_element(InputIterator first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
if(first == last){
// empty range
return std::make_pair(first, first);
@@ -58,6 +62,7 @@ minmax_element(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
if(first == last){
// empty range
return std::make_pair(first, first);
diff --git a/boost/compute/algorithm/mismatch.hpp b/boost/compute/algorithm/mismatch.hpp
index ff31f49f97..98b9a4d037 100644
--- a/boost/compute/algorithm/mismatch.hpp
+++ b/boost/compute/algorithm/mismatch.hpp
@@ -14,6 +14,8 @@
#include <iterator>
#include <utility>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/command_queue.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/iterator/transform_iterator.hpp>
#include <boost/compute/iterator/zip_iterator.hpp>
#include <boost/compute/functional/detail/unpack.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -37,6 +40,8 @@ mismatch(InputIterator1 first1,
InputIterator2 first2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
typedef typename std::iterator_traits<InputIterator1>::value_type value_type;
::boost::compute::equal_to<value_type> op;
@@ -75,6 +80,8 @@ mismatch(InputIterator1 first1,
InputIterator2 last2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
if(std::distance(first1, last1) < std::distance(first2, last2)){
return ::boost::compute::mismatch(first1, last1, first2, queue);
}
diff --git a/boost/compute/algorithm/next_permutation.hpp b/boost/compute/algorithm/next_permutation.hpp
index 061ea1efe9..1816174ec3 100644
--- a/boost/compute/algorithm/next_permutation.hpp
+++ b/boost/compute/algorithm/next_permutation.hpp
@@ -13,10 +13,13 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/container/detail/scalar.hpp>
#include <boost/compute/algorithm/reverse.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -137,6 +140,7 @@ inline bool next_permutation(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
if(first == last) return false;
diff --git a/boost/compute/algorithm/none_of.hpp b/boost/compute/algorithm/none_of.hpp
index fc3ed94bc1..192f5c38b0 100644
--- a/boost/compute/algorithm/none_of.hpp
+++ b/boost/compute/algorithm/none_of.hpp
@@ -11,8 +11,11 @@
#ifndef BOOST_COMPUTE_ALGORITHM_NONE_OF_HPP
#define BOOST_COMPUTE_ALGORITHM_NONE_OF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/find_if.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -29,6 +32,7 @@ inline bool none_of(InputIterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return ::boost::compute::find_if(first, last, predicate, queue) == last;
}
diff --git a/boost/compute/algorithm/nth_element.hpp b/boost/compute/algorithm/nth_element.hpp
index 93344271dd..f55f1a2f99 100644
--- a/boost/compute/algorithm/nth_element.hpp
+++ b/boost/compute/algorithm/nth_element.hpp
@@ -11,12 +11,15 @@
#ifndef BOOST_COMPUTE_ALGORITHM_NTH_ELEMENT_HPP
#define BOOST_COMPUTE_ALGORITHM_NTH_ELEMENT_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/fill_n.hpp>
#include <boost/compute/algorithm/find.hpp>
#include <boost/compute/algorithm/partition.hpp>
#include <boost/compute/algorithm/sort.hpp>
#include <boost/compute/functional/bind.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -32,6 +35,7 @@ inline void nth_element(Iterator first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
if(nth == last) return;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
@@ -74,6 +78,7 @@ inline void nth_element(Iterator first,
Iterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
if(nth == last) return;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
diff --git a/boost/compute/algorithm/partial_sum.hpp b/boost/compute/algorithm/partial_sum.hpp
index 53d36a9db0..1af3b8dbc9 100644
--- a/boost/compute/algorithm/partial_sum.hpp
+++ b/boost/compute/algorithm/partial_sum.hpp
@@ -11,9 +11,12 @@
#ifndef BOOST_COMPUTE_ALGORITHM_PARTIAL_SUM_HPP
#define BOOST_COMPUTE_ALGORITHM_PARTIAL_SUM_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/inclusive_scan.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -32,6 +35,8 @@ partial_sum(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
return ::boost::compute::inclusive_scan(first, last, result, queue);
}
diff --git a/boost/compute/algorithm/partition.hpp b/boost/compute/algorithm/partition.hpp
index 59d0c78f7e..f5a5429ac4 100644
--- a/boost/compute/algorithm/partition.hpp
+++ b/boost/compute/algorithm/partition.hpp
@@ -11,9 +11,12 @@
#ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_HPP
#define BOOST_COMPUTE_ALGORITHM_PARTITION_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/stable_partition.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -32,6 +35,7 @@ inline Iterator partition(Iterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
return stable_partition(first, last, predicate, queue);
}
diff --git a/boost/compute/algorithm/partition_copy.hpp b/boost/compute/algorithm/partition_copy.hpp
index 3215ec0736..b90fa7a581 100644
--- a/boost/compute/algorithm/partition_copy.hpp
+++ b/boost/compute/algorithm/partition_copy.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
#define BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy_if.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -39,6 +42,10 @@ partition_copy(InputIterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator2>::value);
+
// copy true values
OutputIterator1 last_true =
::boost::compute::copy_if(first,
diff --git a/boost/compute/algorithm/partition_point.hpp b/boost/compute/algorithm/partition_point.hpp
index 748824512d..a9f25ebbf4 100644
--- a/boost/compute/algorithm/partition_point.hpp
+++ b/boost/compute/algorithm/partition_point.hpp
@@ -11,9 +11,12 @@
#ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_POINT_HPP
#define BOOST_COMPUTE_ALGORITHM_PARTITION_POINT_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/binary_find.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -35,10 +38,11 @@ namespace compute {
///
template<class InputIterator, class UnaryPredicate>
inline InputIterator partition_point(InputIterator first,
- InputIterator last,
- UnaryPredicate predicate,
- command_queue &queue = system::default_queue())
+ InputIterator last,
+ UnaryPredicate predicate,
+ command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
return detail::binary_find(first, last, not1(predicate), queue);
}
diff --git a/boost/compute/algorithm/prev_permutation.hpp b/boost/compute/algorithm/prev_permutation.hpp
index ea20835caa..268b99b798 100644
--- a/boost/compute/algorithm/prev_permutation.hpp
+++ b/boost/compute/algorithm/prev_permutation.hpp
@@ -13,10 +13,13 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/container/detail/scalar.hpp>
#include <boost/compute/algorithm/reverse.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -137,6 +140,7 @@ inline bool prev_permutation(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
if(first == last) return false;
diff --git a/boost/compute/algorithm/random_shuffle.hpp b/boost/compute/algorithm/random_shuffle.hpp
index 8e020830a5..7405c17374 100644
--- a/boost/compute/algorithm/random_shuffle.hpp
+++ b/boost/compute/algorithm/random_shuffle.hpp
@@ -14,6 +14,11 @@
#include <vector>
#include <algorithm>
+#ifdef BOOST_COMPUTE_USE_CPP11
+#include <random>
+#endif
+
+#include <boost/static_assert.hpp>
#include <boost/range/algorithm_ext/iota.hpp>
#include <boost/compute/system.hpp>
@@ -22,6 +27,7 @@
#include <boost/compute/container/vector.hpp>
#include <boost/compute/algorithm/scatter.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -36,6 +42,7 @@ inline void random_shuffle(Iterator first,
Iterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
size_t count = detail::iterator_range_size(first, last);
@@ -46,7 +53,13 @@ inline void random_shuffle(Iterator first,
// generate shuffled indices on the host
std::vector<cl_uint> random_indices(count);
boost::iota(random_indices, 0);
+#ifdef BOOST_COMPUTE_USE_CPP11
+ std::random_device nondeterministic_randomness;
+ std::default_random_engine random_engine(nondeterministic_randomness());
+ std::shuffle(random_indices.begin(), random_indices.end(), random_engine);
+#else
std::random_shuffle(random_indices.begin(), random_indices.end());
+#endif
// copy random indices to the device
const context &context = queue.get_context();
diff --git a/boost/compute/algorithm/reduce.hpp b/boost/compute/algorithm/reduce.hpp
index e71d90fe24..a794cea495 100644
--- a/boost/compute/algorithm/reduce.hpp
+++ b/boost/compute/algorithm/reduce.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
@@ -26,6 +28,7 @@
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/memory/local_buffer.hpp>
#include <boost/compute/type_traits/result_of.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -276,6 +279,7 @@ inline void reduce(InputIterator first,
BinaryFunction function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
if(first == last){
return;
}
@@ -290,6 +294,7 @@ inline void reduce(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type T;
if(first == last){
diff --git a/boost/compute/algorithm/reduce_by_key.hpp b/boost/compute/algorithm/reduce_by_key.hpp
index 1a233c7dd4..20dbc6bf9d 100644
--- a/boost/compute/algorithm/reduce_by_key.hpp
+++ b/boost/compute/algorithm/reduce_by_key.hpp
@@ -14,11 +14,14 @@
#include <iterator>
#include <utility>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/command_queue.hpp>
#include <boost/compute/device.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/detail/reduce_by_key.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -68,6 +71,11 @@ reduce_by_key(InputKeyIterator keys_first,
BinaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputKeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputValueIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputKeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputValueIterator>::value);
+
return detail::dispatch_reduce_by_key(keys_first, keys_last, values_first,
keys_result, values_result,
function, predicate,
@@ -87,6 +95,10 @@ reduce_by_key(InputKeyIterator keys_first,
BinaryFunction function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputKeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputValueIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputKeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputValueIterator>::value);
typedef typename std::iterator_traits<InputKeyIterator>::value_type key_type;
return reduce_by_key(keys_first, keys_last, values_first,
@@ -106,6 +118,10 @@ reduce_by_key(InputKeyIterator keys_first,
OutputValueIterator values_result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputKeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputValueIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputKeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputValueIterator>::value);
typedef typename std::iterator_traits<InputKeyIterator>::value_type key_type;
typedef typename std::iterator_traits<InputValueIterator>::value_type value_type;
diff --git a/boost/compute/algorithm/remove.hpp b/boost/compute/algorithm/remove.hpp
index 086ba8cc7f..5c92db3c2f 100644
--- a/boost/compute/algorithm/remove.hpp
+++ b/boost/compute/algorithm/remove.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_REMOVE_HPP
#define BOOST_COMPUTE_ALGORITHM_REMOVE_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/lambda.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/remove_if.hpp>
#include <boost/compute/type_traits/vector_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -31,6 +34,7 @@ inline Iterator remove(Iterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
using ::boost::compute::_1;
diff --git a/boost/compute/algorithm/remove_if.hpp b/boost/compute/algorithm/remove_if.hpp
index 9aece18bbd..a0e45d0c51 100644
--- a/boost/compute/algorithm/remove_if.hpp
+++ b/boost/compute/algorithm/remove_if.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_REMOVE_IF_HPP
#define BOOST_COMPUTE_ALGORITHM_REMOVE_IF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/copy_if.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/functional/logical.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -31,6 +34,7 @@ inline Iterator remove_if(Iterator first,
Predicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
// temporary storage for the input data
diff --git a/boost/compute/algorithm/replace.hpp b/boost/compute/algorithm/replace.hpp
index 336c1d3e0f..7eb4b7d874 100644
--- a/boost/compute/algorithm/replace.hpp
+++ b/boost/compute/algorithm/replace.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_REPLACE_HPP
#define BOOST_COMPUTE_ALGORITHM_REPLACE_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -77,6 +80,7 @@ inline void replace(Iterator first,
const T &new_value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
detail::replace_kernel<Iterator, T> kernel;
kernel.set_range(first, last);
diff --git a/boost/compute/algorithm/replace_copy.hpp b/boost/compute/algorithm/replace_copy.hpp
index 34f61b514f..3979ff295a 100644
--- a/boost/compute/algorithm/replace_copy.hpp
+++ b/boost/compute/algorithm/replace_copy.hpp
@@ -13,10 +13,13 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/algorithm/replace.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -37,6 +40,9 @@ replace_copy(InputIterator first,
const T &new_value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<OutputIterator>::difference_type difference_type;
difference_type count = std::distance(first, last);
diff --git a/boost/compute/algorithm/reverse.hpp b/boost/compute/algorithm/reverse.hpp
index 15fe5533ac..9aadfbb0f6 100644
--- a/boost/compute/algorithm/reverse.hpp
+++ b/boost/compute/algorithm/reverse.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_REVERSE_HPP
#define BOOST_COMPUTE_ALGORITHM_REVERSE_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -60,6 +63,7 @@ inline void reverse(Iterator first,
Iterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
size_t count = detail::iterator_range_size(first, last);
if(count < 2){
return;
diff --git a/boost/compute/algorithm/reverse_copy.hpp b/boost/compute/algorithm/reverse_copy.hpp
index 9fda9d4e27..c27cc24311 100644
--- a/boost/compute/algorithm/reverse_copy.hpp
+++ b/boost/compute/algorithm/reverse_copy.hpp
@@ -13,10 +13,13 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/algorithm/reverse.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -61,6 +64,9 @@ reverse_copy(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<OutputIterator>::difference_type difference_type;
difference_type count = std::distance(first, last);
diff --git a/boost/compute/algorithm/scatter.hpp b/boost/compute/algorithm/scatter.hpp
index 8ae5a99443..934d72797b 100644
--- a/boost/compute/algorithm/scatter.hpp
+++ b/boost/compute/algorithm/scatter.hpp
@@ -11,6 +11,7 @@
#ifndef BOOST_COMPUTE_ALGORITHM_SCATTER_HPP
#define BOOST_COMPUTE_ALGORITHM_SCATTER_HPP
+#include <boost/static_assert.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/compute/system.hpp>
@@ -20,6 +21,7 @@
#include <boost/compute/type_traits/type_name.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -89,6 +91,10 @@ inline void scatter(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<MapIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
detail::scatter_kernel<InputIterator, MapIterator, OutputIterator> kernel;
kernel.set_range(first, last, map, result);
diff --git a/boost/compute/algorithm/scatter_if.hpp b/boost/compute/algorithm/scatter_if.hpp
index c7db51d3be..e4b6dbb3cb 100644
--- a/boost/compute/algorithm/scatter_if.hpp
+++ b/boost/compute/algorithm/scatter_if.hpp
@@ -11,6 +11,7 @@
#ifndef BOOST_COMPUTE_ALGORITHM_SCATTER_IF_HPP
#define BOOST_COMPUTE_ALGORITHM_SCATTER_IF_HPP
+#include <boost/static_assert.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/compute/system.hpp>
@@ -20,6 +21,7 @@
#include <boost/compute/type_traits/type_name.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -94,6 +96,11 @@ inline void scatter_if(InputIterator first,
Predicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<MapIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<StencilIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
detail::scatter_if_kernel<InputIterator, MapIterator, StencilIterator, OutputIterator, Predicate> kernel;
kernel.set_range(first, last, map, stencil, result, predicate);
@@ -108,6 +115,11 @@ inline void scatter_if(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<MapIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<StencilIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<StencilIterator>::value_type T;
scatter_if(first, last, map, stencil, result, identity<T>(), queue);
diff --git a/boost/compute/algorithm/search.hpp b/boost/compute/algorithm/search.hpp
index a1f3dece62..72bbf5efa8 100644
--- a/boost/compute/algorithm/search.hpp
+++ b/boost/compute/algorithm/search.hpp
@@ -11,12 +11,15 @@
#ifndef BOOST_COMPUTE_ALGORITHM_SEARCH_HPP
#define BOOST_COMPUTE_ALGORITHM_SEARCH_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/detail/search_all.hpp>
#include <boost/compute/algorithm/find.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -42,6 +45,9 @@ inline TextIterator search(TextIterator t_first,
PatternIterator p_last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<TextIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<PatternIterator>::value);
+
// there is no need to check if pattern starts at last n - 1 indices
vector<uint_> matching_indices(
detail::iterator_range_size(t_first, t_last)
diff --git a/boost/compute/algorithm/search_n.hpp b/boost/compute/algorithm/search_n.hpp
index 86ff64dfd9..4b251f83eb 100644
--- a/boost/compute/algorithm/search_n.hpp
+++ b/boost/compute/algorithm/search_n.hpp
@@ -13,11 +13,14 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/find.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -110,6 +113,8 @@ inline TextIterator search_n(TextIterator t_first,
ValueType value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<TextIterator>::value);
+
// there is no need to check if pattern starts at last n - 1 indices
vector<uint_> matching_indices(
detail::iterator_range_size(t_first, t_last) + 1 - n,
diff --git a/boost/compute/algorithm/set_difference.hpp b/boost/compute/algorithm/set_difference.hpp
index 85a846ba13..f48792c318 100644
--- a/boost/compute/algorithm/set_difference.hpp
+++ b/boost/compute/algorithm/set_difference.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/detail/compact.hpp>
#include <boost/compute/algorithm/detail/balanced_path.hpp>
#include <boost/compute/algorithm/exclusive_scan.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -132,6 +135,10 @@ inline OutputIterator set_difference(InputIterator1 first1,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<InputIterator1>::value_type value_type;
int tile_size = 1024;
diff --git a/boost/compute/algorithm/set_intersection.hpp b/boost/compute/algorithm/set_intersection.hpp
index 74d46f57c6..dd91e93c99 100644
--- a/boost/compute/algorithm/set_intersection.hpp
+++ b/boost/compute/algorithm/set_intersection.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/detail/compact.hpp>
#include <boost/compute/algorithm/detail/balanced_path.hpp>
#include <boost/compute/algorithm/exclusive_scan.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -120,6 +123,10 @@ inline OutputIterator set_intersection(InputIterator1 first1,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<InputIterator1>::value_type value_type;
int tile_size = 1024;
diff --git a/boost/compute/algorithm/set_symmetric_difference.hpp b/boost/compute/algorithm/set_symmetric_difference.hpp
index 34d280daa3..657b0365cc 100644
--- a/boost/compute/algorithm/set_symmetric_difference.hpp
+++ b/boost/compute/algorithm/set_symmetric_difference.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/detail/compact.hpp>
#include <boost/compute/algorithm/detail/balanced_path.hpp>
#include <boost/compute/algorithm/exclusive_scan.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -144,6 +147,10 @@ set_symmetric_difference(InputIterator1 first1,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<InputIterator1>::value_type value_type;
int tile_size = 1024;
diff --git a/boost/compute/algorithm/set_union.hpp b/boost/compute/algorithm/set_union.hpp
index 6b405a0905..9296e0707a 100644
--- a/boost/compute/algorithm/set_union.hpp
+++ b/boost/compute/algorithm/set_union.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/algorithm/detail/balanced_path.hpp>
#include <boost/compute/algorithm/detail/compact.hpp>
#include <boost/compute/algorithm/exclusive_scan.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/system.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -145,6 +148,10 @@ inline OutputIterator set_union(InputIterator1 first1,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<InputIterator1>::value_type value_type;
int tile_size = 1024;
diff --git a/boost/compute/algorithm/sort_by_key.hpp b/boost/compute/algorithm/sort_by_key.hpp
index fdd2d1c481..bbb21b204b 100644
--- a/boost/compute/algorithm/sort_by_key.hpp
+++ b/boost/compute/algorithm/sort_by_key.hpp
@@ -13,6 +13,7 @@
#include <iterator>
+#include <boost/static_assert.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/compute/system.hpp>
@@ -23,10 +24,10 @@
#include <boost/compute/algorithm/detail/radix_sort.hpp>
#include <boost/compute/algorithm/reverse.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
-
namespace detail {
template<class KeyIterator, class ValueIterator>
@@ -138,6 +139,8 @@ inline void sort_by_key(KeyIterator keys_first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<KeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<ValueIterator>::value);
::boost::compute::detail::dispatch_sort_by_key(
keys_first, keys_last, values_first, compare, queue
);
@@ -150,6 +153,8 @@ inline void sort_by_key(KeyIterator keys_first,
ValueIterator values_first,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<KeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<ValueIterator>::value);
typedef typename std::iterator_traits<KeyIterator>::value_type key_type;
::boost::compute::sort_by_key(
diff --git a/boost/compute/algorithm/stable_partition.hpp b/boost/compute/algorithm/stable_partition.hpp
index 2b07f034b9..e43e8a607b 100644
--- a/boost/compute/algorithm/stable_partition.hpp
+++ b/boost/compute/algorithm/stable_partition.hpp
@@ -11,12 +11,15 @@
#ifndef BOOST_COMPUTE_ALGORITHM_STABLE_PARTITION_HPP
#define BOOST_COMPUTE_ALGORITHM_STABLE_PARTITION_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/context.hpp>
#include <boost/compute/functional.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy_if.hpp>
#include <boost/compute/container/vector.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -43,6 +46,7 @@ inline Iterator stable_partition(Iterator first,
UnaryPredicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
// make temporary copy of the input
diff --git a/boost/compute/algorithm/stable_sort.hpp b/boost/compute/algorithm/stable_sort.hpp
index 0857d75dc9..f5bb9a682b 100644
--- a/boost/compute/algorithm/stable_sort.hpp
+++ b/boost/compute/algorithm/stable_sort.hpp
@@ -13,6 +13,8 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/merge_sort_on_cpu.hpp>
@@ -22,6 +24,7 @@
#include <boost/compute/algorithm/reverse.hpp>
#include <boost/compute/functional/operator.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -81,6 +84,8 @@ inline void stable_sort(Iterator first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
+
if(queue.get_device().type() & device::gpu) {
::boost::compute::detail::dispatch_gpu_stable_sort(
first, last, compare, queue
@@ -96,6 +101,7 @@ inline void stable_sort(Iterator first,
Iterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
::boost::compute::less<value_type> less;
diff --git a/boost/compute/algorithm/stable_sort_by_key.hpp b/boost/compute/algorithm/stable_sort_by_key.hpp
index ce8811ef19..876019f905 100644
--- a/boost/compute/algorithm/stable_sort_by_key.hpp
+++ b/boost/compute/algorithm/stable_sort_by_key.hpp
@@ -13,10 +13,13 @@
#include <iterator>
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/sort_by_key.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -136,6 +139,8 @@ inline void stable_sort_by_key(KeyIterator keys_first,
Compare compare,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<KeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<ValueIterator>::value);
::boost::compute::detail::dispatch_ssort_by_key(
keys_first, keys_last, values_first, compare, queue
);
@@ -148,6 +153,8 @@ inline void stable_sort_by_key(KeyIterator keys_first,
ValueIterator values_first,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<KeyIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<ValueIterator>::value);
typedef typename std::iterator_traits<KeyIterator>::value_type key_type;
::boost::compute::stable_sort_by_key(
diff --git a/boost/compute/algorithm/swap_ranges.hpp b/boost/compute/algorithm/swap_ranges.hpp
index a706df7a61..8a270d339b 100644
--- a/boost/compute/algorithm/swap_ranges.hpp
+++ b/boost/compute/algorithm/swap_ranges.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_SWAP_RANGES_HPP
#define BOOST_COMPUTE_ALGORITHM_SWAP_RANGES_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/container/vector.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -29,6 +32,9 @@ inline Iterator2 swap_ranges(Iterator1 first1,
Iterator2 first2,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<Iterator2>::value);
+
typedef typename std::iterator_traits<Iterator1>::value_type value_type;
Iterator2 last2 = first2 + std::distance(first1, last1);
diff --git a/boost/compute/algorithm/transform.hpp b/boost/compute/algorithm/transform.hpp
index 9137604d55..2e4900b42c 100644
--- a/boost/compute/algorithm/transform.hpp
+++ b/boost/compute/algorithm/transform.hpp
@@ -11,12 +11,15 @@
#ifndef BOOST_COMPUTE_ALGORITHM_TRANSFORM_HPP
#define BOOST_COMPUTE_ALGORITHM_TRANSFORM_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/copy.hpp>
#include <boost/compute/iterator/transform_iterator.hpp>
#include <boost/compute/iterator/zip_iterator.hpp>
#include <boost/compute/functional/detail/unpack.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -39,6 +42,8 @@ inline OutputIterator transform(InputIterator first,
UnaryOperator op,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
return copy(
::boost::compute::make_transform_iterator(first, op),
::boost::compute::make_transform_iterator(last, op),
@@ -59,13 +64,17 @@ inline OutputIterator transform(InputIterator1 first1,
BinaryOperator op,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<InputIterator1>::difference_type difference_type;
difference_type n = std::distance(first1, last1);
return transform(
- make_zip_iterator(boost::make_tuple(first1, first2)),
- make_zip_iterator(boost::make_tuple(last1, first2 + n)),
+ ::boost::compute::make_zip_iterator(boost::make_tuple(first1, first2)),
+ ::boost::compute::make_zip_iterator(boost::make_tuple(last1, first2 + n)),
result,
detail::unpack(op),
queue
diff --git a/boost/compute/algorithm/transform_if.hpp b/boost/compute/algorithm/transform_if.hpp
index 9a98102d27..1f85720195 100644
--- a/boost/compute/algorithm/transform_if.hpp
+++ b/boost/compute/algorithm/transform_if.hpp
@@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_ALGORITHM_TRANSFORM_IF_HPP
#define BOOST_COMPUTE_ALGORITHM_TRANSFORM_IF_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/cl.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/iterator/discard_iterator.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -107,6 +110,8 @@ inline OutputIterator transform_if(InputIterator first,
Predicate predicate,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
return detail::transform_if_impl(
first, last, result, function, predicate, false, queue
);
diff --git a/boost/compute/algorithm/transform_reduce.hpp b/boost/compute/algorithm/transform_reduce.hpp
index a59a76aefd..e4e0f715a3 100644
--- a/boost/compute/algorithm/transform_reduce.hpp
+++ b/boost/compute/algorithm/transform_reduce.hpp
@@ -11,12 +11,15 @@
#ifndef BOOST_COMPUTE_ALGORITHM_TRANSFORM_REDUCE_HPP
#define BOOST_COMPUTE_ALGORITHM_TRANSFORM_REDUCE_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/reduce.hpp>
#include <boost/compute/iterator/transform_iterator.hpp>
#include <boost/compute/iterator/zip_iterator.hpp>
#include <boost/compute/functional/detail/unpack.hpp>
#include <boost/compute/detail/iterator_range_size.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -45,6 +48,7 @@ inline void transform_reduce(InputIterator first,
BinaryReduceFunction reduce_function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
::boost::compute::reduce(
::boost::compute::make_transform_iterator(first, transform_function),
::boost::compute::make_transform_iterator(last, transform_function),
@@ -68,6 +72,10 @@ inline void transform_reduce(InputIterator1 first1,
BinaryReduceFunction reduce_function,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<InputIterator1>::difference_type difference_type;
difference_type n = std::distance(first1, last1);
diff --git a/boost/compute/algorithm/unique.hpp b/boost/compute/algorithm/unique.hpp
index 8b7e2a0d0d..2d5cf1e409 100644
--- a/boost/compute/algorithm/unique.hpp
+++ b/boost/compute/algorithm/unique.hpp
@@ -11,11 +11,14 @@
#ifndef BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP
#define BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/unique_copy.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/functional/operator.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -40,6 +43,7 @@ inline InputIterator unique(InputIterator first,
BinaryPredicate op,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
vector<value_type> temp(first, last, queue);
@@ -55,6 +59,7 @@ inline InputIterator unique(InputIterator first,
InputIterator last,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
return ::boost::compute::unique(
diff --git a/boost/compute/algorithm/unique_copy.hpp b/boost/compute/algorithm/unique_copy.hpp
index d5fffd4ff9..4335b16de0 100644
--- a/boost/compute/algorithm/unique_copy.hpp
+++ b/boost/compute/algorithm/unique_copy.hpp
@@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_ALGORITHM_UNIQUE_COPY_HPP
#define BOOST_COMPUTE_ALGORITHM_UNIQUE_COPY_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/command_queue.hpp>
#include <boost/compute/lambda.hpp>
#include <boost/compute/system.hpp>
@@ -21,6 +23,7 @@
#include <boost/compute/detail/iterator_range_size.hpp>
#include <boost/compute/detail/meta_kernel.hpp>
#include <boost/compute/functional/operator.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -137,6 +140,9 @@ inline OutputIterator unique_copy(InputIterator first,
BinaryPredicate op,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
size_t count = detail::iterator_range_size(first, last);
if(count < 32){
return detail::serial_unique_copy(first, last, result, op, queue);
@@ -153,6 +159,9 @@ inline OutputIterator unique_copy(InputIterator first,
OutputIterator result,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
+ BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
+
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
return ::boost::compute::unique_copy(
diff --git a/boost/compute/algorithm/upper_bound.hpp b/boost/compute/algorithm/upper_bound.hpp
index f592c79b9a..37fa283bfb 100644
--- a/boost/compute/algorithm/upper_bound.hpp
+++ b/boost/compute/algorithm/upper_bound.hpp
@@ -11,10 +11,13 @@
#ifndef BOOST_COMPUTE_ALGORITHM_UPPER_BOUND_HPP
#define BOOST_COMPUTE_ALGORITHM_UPPER_BOUND_HPP
+#include <boost/static_assert.hpp>
+
#include <boost/compute/lambda.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/algorithm/detail/binary_find.hpp>
+#include <boost/compute/type_traits/is_device_iterator.hpp>
namespace boost {
namespace compute {
@@ -31,6 +34,7 @@ upper_bound(InputIterator first,
const T &value,
command_queue &queue = system::default_queue())
{
+ BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
using ::boost::compute::_1;
InputIterator position =