MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / find_first_of

Function find_first_of

include/hipSYCL/algorithms/algorithm.hpp:690–721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688
689template <class ForwardIt1, class ForwardIt2>
690sycl::event find_first_of(sycl::queue &q, util::allocation_group &scratch_allocations,
691 ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first,
692 ForwardIt2 s_last,
693 typename std::iterator_traits<ForwardIt1>::difference_type *out,
694 const std::vector<sycl::event> &deps = {}) {
695 if (first == last || s_first == s_last)
696 return sycl::event{};
697
698 using DiffT = typename std::iterator_traits<ForwardIt1>::difference_type;
699 DiffT problem_size = std::distance(first, last);
700
701 auto transform = [=] (ForwardIt1 input) {
702 auto s_it = s_first;
703 for (; s_it != s_last; ++s_it) {
704 if(*input == *s_it)
705 return std::distance(first, input);
706 }
707 return problem_size;
708 };
709
710 auto kernel = [=](sycl::id<1> idx, auto& reducer) {
711 auto input = first;
712 std::advance(input, idx[0]);
713 reducer.combine(transform(input));
714 };
715
716 auto reduce = sycl::minimum<DiffT>{};
717
718 return detail::transform_reduce_impl(q, scratch_allocations, out,
719 std::numeric_limits<DiffT>::max(),
720 problem_size, kernel, reduce, deps);
721}
722
723template <class ForwardIt1, class ForwardIt2, class BinaryPredicate>
724sycl::event find_first_of(sycl::queue &q, util::allocation_group &scratch_allocations,

Callers 1

test_find_first_ofFunction · 0.50

Calls 4

transform_reduce_implFunction · 0.85
maxClass · 0.85
combineMethod · 0.80
transformFunction · 0.70

Tested by 1

test_find_first_ofFunction · 0.40