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

Function block_reduce

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

Source from the content-addressed store, hash-verified

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

Callers 1

generic_reduceFunction · 0.85

Calls 3

reduceFunction · 0.85
get_contextMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected