File indexing completed on 2025-01-18 09:29:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_GENERATE_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_GENERATE_HPP
0013
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/compute/system.hpp>
0017 #include <boost/compute/command_queue.hpp>
0018 #include <boost/compute/algorithm/copy.hpp>
0019 #include <boost/compute/iterator/function_input_iterator.hpp>
0020 #include <boost/compute/detail/iterator_range_size.hpp>
0021 #include <boost/compute/type_traits/is_device_iterator.hpp>
0022
0023 namespace boost {
0024 namespace compute {
0025
0026
0027
0028
0029
0030 template<class OutputIterator, class Generator>
0031 inline void generate(OutputIterator first,
0032 OutputIterator last,
0033 Generator generator,
0034 command_queue &queue = system::default_queue())
0035 {
0036 BOOST_STATIC_ASSERT(is_device_iterator<OutputIterator>::value);
0037 size_t count = detail::iterator_range_size(first, last);
0038 if(count == 0){
0039 return;
0040 }
0041
0042 ::boost::compute::copy(
0043 ::boost::compute::make_function_input_iterator(generator,
0044 first.get_index()),
0045 ::boost::compute::make_function_input_iterator(generator,
0046 last.get_index()),
0047 first,
0048 queue
0049 );
0050 }
0051
0052 }
0053 }
0054
0055 #endif