Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions include/beman/execution/detail/task_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,12 @@ struct task_scheduler_backend_for : task_scheduler_backend_sched<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);
}

Expand All @@ -276,10 +269,10 @@ struct task_scheduler_backend_for : task_scheduler_backend_sched<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);
}

Expand Down
11 changes: 10 additions & 1 deletion tests/beman/execution/exec-parallel-scheduler.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bulk_shared_state> shared_state;
try {
Expand Down Expand Up @@ -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<int> vec(size);
Expand Down
Loading