Crate leopard_vec

Crate leopard_vec 

Source
Expand description

§Leopard

A high-performance parallelized vector container library with deferred execution.

Leopard provides LVec, a parallel vector container that records operations and executes them in a single bulk parallel pass. This design minimizes thread pool creation overhead by batching all operations together.

§Key Features

  • Deferred Execution: Operations are recorded between LQueue::start and LQueue::end, then executed in one parallel batch
  • Type-Agnostic Queue: A single LQueue can manage LVec<T> of different types
  • SIMD-Style Masking: Boolean masks with blend, select, and masked operations
  • Operator Overloading: Natural syntax with +, -, *, / operators
  • Dependency Graph: Operations are automatically ordered based on data dependencies

§Quick Start

use leopard::{LQueue, LVec, LMask};

let q = LQueue::new();
let x: LVec<f64> = q.lvec_with_capacity(1000);
let y: LVec<f64> = q.lvec_with_capacity(1000);

q.start();
let x = x.fill_with(|i| i as f64);
let y = y.fill_with(|i| (i * 2) as f64);
let z = &x * &y + &x;
q.end();

let result = z.materialize().unwrap();

§How It Works

  1. Recording Phase: Between q.start() and q.end(), operations create “pending” LVec instances and push operation descriptors to the queue.

  2. Dependency Analysis: The queue builds a dependency graph to determine execution order.

  3. Parallel Execution: At q.end(), operations are executed level-by-level. Each operation uses Rayon’s parallel iterators for element-wise computation.

  4. Result Retrieval: materialize() returns the computed Arc<Vec<T>> for any pending LVec.

Structs§

LMask
A boolean mask for parallel conditional operations.
LQueue
The operation queue that records and executes parallel operations.
LVec
A parallelized vector container with deferred execution.