Skip to main content

copy_into

Function copy_into 

Source
pub fn copy_into<T: Copy + Send + Sync + 'static>(
    dest: &mut StridedViewMut<'_, T>,
    src: &StridedView<'_, T>,
    exec: Exec<'_>,
) -> Result<()>
Expand description

Copy elements from source to destination: dest[i] = src[i].

Uses HPTT-inspired blocked permutation with bilateral dimension fusion, cache-aware blocking, and optimal loop ordering. The permutation is split across the budget of exec, at the width the token’s dispatch cost justifies for the copy (copy_ns_per_element times its elements); a small copy stays on the calling thread. A caller that wants a large copy on one thread passes Exec::serial or narrows the token with Exec::limit. A contiguous copy uses one memcpy per range of the narrowed token, or a single memcpy on the calling thread when that token is serial.

This is a simple copy without ElementOp support. For copies with element operations (conj, transpose, etc.), use strided_kernel::copy_into.

§Examples

use threadteam::Exec;
use strided_perm::copy_into;
use strided_view::StridedArray;

let src = StridedArray::<f64>::from_fn_col_major(&[2, 3], |idx| (idx[0] * 10 + idx[1]) as f64);
let mut dst = StridedArray::<f64>::col_major(&[2, 3]);
copy_into(&mut dst.view_mut(), &src.view(), Exec::serial()).unwrap();
assert_eq!(dst.get(&[1, 2]), 12.0);