Repository navigation
Provide only the pool; the schedulers move to OhMyThreads (2.0) - #88
Merged
Merged
Conversation
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>
Owner
Author
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #79.
ThreadTeams depended on OhMyThreads, re-exported its API and defined
TeamSchedulerandGreedyTeamSchedulerby 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
using ThreadTeamstakes about 14 ms instead of 79 ms.TeamScheduler,GreedyTeamSchedulerand the re-export of the OhMyThreads API are removed: users writeusing OhMyThreadsinstead.ThreadTeams.nchunksis removed.New public API
run_chunks(f, n, [schedule])andrun_fold(f, op, n, [schedule]), the functions the schedulers were built on.StaticSchedule(; busy)andGreedySchedule(; busy)in place of the scheduler objects.runs_serially(schedule), for callers that decide how many chunks to make.run_chunksandrun_foldnow check their arguments: a static schedule throws anArgumentErrorfor more thannworkers()chunks, andn ≤ 1or a single thread runs serially.Unchanged
foreach_chunk,foreach_rangeand the pool controls. KernelAbstractions should only needThreadTeams = "2"in its compat.run_chunksandrun_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 throughtforeachand friends, with OhMyThreads as a test dependency, andtest/run_chunks.jlcovers 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