Skip to main content

for_each_inner_block_preordered

Function for_each_inner_block_preordered 

Source
pub unsafe fn for_each_inner_block_preordered<S: AsRef<[isize]>, F>(
    dims: &[usize],
    blocks: &[usize],
    strides: &[S],
    initial_offsets: &[isize],
    f: F,
) -> Result<()>
where F: FnMut(&[isize], usize, &[isize]) -> Result<()>,
Expand description

Prevalidated for each inner block preordered for kernel-family implementations.

§Safety

All rank-indexed arrays must have matching lengths and a valid destination index (when present). Shape products, stride magnitudes, cost arithmetic, and every intermediate offset used by planning/iteration must be representable. Iteration blocks must be positive and offsets must correspond to the supplied layouts; threaded partitioning additionally requires positive costs. Callback memory accesses must be valid for each generated block, with disjoint mutable regions when partitions execute concurrently.

§Examples

use strided_basic::execution::*;
// SAFETY: the example supplies matching bounded layouts and disjoint storage.
let mut count = 0;
unsafe { for_each_inner_block_preordered(&[4], &[4], &[vec![1]], &[0], |_, n, _| { count += n; Ok(()) }) }.unwrap();
assert_eq!(count, 4);

§Errors

Forwards errors from the owning kernel or callback; callers must still satisfy the safety contract before invoking this prevalidated entry.