Skip to main content

replay_copy_raw

Function replay_copy_raw 

Source
pub fn replay_copy_raw<T>(
    dest: &mut RawStridedMut<'_, T>,
    src: &RawStridedRef<'_, T>,
    exec: Exec<'_>,
) -> Result<()>
where T: Copy + Send + Sync,
Expand description

dest = src, replaying the axes of the two views exactly as given.

The views carry already-fused dims: no axis is reordered, dropped or merged, and no plan is compiled. Axis 0 is the inner run of the column-major walk; when the shared cache-block model finds tiles that change the visit order and can reuse a cache line, the walk goes tile by tile instead, each tile column-major over the given axes. Bounds were validated when the views were built (RawStridedRef::new, RawStridedMut::new).

On a successful call the replay itself (validation, traversal and dispatch) allocates nothing at any rank on a serial token, or on a pooled token whose replay is not tiled. A pooled tiled replay with more than RAW_FUSED_RANK_LIMIT moving axes may allocate the splitter’s metadata. The wide route uses a rank-bounded amount of stack. An error may allocate its payload.

The width comes from the repository rule on exec. A parallel or tiled replay runs only on a destination proven injective without allocating; any other destination is replayed serially in column-major order of the given axes.

§Errors

StridedError::ShapeMismatch when the two views have different dims, and StridedError::OffsetOverflow when the element count overflows usize; both before any write.

§Examples

Copy the outer band 1..3 of a stored 2 x 3 block into a transposed destination:

use strided_basic::{replay_copy_raw, Exec, RawStridedMut, RawStridedRef};

let stored = [0.0f64, 1.0, 2.0, 3.0, 4.0, 5.0]; // column-major 2 x 3
let band = [2usize, 2];
let src = RawStridedRef::new(&stored, &band, &[1, 2], 2).unwrap();
let mut out = [0.0f64; 4];
let mut dst = RawStridedMut::new(&mut out, &band, &[2, 1], 0).unwrap();
replay_copy_raw(&mut dst, &src, Exec::serial()).unwrap();
assert_eq!(out, [2.0, 4.0, 3.0, 5.0]);