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

Class binary_find_kernel

include/boost/compute/algorithm/detail/binary_find.hpp:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28///
29template<class InputIterator, class UnaryPredicate>
30class binary_find_kernel : public meta_kernel
31{
32public:
33 binary_find_kernel(InputIterator first,
34 InputIterator last,
35 UnaryPredicate predicate)
36 : meta_kernel("binary_find")
37 {
38 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
39
40 m_index_arg = add_arg<uint_ *>(memory_object::global_memory, "index");
41 m_block_arg = add_arg<uint_>("block");
42
43 atomic_min<uint_> atomic_min_uint;
44
45 *this <<
46 "uint i = get_global_id(0) * block;\n" <<
47 decl<value_type>("value") << "=" << first[var<uint_>("i")] << ";\n" <<
48 "if(" << predicate(var<value_type>("value")) << ") {\n" <<
49 atomic_min_uint(var<uint_ *>("index"), var<uint_>("i")) << ";\n" <<
50 "}\n";
51 }
52
53 size_t m_index_arg;
54 size_t m_block_arg;
55};
56
57///
58/// \brief Binary find algorithm

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected