Expand description
CPU resources for the tcontract stack: scratch memory and contraction policy.
Placement (where tasks run, and how many at once) belongs to
threadteam: a host owns a threadteam::Pool, lends it through
Pool, and each operation takes an Exec, a bundle of one
threadteam::Exec token, an optional workspace and a BatchPolicy.
This crate starts no task and exposes no scheduler type. See
PERFORMANCE_TIPS.md, CPU Threading Contract.
§Examples
use tcontract_exec::{Exec, Pool};
let sp = threadteam::Pool::builder().threads(2).build().unwrap();
let pool = Pool::borrow(&sp);
let mut exec = Exec::new(&pool, 2).unwrap();
assert_eq!(exec.budget(), pool.size().min(2));
let total = std::sync::atomic::AtomicUsize::new(0);
exec.token().for_ranges(100, 1.try_into().unwrap(), |r| {
total.fetch_add(r.len(), std::sync::atomic::Ordering::Relaxed);
});
assert_eq!(total.into_inner(), 100);Re-exports§
pub use batch::BatchDecision;pub use batch::BatchPolicy;pub use batch::BatchQuery;pub use batch::BatchStrategy;pub use batch::WorkModel;
Modules§
- batch
- Batch lane policy: the shared vocabulary and the one decision function.
- host
- Host class and the serial GEMM rate of each class.
Structs§
- Arena
Provider - A workspace owner: per-thread worker slots plus a free list of team sets.
- Exec
- The resources one operation runs with: a placement token, optional reusable scratch, and the batch lane policy.
- Pool
- The CPU resources one owner lends to every operation: a
threadteam::Pool(where tasks run) and anArenaProvider(where scratch lives). - Team
Lease - An exclusive loan of a team set, returned to its owner on drop.
- Workspace
- A caller-owned, bounded workspace: an
ArenaProviderpre-sized to oneWorkspaceReq, so a steady-state execute whose requirement is within the bound allocates nothing. - Workspace
Req - Bytes and counts one execute needs. Buffer sizes are bytes because the provider is element-type erased: the driver knows the element type and converts its real counts once.
- Workspace
Stats - What an owner currently holds and currently lends out.
Enums§
- Exec
Error - Errors from building or using an
Exec. - Host
Class - The class of the machine, keyed by the kernel dispatch it will take, not by
the CPU model. Detected once per process by
HostClass::detect.
Traits§
- Workspace
Provider - Storage an execution may borrow. Implemented by the owner; the driver only ever sees this trait, so nothing here depends on the driver.
Functions§
- with_
faer_ par - Runs
fwith the parallelism faer should use fortoken.