Skip to main content

strided_perm/
lib.rs

1//! Cache-efficient tensor permutation / transpose.
2//!
3//! This crate provides optimized copy and permutation operations for strided
4//! multidimensional arrays. It is designed as a single-responsibility crate
5//! sitting between `strided-view` (data structures) and `strided-kernel`
6//! (general map/reduce/broadcast operations).
7//!
8//! # Dependency graph
9//!
10//! ```text
11//! strided-view -> strided-perm -> strided-kernel
12//! ```
13//!
14//! # Threading
15//!
16//! Every copy takes a [`threadteam::Exec`] placement token as its last
17//! parameter and splits the permutation within that budget. The width is
18//! decided by the token: the serial time of the copy
19//! ([`copy_ns_per_element`] times its elements) against the dispatch cost of one
20//! section (`Exec::width_for`), so a copy too small to repay a fan-out runs on the
21//! calling thread whatever the budget. The crate never reaches a global
22//! pool; pass `Exec::serial()` for a copy on the calling thread.
23
24#[cfg(test)]
25mod block;
26mod copy;
27mod fuse;
28mod host;
29mod hptt;
30#[cfg(test)]
31#[allow(dead_code)]
32mod kernel;
33#[cfg(test)]
34mod order;
35
36// Re-export primary API
37pub use copy::{copy_into, copy_into_col_major, copy_into_uninit};
38pub use fuse::{plan_bilateral_fusion, BilateralFusionPlan, FusionPlanError};
39pub use host::{copy_ns_per_element, copy_ns_per_element_of, HostClass};
40
41// Constants
42pub const BLOCK_MEMORY_SIZE: usize = 32 * 1024;
43pub const CACHE_LINE_SIZE: usize = 64;