Skip to main content

Crate oxicuda_backend

Crate oxicuda_backend 

Source
Expand description

Abstract compute backend for GPU-accelerated operations.

The ComputeBackend trait defines the interface for GPU computation, allowing higher-level crates (SciRS2, oxionnx, ToRSh, TrustformeRS) to use GPU acceleration without coupling to specific GPU APIs.

§Architecture

┌─────────────────────────────┐
│  SciRS2 / ToRSh / oxionnx  │
│         (consumers)         │
└─────────────┬───────────────┘
              │  dyn ComputeBackend
┌─────────────▼───────────────┐
│   BackendRegistry (select)  │
│       ComputeBackend        │
│     (trait definition)      │
└─────────────┬───────────────┘
              │
┌─────────────▼───────────────┐
│  CudaBackend / MetalBackend │
│  CpuBackend / NullBackend   │
│    (concrete impls)         │
└─────────────────────────────┘

§Beyond the trait

This crate also ships the host-side control plane that turns the bare trait into a usable multi-backend abstraction layer:

  • BackendKind — names every backend and ranks them by preference.
  • BackendRegistry — registers backends, probes availability, and does capability-based selection plus GPU→CPU fallback chains.
  • Capabilities / DeviceInfo — per-backend feature and device discovery.
  • CpuBackend — a genuinely-working pure-Rust reference backend (the always-available fallback and the numerical reference for conformance).
  • NullBackend — a scaffold that refuses every op, for testing dispatch.

None of the control-plane logic touches a GPU, so it is fully testable on a machine with no accelerator.

Structs§

BackendEntry
A backend known to the registry, plus the runtime facts needed to pick it.
BackendRegistry
A registry of compute backends with capability-aware selection.
Capabilities
Per-backend capability report.
CpuBackend
Pure-Rust host backend. Always available; never touches a GPU.
DeviceInfo
A single device exposed by a backend, in a backend-agnostic shape.
NullBackend
A no-op backend whose operations all return BackendError::Unsupported.
SelectionRequest
Required-feature predicate used to filter backends during selection.
TileShape
A GEMM tile-shape hint (tile_m, tile_n, tile_k) returned by ComputeBackend::recommended_tile_for.

Enums§

BackendError
Error type for backend operations.
BackendKind
One of the concrete compute backends OxiCUDA targets.
BackendTranspose
Transpose mode for matrix operations.
BinaryOp
Element-wise binary operation.
MemoryKind
Memory-type classification, abstracting each backend’s notion of where a buffer physically lives. Used by DeviceInfo and cross-backend transfer planning.
MixedPrecision
Reduced-precision input storage format for a mixed-precision GEMM.
OpClass
Routable operation classes used by BackendRegistry::route.
ReduceOp
Reduction operation applied along an axis.
UnaryOp
Element-wise unary operation.

Traits§

ComputeBackend
Abstract compute backend trait.

Functions§

default_tile_for
Default tile heuristic shared by the trait’s recommended_tile_for: small problems get a small tile (less wasted compute on the fringe), large problems get the canonical 128×128×8 tile, mid-size gets 64×64×16.
round_to_bf16
Round an f32 to bfloat16 storage and return the resulting f32.
round_to_f16
Round an f32 to IEEE-754 binary16 storage and return the resulting f32.

Type Aliases§

BackendResult
Result type for backend operations.