| 28 | /// |
| 29 | template<class InputIterator, class UnaryPredicate> |
| 30 | class binary_find_kernel : public meta_kernel |
| 31 | { |
| 32 | public: |
| 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 |
nothing calls this directly
no outgoing calls
no test coverage detected