pub struct Tiles<'scope, S: Strategy> { /* private fields */ }Expand description
Tiles supplied for one invocation of Strategy::run_tiles.
Each tile is one row over a contiguous range of columns, and the tiles cover every cell exactly once. A serial run makes every row one tile on the calling thread.
A parallel run estimates each grid’s critical path over its workers both as whole rows and as equal shares of cells, and cuts the grid in the way with the shortest estimate. Workers claim whole rows from one queue, one row at a time unless the grid has more than 65,535 rows, and whole rows may leave some workers a row short. Shares of cells cut rows and cost each worker about two extra tiles and a tile’s cost of unevenness.
A worker that runs out of its share of cells takes the back half of the largest other
pending share. Taking it can cut a row, so it happens only while the half is longer than
tile_cost, where the extra tile pays for itself.
When an operation does its work in fill, a worker that runs slowly or starts late holds
up the run by at most one claim of rows, or by one claim of cells and the halves of its
share too short to take. Those cells come to a few tile costs, or proportionally more in a
grid of more than 65,535 tile costs. Work an operation defers to finish stays with the
worker that holds the tile.
Implementations§
Source§impl<'scope, S: Strategy> Tiles<'scope, S>
impl<'scope, S: Strategy> Tiles<'scope, S>
Sourcepub const fn grid(&self) -> usize
pub const fn grid(&self) -> usize
The index, among the grids supplied to the run, of the grid it cuts.
Sourcepub fn fill_collect_vec<INIT, T, FILL, FINISH, R>(
self,
init: INIT,
fill: FILL,
finish: FINISH,
) -> Vec<R>
pub fn fill_collect_vec<INIT, T, FILL, FINISH, R>( self, init: INIT, fill: FILL, finish: FINISH, ) -> Vec<R>
Fills every tile piece by piece with per-worker state, collecting one result per tile.
fill receives a tile’s row and the columns of each of its pieces in column order, and
no piece is empty. finish then ends the tile and returns its result. init creates
state that a worker reuses across its tiles, so finish must leave the state ready for
another tile.
Results come back in no particular order. Where a parallel run cuts a row depends on timing, so combine a row’s results in a way that does not depend on its cuts.