Skip to content

fix: provide the scheduler_concept nested alias on all stdexec schedulers (#2134) - #2256

Merged
ericniebler merged 2 commits into
NVIDIA:mainfrom
alwaysprince05:fix/issue-2134-task-semi-scheduler-concept
Sep 15, 2026
Merged

ericniebler merged 2 commits into
NVIDIA:mainfrom
alwaysprince05:fix/issue-2134-task-semi-scheduler-concept

Conversation

@alwaysprince05

@alwaysprince05 alwaysprince05 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2134

What happened

Users couldn't start an exec::task on an exec::static_thread_pool or exec::timed_thread_context scheduler — the code failed to compile:

include/exec/task.hpp:163:33: error: no viable overloaded '='

The task's internal __any_scheduler converting constructor is guarded by __semi_scheduler, which requires a scheduler_concept typedef derived from scheduler_tag. Per [exec.sched], that nested alias is part of the scheduler concept, so scheduler types are expected to define it — but a number of the schedulers in stdexec did not.

The fix (updated after review)

Rather than loosening the internal __semi_scheduler concept (the original approach of this PR), this PR now keeps include/exec/task.hpp exactly as it is on main and instead makes all of stdexec's own schedulers provide the required nested alias (using scheduler_concept = scheduler_tag;):

  • exec::static_thread_pool::scheduler
  • exec::thread_pool_base<...>::scheduler (also covers exec::tbb::tbb_thread_pool and exec::taskflow::taskflow_thread_pool)
  • exec::timed_thread_scheduler
  • exec::libdispatch_scheduler
  • exec::io_uring_context::__scheduler (Linux)
  • exec::windows_thread_pool::scheduler (Windows)
  • exec::trampoline_scheduler's scheduler
  • exec::reschedule's internal scheduler
  • stdexec::parallel_scheduler
  • nvexec::stream_scheduler and nvexec::multi_gpu_stream_scheduler

Schedulers that already defined the alias are unchanged (inline_scheduler, run_loop's scheduler, any_scheduler, and the test-common schedulers).

Tests

Two regression tests in test/exec/test_task.cpp co_start an exec::task on exec::static_thread_pool and exec::timed_thread_context and verify it actually runs, guarding the fix going forward.

Verification

  • test.exec: 3401 assertions / 359 cases pass (Release, Apple Clang)
  • test.stdexec: 3528 assertions / 619 cases pass

@copy-pr-bot

copy-pr-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@alwaysprince05

Copy link
Copy Markdown
Contributor Author

Hi @ericniebler — could you run /ok to test 1551bbb when you get a chance? It's a small fix for #2134: it drops the scheduler_concept requirement from __semi_scheduler so exec::task can be co_started on exec::static_thread_pool and exec::timed_thread_context, plus two compile-time regression tests. Details in the description. Thanks!

@ericniebler

Copy link
Copy Markdown
Collaborator

The scheduler concept requires the scheduler_concept nested alias. See [exec.sched]. I think the right fix here is for all of the schedulers in stdexec to provide that nested alias.

alwaysprince05 added a commit to alwaysprince05/stdexec that referenced this pull request Sep 14, 2026
…VIDIA#2134)

Per review feedback on NVIDIA#2256, keep the __semi_scheduler concept in
exec/task.hpp requiring the scheduler_concept nested alias, as required
by the scheduler concept in [exec.sched], and instead provide that alias
on all of stdexec's own schedulers that were missing it: the schedulers
of static_thread_pool, thread_pool_base (tbb, taskflow pools),
timed_thread_scheduler, libdispatch_scheduler, io_uring_context,
windows_thread_pool, trampoline_scheduler, reschedule,
parallel_scheduler, and the nvexec stream and multi-GPU stream
schedulers.

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@alwaysprince05 alwaysprince05 changed the title fix(exec): let exec::task run on schedulers without a scheduler_concept typedef (#2134) fix: provide the scheduler_concept nested alias on all stdexec schedulers (#2134) Sep 14, 2026
@alwaysprince05

Copy link
Copy Markdown
Contributor Author

Good point — done. 2a5cf76 restores __semi_scheduler (and all of include/exec/task.hpp) to exactly what is on main, and instead adds the scheduler_concept nested alias required by [exec.sched] to the schedulers in stdexec that were missing it: static_thread_pool, thread_pool_base (covers the tbb and taskflow pools), timed_thread_scheduler, libdispatch_scheduler, io_uring_context, windows_thread_pool, trampoline_scheduler, reschedule, parallel_scheduler, and the nvexec stream and multi-GPU stream schedulers. The two regression tests from the original PR are kept, and test.exec + test.stdexec pass.

…lers (NVIDIA#2134)

The scheduler concept in [exec.sched] requires a scheduler_concept
nested alias derived from scheduler_tag, and exec::task's internal
__any_scheduler conversion checks it via __semi_scheduler. Most of
stdexec's schedulers define that typedef, but several did not, so
co_starting an exec::task on them failed to compile
(see NVIDIA#2134).

Add the missing `using scheduler_concept = scheduler_tag;` to the
schedulers that lacked it: static_thread_pool, thread_pool_base (also
covering the tbb and taskflow pools), timed_thread_scheduler,
libdispatch_scheduler, io_uring_context, windows_thread_pool,
trampoline_scheduler, reschedule, parallel_scheduler, and the nvexec
stream and multi-GPU stream schedulers. Schedulers that already define
the alias are unchanged, and include/exec/task.hpp is untouched.

Also add regression tests that co_start an exec::task on the schedulers
of exec::static_thread_pool and exec::timed_thread_context and verify
they run, guarding the fix going forward.

Fixes NVIDIA#2134

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@alwaysprince05
alwaysprince05 force-pushed the fix/issue-2134-task-semi-scheduler-concept branch from 2a5cf76 to 2c7dc69 Compare September 14, 2026 19:16
@alwaysprince05

Copy link
Copy Markdown
Contributor Author

(Squashed the two commits into a single clean one before review started; the fix described above is now commit 2c7dc69 — content is unchanged.)

Align the `=` in the time_point/duration aliases and re-indent the new
test_task.cpp tests so `clang-format-21 --dry-run --Werror` (the CI
style check) passes.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@alwaysprince05

Copy link
Copy Markdown
Contributor Author

Hi @ericniebler — the clang-format violations you'd have seen on the earlier head are fixed now (7b4b2c5, whitespace-only, verified against clang-format-21 exactly as CI runs it). Could you /ok to test so the workflows can run on the new commit? Thanks!

@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test 7b4b2c5

@alwaysprince05

Copy link
Copy Markdown
Contributor Author

FYI: the failing CPU (clang 22, Debug, modules) job is the known-broken allow_failure: true config — it also fails on current main (example run). The errors are in test/stdexec/types/test_task.cpp, which this PR doesn't touch, so I believe it's unrelated.

@ericniebler
ericniebler merged commit 71b28e0 into NVIDIA:main Sep 15, 2026
38 of 39 checks passed
@ericniebler

Copy link
Copy Markdown
Collaborator

thanks!

@alwaysprince05
alwaysprince05 deleted the fix/issue-2134-task-semi-scheduler-concept branch September 15, 2026 20:35
ericniebler pushed a commit that referenced this pull request Sep 16, 2026
…rs (#2257)

* test: add scheduler_concept regression guard for all stdexec schedulers

Per [exec.sched], scheduler types should define a nested scheduler_concept
alias derived from scheduler_tag. PR #2256 (issue #2134) added the missing
aliases; this adds compile-time guards so the requirement cannot regress.

- New test/exec/test_scheduler_concept.cpp statically asserts the alias and
  scheduler<> satisfaction for the always-available schedulers: inline,
  run_loop, task_scheduler, parallel, static_thread_pool, thread_pool_base
  (CRTP), timed_thread, trampoline, and the internal reschedule scheduler.
- Gated schedulers are asserted in their existing gated test files:
  io_uring, windows_thread_pool, libdispatch, and the nvexec stream and
  multi-GPU stream schedulers.

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

* style: join wrapped TEST_CASE args in test_libdispatch to satisfy clang-format

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

---------

Co-authored-by: Codebuff <noreply@codebuff.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build error when starting exec::task in some schedulers, because they miss the scheduler_concept typedef

2 participants