scirs2-core
Foundation crate for the SciRS2 scientific computing ecosystem.
scirs2-core provides the essential utilities, abstractions, and optimizations shared by every SciRS2 module. It enforces the SciRS2 POLICY: only scirs2-core uses external dependencies directly; all other crates consume re-exports and abstractions from this crate.
Installation
[]
= "0.3.0"
With optional feature flags:
[]
= { = "0.3.0", = ["validation", "simd", "parallel", "gpu"] }
Features (v0.3.0)
Performance
- SIMD-accelerated array operations (SSE, AVX, AVX2, AVX-512, NEON) — up to 14x speedup over scalar
- Ultra-optimized SIMD with multiple accumulators, FMA, 8-way loop unrolling, software pipelining
- Work-stealing scheduler with NUMA-aware thread placement
- Parallel iterators (parallel map, reduce, scan, map-reduce)
- Async utilities: semaphore, channel, timeout, rate limiter
- Cache-oblivious B-tree and matrix multiply algorithms
- GPU memory management: pool allocator, slab allocator, buddy allocator, best-fit allocator
Data Structures
- Lock-free queue, stack, and hash map (using CAS, epoch-based reclamation)
- HAMT (Hash Array Mapped Trie) persistent functional data structure
- Persistent red-black tree (immutable update)
- Interval tree, segment tree, van Emde Boas tree
- Skip list, finger tree, B-tree variants
- String interning (global thread-safe interner)
- Task graph with topological scheduling
Memory Management
- Arena allocator (bump allocation)
- Slab allocator (fixed-size object pools)
- NUMA-aware allocator with topology detection
- Object pool with configurable capacity
- Zero-copy buffer management
- Memory-mapped array support (
MemoryMappedArray) - Chunked out-of-core array processing
Distributed Computing
- Ring allreduce (parameter averaging across nodes)
- Parameter server (key-value store with async push/pull)
- Collective operations: broadcast, scatter, gather, allgather, reduce-scatter
- Lock-free distributed data structures
Validation
- Schema-based data validation with constraints
- Config file validation (JSON/TOML/YAML compatible schemas)
- Assertion helpers for numeric arrays (check_finite, check_positive, check_shape)
- Type coercion utilities
Scientific Infrastructure
- 30+ mathematical constants, 40+ physical constants
- Generic numeric traits (
Float,ScalarElem,LinalgScalar, etc.) - Complex number support via
num-complexre-exports - Arbitrary precision arithmetic (multi-precision floats and integers)
- Interval arithmetic (verified computing)
- Extended precision accumulators (Kahan, pairwise)
ML Pipeline
Transformertrait for data preprocessing stepsPredictortrait for model inferenceEvaluatortrait for scoring and metricsPipelinestruct for chaining transformers and a final predictor- Batch inference utilities
Observability
- Structured logging (tracing-compatible)
- Metrics collector (counters, histograms, gauges)
- GPU profiler and perf-event profiler stubs
- Distributed tracing integration
Other Utilities
- Bioinformatics: sequence alignment extensions, motif finding, sequence type utilities
- Geospatial: geodesic calculations, projections, spatial indexing
- Quantum computing primitives: qubit representation, gate operations, measurement simulation
- Reactive programming primitives: observable, subject, operators
- Combinatorics utilities: permutations, combinations, partitions
- Concurrent collections: concurrent hash map, priority queue
Usage Examples
Basic validation
use ;
use array;
let data = array!;
check_finite?;
check_positive?;
SIMD operations
use ;
let a = vec!;
let b = vec!;
let sum = simd_add_f64;
let dot = simd_dot_f64;
Parallel processing
use ;
let data: = .map.collect;
let squares: = parallel_map?;
let total: f64 = parallel_reduce?;
Lock-free queue
use LockFreeQueue;
let queue: = new;
queue.push;
let val = queue.pop; // Some(42)
ML pipeline
use ;
// Build a pipeline: StandardScaler -> LinearModel
let pipeline = builder
.add_transformer
.set_predictor
.build;
let predictions = pipeline.predict?;
Feature Flags
| Feature | Description |
|---|---|
validation |
Data validation helpers (check_finite, schema validation) |
simd |
SIMD-accelerated array operations |
parallel |
Multi-threaded parallel processing via Rayon |
gpu |
GPU memory management and kernel abstractions |
cuda |
NVIDIA CUDA backend (requires gpu) |
memory_management |
Advanced memory utilities (arena, slab, pool) |
array_protocol |
Extensible unified array interface |
logging |
Structured logging integration |
profiling |
Performance profiling stubs |
std |
Standard library support (enabled by default; disable for no_std) |
all |
All stable features |
Links
License
Licensed under the Apache License 2.0. See LICENSE for details.