@@ -870,6 +870,73 @@ sycl::event count_if(sycl::queue &q, util::allocation_group &scratch_allocations
870870 deps);
871871}
872872
873+ template <class ForwardIt1 , class ForwardIt2 , class BinaryPredicate >
874+ sycl::event mismatch (sycl::queue &q, util::allocation_group &scratch_allocations,
875+ ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
876+ ForwardIt2 last2, BinaryPredicate p,
877+ typename std::iterator_traits<ForwardIt1>::difference_type* out,
878+ const std::vector<sycl::event>& deps = {}) {
879+ if (first1 == last1 || first2 == last2)
880+ return sycl::event{};
881+
882+ using DiffT = typename std::iterator_traits<ForwardIt1>::difference_type;
883+ DiffT problem_size = std::min (std::distance (first1, last1),
884+ std::distance (first2, last2));
885+
886+ auto kernel = [=](sycl::id<1 > idx, auto & reducer) {
887+ auto input1 = std::next (first1, idx[0 ]);
888+ auto input2 = std::next (first2, idx[0 ]);
889+ if ( p (*input1, *input2) )
890+ reducer.combine (problem_size);
891+ else
892+ reducer.combine (idx[0 ]);
893+ };
894+
895+ auto reduce = sycl::minimum<DiffT>{};
896+
897+ return detail::transform_reduce_impl (q, scratch_allocations, out,
898+ std::numeric_limits<DiffT>::max (),
899+ problem_size, kernel, reduce, deps);
900+ }
901+
902+ template <class ForwardIt1 , class ForwardIt2 , class BinaryPredicate >
903+ sycl::event mismatch (sycl::queue &q, util::allocation_group &scratch_allocations,
904+ ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
905+ BinaryPredicate p,
906+ typename std::iterator_traits<ForwardIt1>::difference_type* out,
907+ const std::vector<sycl::event>& deps = {}) {
908+ if (first1 == last1)
909+ return sycl::event{};
910+
911+ return mismatch (q, scratch_allocations, first1, last1, first2,
912+ std::next (first2, std::distance (first1, last1)), p, out, deps);
913+ }
914+
915+ template <class ForwardIt1 , class ForwardIt2 >
916+ sycl::event mismatch (sycl::queue &q, util::allocation_group &scratch_allocations,
917+ ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
918+ ForwardIt2 last2,
919+ typename std::iterator_traits<ForwardIt1>::difference_type* out,
920+ const std::vector<sycl::event>& deps = {}) {
921+ if (first1 == last1 || first2 == last2)
922+ return sycl::event{};
923+
924+ return mismatch (q, scratch_allocations, first1, last1, first2,
925+ last2, std::equal_to<>(), out, deps);
926+ }
927+
928+ template <class ForwardIt1 , class ForwardIt2 >
929+ sycl::event mismatch (sycl::queue &q, util::allocation_group &scratch_allocations,
930+ ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
931+ typename std::iterator_traits<ForwardIt1>::difference_type* out,
932+ const std::vector<sycl::event>& deps = {}) {
933+ if (first1 == last1)
934+ return sycl::event{};
935+
936+ return mismatch (q, scratch_allocations, first1, last1, first2,
937+ std::next (first2, std::distance (first1, last1)), out, deps);
938+ }
939+
873940template <class ForwardIt >
874941sycl::event
875942min_element (sycl::queue &q, util::allocation_group &scratch_allocations,
0 commit comments