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
24mod copy;
25mod fuse;
26mod host;
27mod hptt;
28
29// Re-export primary API
30pub use copy::{
31    copy_conj_into, copy_conj_into_uninit, copy_into, copy_into_col_major, copy_into_uninit,
32};
33pub use fuse::{plan_bilateral_fusion, BilateralFusionPlan, FusionPlanError};
34pub use host::{copy_ns_per_element, copy_ns_per_element_of, HostClass};
35
36// Constants
37pub const BLOCK_MEMORY_SIZE: usize = 32 * 1024;
38pub const CACHE_LINE_SIZE: usize = 64;