| 401 | |
| 402 | template <class ForwardIt, class UnaryPredicate> |
| 403 | sycl::event remove_if(sycl::queue &q, util::allocation_group &scratch_allocations, |
| 404 | ForwardIt first, ForwardIt last, UnaryPredicate pred, |
| 405 | std::size_t *num_elements_copied = nullptr, |
| 406 | const std::vector<sycl::event> &deps = {}) { |
| 407 | if(first == last) { |
| 408 | if(num_elements_copied) |
| 409 | *num_elements_copied = 0; |
| 410 | return sycl::event{}; |
| 411 | } |
| 412 | |
| 413 | using ValueT = typename std::iterator_traits<ForwardIt>::value_type; |
| 414 | ValueT* device_buffer = scratch_allocations.obtain<ValueT>(std::distance(first, last)); |
| 415 | |
| 416 | auto op = [pred](auto x){ return !pred(x); }; |
| 417 | auto evt = copy_if(q, scratch_allocations, first, last, device_buffer, op, |
| 418 | num_elements_copied, deps); |
| 419 | |
| 420 | evt.wait(); |
| 421 | return copy_n(q, &(*device_buffer), *num_elements_copied, first, |
| 422 | deps); |
| 423 | } |
| 424 | |
| 425 | template <class ForwardIt1, class ForwardIt2, class UnaryPredicate> |
| 426 | sycl::event remove_copy_if(sycl::queue &q, util::allocation_group &scratch_allocations, |