]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | //---------------------------------------------------------------------------// |
2 | // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com> | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0 | |
5 | // See accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt | |
7 | // | |
8 | // See http://boostorg.github.com/compute for more information. | |
9 | //---------------------------------------------------------------------------// | |
10 | ||
11 | #ifndef BOOST_COMPUTE_ALGORITHM_COPY_N_HPP | |
12 | #define BOOST_COMPUTE_ALGORITHM_COPY_N_HPP | |
13 | ||
14 | #include <boost/compute/system.hpp> | |
15 | #include <boost/compute/command_queue.hpp> | |
16 | #include <boost/compute/algorithm/copy.hpp> | |
17 | ||
18 | namespace boost { | |
19 | namespace compute { | |
20 | ||
21 | /// Copies \p count elements from \p first to \p result. | |
22 | /// | |
23 | /// For example, to copy four values from the host to the device: | |
24 | /// \code | |
25 | /// // values on the host and vector on the device | |
26 | /// float values[4] = { 1.f, 2.f, 3.f, 4.f }; | |
27 | /// boost::compute::vector<float> vec(4, context); | |
28 | /// | |
29 | /// // copy from the host to the device | |
30 | /// boost::compute::copy_n(values, 4, vec.begin(), queue); | |
31 | /// \endcode | |
32 | /// | |
33 | /// \see copy() | |
34 | template<class InputIterator, class Size, class OutputIterator> | |
35 | inline OutputIterator copy_n(InputIterator first, | |
36 | Size count, | |
37 | OutputIterator result, | |
38 | command_queue &queue = system::default_queue()) | |
39 | { | |
40 | typedef typename std::iterator_traits<InputIterator>::difference_type difference_type; | |
41 | ||
42 | return ::boost::compute::copy(first, | |
43 | first + static_cast<difference_type>(count), | |
44 | result, | |
45 | queue); | |
46 | } | |
47 | ||
48 | } // end compute namespace | |
49 | } // end boost namespace | |
50 | ||
51 | #endif // BOOST_COMPUTE_ALGORITHM_COPY_N_HPP |