Repository navigation
foreach_range(...; isolate = true): run no other task while waiting - #87
Merged
Merged
Conversation
…ting While it waits for the participants, the caller of a range region yields: in the park branch of `rescue_ranges`, every 1024 spins of `wait_idle`, and in `notify` when another task holds the event's lock. Tasks queued on its thread then run in the middle of the call. With `isolate = true` the caller only spins and parks its OS thread, and wakes workers after taking the event's lock with `trylock`, so it switches tasks only where `f` does. Should a call of `f` that yielded move the caller onto another worker's thread, the waits yield again, since that worker could otherwise not progress. The other loops and the default are unchanged. A caller needs this when it relies on state of its thread across the call. On Julia up to 1.13, `disable_sigint` defers a Ctrl-C only while the deferring task runs on thread 1: when it yields, the interrupt is thrown into whichever task runs there next, usually the thread-1 worker, which dies (if it had not started yet) or drops it (#40). KernelAbstractions' CPU back-end defers interrupts for the whole of a kernel launch on the team, and lost them this way (JuliaGPU/KernelAbstractions.jl#941).
Benchmark Results (Julia v1)Time benchmarks
|
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.
Adds
foreach_range(f, n; isolate = true): the caller dispatches and waits without switching tasks, providedfdoes not yield. The default and other loops are unchanged.On Julia ≤ 1.13, yielding on thread 1 lets another task receive a Ctrl-C deferred by
disable_sigint. A ThreadTeams worker can die before starting or drop the interrupt while idle (#40). This caused lost interrupts during KernelAbstractions CPU launches (JuliaGPU/KernelAbstractions.jl#941).Isolated waits spin and park the OS thread; worker notifications use
trylock+notifyto avoid yielding on a contended event lock. Iffyields and moves the caller onto another worker's thread, completion waits resume yielding so workers can progress.Validation
-t 4).kill -INT0.25 s into a 2 s launch): previously lost 1 of 3 interrupts on Linux and the first in every run on macOS. With isolation, 12/12 (Linux) and 8/8 (macOS) delivered; all workers remained alive.