NVIDIA / NVIDIA/stdexec

static_thread_pool hangs when the batch is smaller than the pool size.

Open Beginner friendly
#1,751 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
2.4k
Forks
270
Avg merge
3d 6h
Merged PRs (30d)
39

Description

problem

in include/exec/static_thread_pool.hpp
schedule_all cpo invoke

void start() & noexcept {
            std::size_t size = items_.size();
            std::size_t nthreads = this->pool_.static_thread_poolilable_parallelism();
            bwos_params params = this->pool_.params();
            std::size_t local_size = params.blockSize * params.numBlocks;
            std::size_t chunk_size = std::min(size / nthreads, local_size * nthreads);
            auto& remote_queue = *this->pool_.get_remote_queue();
            auto it = std::ranges::begin(this->range_);
            std::size_t i0 = 0;
            while (i0 + chunk_size < size) {
              for (std::size_t i = i0; i < i0 + chunk_size; ++i) {
                items_[i].__construct_from(
                  stdexec::connect,
                  set_next(this->rcvr_, item_sender_t{this, it + i}),
                  next_receiver_t{this});
                stdexec::start(items_[i].__get());
              }

              std::unique_lock lock{this->start_mutex_};
              this->pool_.bulk_enqueue(remote_queue, std::move(this->tasks_), this->tasks_size_);
              lock.unlock();
              i0 += chunk_size;
            }

When the ready batch is smaller than the pool size (size < nthreads), size / nthreads becomes 0, so chunk_size is
0 and the loop never advances. That spins forever, no tasks are enqueued.

usage pattern:

std::span<const int> node_indices;
 auto task = exec::schedule_all(pool,node_indices) |
                exec::transform_each(stdexec::then([](int node_index) noexcept {

                                 })) |
                exec::ignore_all_values();
    stdexec::start_detached(std::move(task));

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in include/exec/static_thread_pool.hpp at schedule_all CPO invoke and its start() entry point. Reproduce the provided schedule_all usage with a ready batch smaller than the pool's available parallelism, then trace whether the loop advances and tasks are enqueued. Done means the small batch no longer hangs and its tasks complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.