Skip to main content

phase_order

Function phase_order 

Source
pub fn phase_order(touches: &[SectionTouch]) -> (Vec<usize>, Vec<bool>)
Expand description

Place each section, in source order, in the earliest phase after every section it depends on (a read of what an earlier one writes, a write of what an earlier one reads or writes — the carried state included) where its chips are free, and return the sections’ order, phase by phase, with barrier_after[k] closing the last section of each phase.

A section depends on an earlier one exactly when some name witnesses it, so the phase it must follow is the latest phase any of its names was written in (or, for a name it writes, read in) — the pairwise maximum over the sections before it, taken per name. The first phase from there with its chips free is read off each chip’s FreePhases: jumping to the latest of the chips’ next free phases skips only phases some chip holds, so the first phase every chip agrees on is the earliest free one. Both keep the placement linear in the sections, where a walk phase by phase is quadratic in a batch whose independent sequences all start past the same phase.