| 854 | |
| 855 | template<class ForwardIt, class T> |
| 856 | sycl::event count(sycl::queue &q, util::allocation_group &scratch_allocations, |
| 857 | ForwardIt first, ForwardIt last, |
| 858 | typename std::iterator_traits<ForwardIt>::difference_type *out, |
| 859 | const T& value, const std::vector<sycl::event> &deps = {}) { |
| 860 | |
| 861 | using DiffT = typename std::iterator_traits<ForwardIt>::difference_type; |
| 862 | using ValueT = typename std::iterator_traits<ForwardIt>::value_type; |
| 863 | |
| 864 | return transform_reduce(q, scratch_allocations, first, last, out, |
| 865 | DiffT{}, std::plus<>{}, |
| 866 | [value](ValueT x) {return (x == value ? 1 : 0);}, |
| 867 | deps); |
| 868 | } |
| 869 | |
| 870 | template<class ForwardIt, class UnaryPredicate> |
| 871 | sycl::event count_if(sycl::queue &q, util::allocation_group &scratch_allocations, |