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

Function is_sorted_until

include/hipSYCL/algorithms/algorithm.hpp:1287–1319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1285
1286template<class ForwardIt>
1287sycl::event is_sorted_until(sycl::queue &q, util::allocation_group &scratch_allocations,
1288 ForwardIt first, ForwardIt last,
1289 typename std::iterator_traits<ForwardIt>::difference_type *out,
1290 const std::vector<sycl::event>& deps = {}) {
1291 if(first == last)
1292 return sycl::event{};
1293
1294 using DiffT = typename std::iterator_traits<ForwardIt>::difference_type;
1295 DiffT problem_size = std::distance(first, last);
1296
1297 auto transform = [=] (ForwardIt input) {
1298 auto next = std::next(input, 1);
1299#if __cplusplus < 202002L
1300 if((*next < *input))
1301#else
1302 if(std::less{}(*next, *input))
1303#endif
1304 return std::distance(first, input);
1305
1306 return problem_size;
1307 };
1308
1309 auto kernel = [=](sycl::id<1> idx, auto& reducer) {
1310 auto input = first;
1311 std::advance(input, idx[0]);
1312 reducer.combine(transform(input));
1313 };
1314
1315 auto reduce = sycl::minimum<DiffT>{};
1316
1317 return detail::transform_reduce_impl(q, scratch_allocations, out, std::numeric_limits<DiffT>::max(),
1318 problem_size, kernel, reduce, deps);
1319}
1320
1321template<class ForwardIt, class Compare>
1322sycl::event is_sorted_until(sycl::queue &q, util::allocation_group &scratch_allocations,

Callers 1

test_is_sorted_untilFunction · 0.50

Calls 5

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

Tested by 1

test_is_sorted_untilFunction · 0.40