]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/include/boost/compute/algorithm/exclusive_scan.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / algorithm / exclusive_scan.hpp
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_EXCLUSIVE_SCAN_HPP
12 #define BOOST_COMPUTE_ALGORITHM_EXCLUSIVE_SCAN_HPP
13
14 #include <boost/compute/functional.hpp>
15 #include <boost/compute/system.hpp>
16 #include <boost/compute/command_queue.hpp>
17 #include <boost/compute/algorithm/detail/scan.hpp>
18
19 namespace boost {
20 namespace compute {
21
22 /// Performs an exclusive scan of the elements in the range [\p first, \p last)
23 /// and stores the results in the range beginning at \p result.
24 ///
25 /// Each element in the output is assigned to the sum of all the previous
26 /// values in the input.
27 ///
28 /// \param first first element in the range to scan
29 /// \param last last element in the range to scan
30 /// \param result first element in the result range
31 /// \param init value used to initialize the scan sequence
32 /// \param binary_op associative binary operator
33 /// \param queue command queue to perform the operation
34 ///
35 /// \return \c OutputIterator to the end of the result range
36 ///
37 /// The default operation is to add the elements up.
38 ///
39 /// \snippet test/test_scan.cpp exclusive_scan_int
40 ///
41 /// But different associative operation can be specified as \p binary_op
42 /// instead (e.g., multiplication, maximum, minimum). Also value used to
43 /// initialized the scan sequence can be specified.
44 ///
45 /// \snippet test/test_scan.cpp exclusive_scan_int_multiplies
46 ///
47 /// \see inclusive_scan()
48 template<class InputIterator, class OutputIterator, class T, class BinaryOperator>
49 inline OutputIterator
50 exclusive_scan(InputIterator first,
51 InputIterator last,
52 OutputIterator result,
53 T init,
54 BinaryOperator binary_op,
55 command_queue &queue = system::default_queue())
56 {
57 return detail::scan(first, last, result, true, init, binary_op, queue);
58 }
59
60 /// \overload
61 template<class InputIterator, class OutputIterator, class T>
62 inline OutputIterator
63 exclusive_scan(InputIterator first,
64 InputIterator last,
65 OutputIterator result,
66 T init,
67 command_queue &queue = system::default_queue())
68 {
69 typedef typename
70 std::iterator_traits<OutputIterator>::value_type output_type;
71
72 return detail::scan(first, last, result, true,
73 init, boost::compute::plus<output_type>(),
74 queue);
75 }
76
77 /// \overload
78 template<class InputIterator, class OutputIterator>
79 inline OutputIterator
80 exclusive_scan(InputIterator first,
81 InputIterator last,
82 OutputIterator result,
83 command_queue &queue = system::default_queue())
84 {
85 typedef typename
86 std::iterator_traits<OutputIterator>::value_type output_type;
87
88 return detail::scan(first, last, result, true,
89 output_type(0), boost::compute::plus<output_type>(),
90 queue);
91 }
92
93 } // end compute namespace
94 } // end boost namespace
95
96 #endif // BOOST_COMPUTE_ALGORITHM_EXCLUSIVE_SCAN_HPP