Skip to content

Provide only the pool; the schedulers move to OhMyThreads (2.0) - #88

Merged
vchuravy merged 4 commits into
mainfrom
vc/pool-only
Nov 15, 2026
Merged

vchuravy merged 4 commits into
mainfrom
vc/pool-only

Conversation

@vchuravy

Copy link
Copy Markdown
Owner

Fixes #79.

ThreadTeams depended on OhMyThreads, re-exported its API and defined TeamScheduler and GreedyTeamScheduler by overriding OhMyThreads internals. This inverts the relationship: ThreadTeams keeps the pool and the scheduling of chunks on it, and OhMyThreads depends on it and defines the schedulers (the companion PR is linked below).

Breaking changes

  • No dependency on OhMyThreads or ChunkSplitters; only ScopedValues remains. using ThreadTeams takes about 14 ms instead of 79 ms.
  • The package exports nothing. TeamScheduler, GreedyTeamScheduler and the re-export of the OhMyThreads API are removed: users write using OhMyThreads instead.
  • ThreadTeams.nchunks is removed.

New public API

  • run_chunks(f, n, [schedule]) and run_fold(f, op, n, [schedule]), the functions the schedulers were built on.
  • StaticSchedule(; busy) and GreedySchedule(; busy) in place of the scheduler objects.
  • runs_serially(schedule), for callers that decide how many chunks to make.

run_chunks and run_fold now check their arguments: a static schedule throws an ArgumentError for more than nworkers() chunks, and n ≤ 1 or a single thread runs serially.

Unchanged

  • foreach_chunk, foreach_range and the pool controls. KernelAbstractions should only need ThreadTeams = "2" in its compat.
  • The Enzyme rules stay here, on run_chunks and run_fold, so they keep covering OhMyThreads' team schedulers.

Tests

The tests of the schedulers themselves (test/schedulers.jl, test/captures.jl) move to OhMyThreads. The others still run the pool through tforeach and friends, with OhMyThreads as a test dependency, and test/run_chunks.jl covers the new public functions directly.

Locally, with both branches in one environment (Julia 1.12): the suite passes with 4 threads and with 1 thread. Per-loop overhead and the latency of a session's first loop are the same as on main.

CI and release order

CI here will fail until the OhMyThreads PR is released: the tests and benchmarks need OhMyThreads = "0.8.10", which in turn needs ThreadTeams 2. The Downstream job (FastBroadcast, vc/threadteams) was not checked against 2.0.

Suggested order: merge and register this as 2.0.0, then merge and release OhMyThreads 0.8.10.

🤖 Generated with Claude Code

ThreadTeams depended on OhMyThreads, re-exported its API and defined the
`TeamScheduler` and `GreedyTeamScheduler` by overriding OhMyThreads
internals. Packages that only need the pool, like KernelAbstractions'
CPU back-end (`foreach_chunk`), paid for loading OhMyThreads (62 of
79 ms), and the overrides broke with OhMyThreads releases (#30, #71).

The relationship is now inverted: ThreadTeams has the pool and the
scheduling of chunks on it, and OhMyThreads depends on it and defines
the schedulers.

- The package no longer depends on OhMyThreads and ChunkSplitters, and
  exports nothing. `TeamScheduler`, `GreedyTeamScheduler`, the re-export
  of the OhMyThreads API and `ThreadTeams.nchunks` are removed.
- `run_chunks(f, n, [schedule])` and `run_fold(f, op, n, [schedule])`
  are public, with `StaticSchedule(; busy)` and `GreedySchedule(; busy)`
  in place of the scheduler objects, and `runs_serially(schedule)` for
  callers that decide the number of chunks. They check their arguments
  now: a static schedule takes at most `nworkers()` chunks, and `n ≤ 1`
  or a single thread runs serially.
- The Enzyme rules stay here, on `run_chunks` and `run_fold`.
- The precompile workload for the schedulers moves to OhMyThreads with
  them, as do the tests of the schedulers themselves. The other tests
  keep running the pool through OhMyThreads' schedulers, now a test
  dependency.

Fixes #79.

Co-Authored-By: Claude <noreply@anthropic.com>
@vchuravy

Copy link
Copy Markdown
Owner Author

x-ref: JuliaFolds2/OhMyThreads.jl#180

The tests use OhMyThreads' schedulers, which move there in
JuliaFolds2/OhMyThreads.jl#180 and need ThreadTeams 2.0. Point the test
and benchmark environments at that branch with `[sources]`. Julia 1.10
ignores `[sources]`, and its `Pkg.test` cannot merge a test dependency
that depends on the package under test, so the 1.10 jobs develop both
packages into the test environment and run test/runtests.jl directly.

Assisted-by: Claude Code (Opus 5.5)
Its only package, the vc/threadteams branch of FastBroadcast, requires
ThreadTeams 1 and cannot resolve against 2.0.

Assisted-by: Claude Code (Opus 5.5)
ThreadTeams 2.0 provides the pool; the team schedulers are in
OhMyThreads. The AirspeedVelocity suite now measures `run_chunks` and
`run_fold` (static and greedy), `foreach_range` (static and stealing)
and `foreach_chunk` against `Threads.@threads`, and drops OhMyThreads
and the FastBroadcast group (its branch requires ThreadTeams 1).

The Enzyme and Trixi groups use `run_chunks`/`run_fold` directly. The
forward-mode benchmark differentiates `run_fold`: Enzyme can not yet
differentiate `run_chunks` in forward mode with a closure that captures
a constant scalar on Julia 1.12 and later (EnzymeAD/Enzyme.jl#2707).

`benchmark/overhead/` keeps comparing against OhMyThreads' schedulers
for the documentation.

Assisted-by: Claude Code (Opus 5.5)
@vchuravy
vchuravy merged commit fbe499f into main Nov 15, 2026
10 of 11 checks passed
@vchuravy
vchuravy deleted the vc/pool-only branch November 15, 2026 16:05
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.

Load the pool without OhMyThreads (2.0)

1 participant