| 1235 | |
| 1236 | template <class ForwardIt> |
| 1237 | sycl::event is_sorted(sycl::queue &q, ForwardIt first, ForwardIt last, |
| 1238 | detail::early_exit_flag_t* out, |
| 1239 | const std::vector<sycl::event>& deps = {}) { |
| 1240 | std::size_t problem_size = std::distance(first, last); |
| 1241 | if(problem_size == 0) |
| 1242 | return sycl::event{}; |
| 1243 | |
| 1244 | auto evt = detail::early_exit_for_each(q, problem_size, out, |
| 1245 | [=](sycl::id<1> idx) -> bool { |
| 1246 | auto it = first; |
| 1247 | std::advance(it, idx[0]); |
| 1248 | if(it != last-1) { |
| 1249 | auto next = std::next(it, 1); |
| 1250 | #if __cplusplus < 202002L |
| 1251 | return (*next < *it); |
| 1252 | #else |
| 1253 | return std::less{}(*next, *it); |
| 1254 | #endif |
| 1255 | } |
| 1256 | return false; |
| 1257 | }, deps); |
| 1258 | return q.single_task(evt, [=](){ |
| 1259 | *out = static_cast<detail::early_exit_flag_t>(!(*out)); |
| 1260 | }); |
| 1261 | } |
| 1262 | |
| 1263 | template <class ForwardIt, class Compare> |
| 1264 | sycl::event is_sorted(sycl::queue &q, ForwardIt first, ForwardIt last, |