Skip to main content

Crate tenferro_cpu

Crate tenferro_cpu 

Source
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.
BufferPoolStats
Snapshot of typed host buffers retained by a BufferPool.
CpuBatchPolicy
A batch strategy together with the CpuBatchThresholds Auto applies.
CpuBatchThresholds
The cost and fan-out model CpuBatchStrategy::Auto applies.
CpuEngine
A caller-held CPU execution engine.
CpuPlanCache
A shareable, bounded cache of immutable CPU numerical plans.
IndexedPlanCacheLimits
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 Exec tokens place work on.
PoolBuilder
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§

CpuBatchStrategy
How the items of one batched operation are split over a thread budget.
CpuEngineError
Typed refusals reported by a CpuEngine before an operation runs.

Traits§

BinaryScalarOp
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 CpuEngine under engine_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 f on engine with policy as the effective CPU batch policy.