Expand description
CPU execution engine, kernels and provider selection.
A CpuEngine owns one Pool built by the caller (or none) and the
workspace its operations write. Every operation takes the engine as &mut:
use tenferro_cpu::{Pool, CpuEngine};
use tenferro_tensor::{Tensor, TensorElementwise, TensorRead};
let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
let b = Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0])?;
let mut serial = CpuEngine::serial();
let c = serial.add_read(TensorRead::from_tensor(&a), TensorRead::from_tensor(&b))?;
assert_eq!(c.as_slice::<f64>()?, &[4.0, 6.0]);
let mut parallel = CpuEngine::new(Pool::builder().threads(2).build()?);
let d = parallel.add_read(TensorRead::from_tensor(&a), TensorRead::from_tensor(&b))?;
assert_eq!(d.as_slice::<f64>()?, &[4.0, 6.0]);Re-exports§
pub use threadteam;pub use faer;
Modules§
- backend
- Pool helpers shared by the CPU engine’s operations.
Macros§
- same_
variant_ pair - Dispatch a same-variant pair of tensors to a typed kernel.
- same_
variant_ unary - Dispatch a single tensor to a typed kernel and erase its result.
Structs§
- AddOp
- Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Addition.
- Buffer
Pool Stats - Snapshot of typed host buffers retained by a
BufferPool. - CpuBatch
Policy - A batch strategy together with the
CpuBatchThresholdsAutoapplies. - CpuBatch
Thresholds - The cost and fan-out model
CpuBatchStrategy::Autoapplies. - CpuEngine
- A caller-held CPU execution engine.
- CpuPlan
Cache - A shareable, bounded cache of immutable CPU numerical plans.
- Indexed
Plan Cache Limits - Limits for the CPU indexed-plan cache.
- MulOp
- Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Multiplication.
- Pool
- A fixed set of worker threads that
Exectokens place work on. - Pool
Builder - Configuration of a
Pool. - SubOp
- Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Subtraction.
Enums§
- CpuBatch
Strategy - How the items of one batched operation are split over a thread budget.
- CpuEngine
Error - Typed refusals reported by a
CpuEnginebefore an operation runs.
Traits§
- Binary
Scalar Op - Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. A binary operation between two scalars of the same type.
Functions§
- cpu_
capabilities - Return the CPU backend operation capability descriptor table.
- runtime_
engine_ id - Return the canonical CPU runtime engine identifier.
- runtime_
engine_ registration - Build a runtime engine registration for a
CpuEngine. - runtime_
engine_ registration_ with_ id - Build a runtime engine registration for a
CpuEngineunderengine_id. - runtime_
hardware_ class - Return the canonical CPU runtime hardware class.
- scalar_
binary_ into - Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Apply a named binary operation elementwise into a caller-owned destination.
- scalar_
fold - Ordinary CPU entry points that take a caller-provided destination and the
caller’s own arithmetic instead of the typed pool.
Fold every element of a caller-owned tensor with a named associative
operation, starting from
init. - with_
batch_ policy - Run
fonenginewithpolicyas the effective CPU batch policy.