diff --git a/include/beman/execution/detail/task_scheduler.hpp b/include/beman/execution/detail/task_scheduler.hpp index 42172845..d9122d60 100644 --- a/include/beman/execution/detail/task_scheduler.hpp +++ b/include/beman/execution/detail/task_scheduler.hpp @@ -255,19 +255,12 @@ struct task_scheduler_backend_for : task_scheduler_backend_sched { auto schedule_bulk_chunked(::std::size_t shape, ::beman::execution::parallel_scheduler_replacement::bulk_item_receiver_proxy& proxy, ::std::span<::std::byte> storage) noexcept -> void override { - const ::std::size_t chunk_size = ::std::min(shape, 8uz); - const ::std::size_t num_chunks = (shape + chunk_size - 1uz) / chunk_size; this->fire_and_forget(storage, - ::beman::execution::bulk(just_sndr_like{this->sched}, - ::beman::execution::par, - num_chunks, - [=, &proxy](::std::size_t i) noexcept { - const auto begin = i * chunk_size; - const auto end = shape - begin <= chunk_size - ? shape - : begin + chunk_size; - proxy.execute(begin, end); - }), + ::beman::execution::bulk_chunked( + just_sndr_like{this->sched}, + ::beman::execution::par, + shape, + [&proxy](::std::size_t i, ::std::size_t j) noexcept { proxy.execute(i, j); }), proxy); } @@ -276,10 +269,10 @@ struct task_scheduler_backend_for : task_scheduler_backend_sched { ::std::span<::std::byte> storage) noexcept -> void override { this->fire_and_forget( storage, - ::beman::execution::bulk(just_sndr_like{this->sched}, - ::beman::execution::par, - shape, - [&proxy](::std::size_t i) noexcept { proxy.execute(i, i + 1uz); }), + ::beman::execution::bulk_unchunked(just_sndr_like{this->sched}, + ::beman::execution::par, + shape, + [&proxy](::std::size_t i) noexcept { proxy.execute(i, i + 1uz); }), proxy); } diff --git a/tests/beman/execution/exec-parallel-scheduler.test.cpp b/tests/beman/execution/exec-parallel-scheduler.test.cpp index 3915184c..883c903b 100644 --- a/tests/beman/execution/exec-parallel-scheduler.test.cpp +++ b/tests/beman/execution/exec-parallel-scheduler.test.cpp @@ -136,7 +136,11 @@ struct thread_pool_base : replaceability::parallel_scheduler_backend { auto schedule_bulk(std::size_t shape, std::size_t chunk_length, replaceability::bulk_item_receiver_proxy& proxy, - std::span<::std::byte>) noexcept -> void { + std::span<::std::byte> storage) noexcept -> void { + if (shape == 0uz) { + schedule(proxy, storage); + return; + } const std::size_t chunk_count = (shape + chunk_length - 1uz) / chunk_length; std::shared_ptr shared_state; try { @@ -308,6 +312,11 @@ auto test_parallel_scheduler_schedule() -> void { test_std::sync_wait(test_std::schedule(sch) | test_std::then([&i]() noexcept { i = 114514; })); ASSERT(i == 114514); } + { + test_std::sync_wait(test_std::schedule(sch) | test_std::bulk(test_std::par, 0uz, [](std::size_t) noexcept {})); + test_std::sync_wait(test_std::schedule(sch) | + test_std::bulk(test_std::unseq, 0uz, [](std::size_t) noexcept {})); + } { for (auto size : {1uz, 4uz, 8uz, 16uz, 32uz}) { std::vector vec(size);