tensorlogic-oxicuda-rng
GPU-accelerated random number generation for TensorLogic with pure-Rust CPU fallback.
Provides a unified RngEngine that seamlessly dispatches to either a pure-Rust CPU
backend (PCG-XSH-RR + Box-Muller) or an OxiCUDA GPU backend — chosen at construction
time with no API change.
Feature flags
| Feature | Default | Effect |
|---|---|---|
cpu |
yes | Pure-Rust CPU RNG via scirs2-core::random (PCG-XSH-RR + Box-Muller). |
gpu |
no | Enables oxicuda-rand, oxicuda-driver, oxicuda-memory. Requires an NVIDIA driver at runtime — no CUDA SDK needed. |
Quick start
use ;
API
RngEngine
| Method | Description |
|---|---|
new(kind, seed) |
Create engine for Cpu or Gpu backend |
kind() |
Returns RngEngineKind of this engine |
is_gpu() |
Returns true if running on GPU |
uniform_f32(out) |
Fill slice with samples ∈ [0, 1) |
normal_f32(out, mean, std_dev) |
Fill slice with Gaussian samples |
bernoulli(out, p) |
Fill u8 slice with 0/1 Bernoulli samples |
RngEngineKind
| Variant | Description |
|---|---|
Cpu |
Pure-Rust PCG-XSH-RR generator |
Gpu |
OxiCUDA GPU RNG (requires gpu feature and NVIDIA driver) |
Requirements
- CPU features work on all platforms (pure Rust, no native deps)
- GPU features require
--features gpuand an NVIDIA GPU with CUDA driver at runtime
License
Apache-2.0 — see LICENSE for details.