Skip to main content

Tiles

Struct Tiles 

Source
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>

Source

pub const fn grid(&self) -> usize

The index, among the grids supplied to the run, of the grid it cuts.

Source

pub fn fill_collect_vec<INIT, T, FILL, FINISH, R>( self, init: INIT, fill: FILL, finish: FINISH, ) -> Vec<R>
where INIT: Fn() -> T + Send + Sync, T: Send, FILL: Fn(&mut T, usize, Range<usize>) + Send + Sync, FINISH: Fn(&mut T, usize) -> R + Send + Sync, R: Send,

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.

Trait Implementations§

Source§

impl<'scope, S: Debug + Strategy> Debug for Tiles<'scope, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'scope, S> Freeze for Tiles<'scope, S>

§

impl<'scope, S> RefUnwindSafe for Tiles<'scope, S>

§

impl<'scope, S> Send for Tiles<'scope, S>
where &'scope S: Send,

§

impl<'scope, S> Sync for Tiles<'scope, S>
where &'scope S: Sync,

§

impl<'scope, S> Unpin for Tiles<'scope, S>

§

impl<'scope, S> UnsafeUnpin for Tiles<'scope, S>

§

impl<'scope, S> UnwindSafe for Tiles<'scope, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.