MCPcopy Create free account
hub / github.com/boostorg/compute / block_reduce

Function block_reduce

include/boost/compute/algorithm/reduce.hpp:128–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126
127template<class InputIterator, class BinaryFunction>
128inline vector<
129 typename boost::compute::result_of<
130 BinaryFunction(
131 typename std::iterator_traits<InputIterator>::value_type,
132 typename std::iterator_traits<InputIterator>::value_type
133 )
134 >::type
135>
136block_reduce(InputIterator first,
137 size_t count,
138 size_t block_size,
139 BinaryFunction function,
140 command_queue &queue)
141{
142 typedef typename
143 std::iterator_traits<InputIterator>::value_type
144 input_type;
145 typedef typename
146 boost::compute::result_of<BinaryFunction(input_type, input_type)>::type
147 result_type;
148
149 const context &context = queue.get_context();
150 size_t total_block_count =
151 static_cast<size_t>(std::ceil(float(count) / 2.f / float(block_size)));
152 vector<result_type> result_vector(total_block_count, context);
153
154 reduce(first, count, result_vector.begin(), block_size, function, queue);
155
156 return result_vector;
157}
158
159// Space complexity: O( ceil(n / 2 / 256) )
160template<class InputIterator, class OutputIterator, class BinaryFunction>

Callers 1

generic_reduceFunction · 0.85

Calls 3

reduceFunction · 0.85
get_contextMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected