Skip to main content

along

Function along 

Source
pub fn along<T, R>(
    data: &[T],
    shape: [usize; 3],
) -> (Vec<<R as Reduction<T>>::Total>, bool)
where T: Copy + Sync, R: Reduction<T>,
Expand description

The folds by R of the lanes along the middle axis of data, an array of shape [outer, len, inner] held row by row: one fold for each of the outer × inner lanes, and whether every one fits. Where a lane along the last axis, or a group of inner lanes along another axis, fits in one piece of fold_pieces, each lane folds whole. Runs of whole lanes or groups then split across threads as parallel::split splits a call. An array with too few rows to give each of this thread’s parallel::threads a piece of [ROWS] rows splits by columns instead, where a row holds more than one unit: a run of lanes whose part of the array holds at least [PIECE] items. Each thread then reads part of every row. At 4 threads on an M5 Max, +⌿ took 41% less time on 8×524288, which had folded on one thread, and 17% less on 64×65536 than split by rows. With more rows, a split by columns took more time than a split by rows: 33% more on 256×16384 and 66% more on 4000×9000. Otherwise the array folds as fold_pieces folds it.