Expand description
Safe, idiomatic Rust wrapper over Intel oneAPI Math Kernel Library (oneMKL).
For the raw FFI surface, see onemkl-sys.
§Quick orientation by use case
- Dense linear algebra — see
blas(Level 1/2/3, batched, pack/compute, JIT, mixed-precision, compact) andlapack(solvers, factorizations, eigenvalue / SVD, auxiliary routines). - Sparse linear algebra — see
sparse(CSR/COO/CSC/BSR matrices, mv/mm/trsv, format conversion, sparse arithmetic),pardiso/dss(direct solvers),iss(CG / FGMRES),preconditioners(ILU0 / ILUT). - FFT and signal processing — see
fft(1D/2D/3D/N-D complex and real-input transforms with configurable scaling),pde(DCT / DST trigonometric transforms),rng::convolution(1D conv / corr). - Statistics and random numbers — see
rng(RNG streams, distributions) andrng::summary_stats(mean / variance / min / max / sum). - Mixed-precision ML kernels — see
blas::mixed_precisionfor bf16 / fp16 / FP8 / int8 GEMMs andblas::jitfor runtime-specialized small kernels. - Eigensolvers — see
lapackfor general drivers andfeastfor contour-integration solvers (find all eigenvalues in an interval). - Optimization — see
optimfor trust-region nonlinear least squares. - Spline / data fitting — see
data_fittingfor cubic splines (natural / Bessel / Akima / Hermite). - MKL service / runtime — see
service(threading, verbose mode, version).
Anything not yet wrapped is reachable through the raw bindings
re-exported as sys.
§A minimal example
use onemkl::prelude::*;
use onemkl::blas::level3::gemm;
// Compute C = A * B + 0 * C for two 2×2 matrices.
let a_data = vec![1.0_f64, 2.0, 3.0, 4.0];
let b_data = vec![5.0_f64, 6.0, 7.0, 8.0];
let mut c_data = vec![0.0_f64; 4];
let a = MatrixRef::new(&a_data, 2, 2, Layout::RowMajor).unwrap();
let b = MatrixRef::new(&b_data, 2, 2, Layout::RowMajor).unwrap();
let mut c = MatrixMut::new(&mut c_data, 2, 2, Layout::RowMajor).unwrap();
gemm(
Transpose::NoTrans, Transpose::NoTrans,
1.0, &a, &b, 0.0, &mut c,
).unwrap();
// c_data ≈ [19, 22, 43, 50].§Per-domain features
Each major oneMKL domain is gated by a Cargo feature so users can opt
out of unused parts. All domain features are enabled by default.
Foundation modules (error, enums, matrix, scalar, and
service) are always built.
| Feature | Module | What’s inside |
|---|---|---|
blas | blas | Level 1/2/3, batched (strided + pointer-array), pack/compute, JIT, mixed precision (bf16/f16/FP8/int8), compact |
data-fitting | data_fitting | Cubic splines (natural / Bessel / Akima / Hermite) |
dss | dss | Direct sparse solver with statistics readout |
feast | feast | Contour-integration eigensolver (dense, CSR, banded, generalized) |
fft | fft | DFTI 1D / 2D / 3D / N-D, complex and real-input, configurable scaling |
iss | iss | CG / FGMRES with closure or step-by-step session API |
lapack | lapack | Solvers, factorizations, eigenvalue / SVD, auxiliary (lacpy / lange / gecon / laswp / larfg) |
optim | optim | Trust-region nonlinear least squares |
pardiso | pardiso | Stateful direct sparse solver, pardiso_64, pivot callback |
pde | pde | Trigonometric transforms (DCT / DST) for spectral PDE solvers |
preconditioners | preconditioners | ILU0 / ILUT and apply_ilu |
rng | rng | VSL streams, distributions, 1-D conv/corr, summary statistics |
sparse | sparse | Inspector-Executor sparse: CSR/COO/CSC/BSR, mv/mm/trsv, copy/convert, add/spmm/spmmd |
vm | vm | Element-wise vector math |
For a minimal build:
onemkl = { version = "...", default-features = false, features = [
"lp64", "threading-sequential", "link-dynamic", # required
"blas", "lapack", # whatever you need
] }Until a domain has a safe wrapper, the raw bindings are accessible via
sys.
§Building against MKL
The build script in onemkl-sys searches in this order:
MKLROOTenvironment variable.ONEMKL_SYS_INCLUDE_DIR/ONEMKL_SYS_LIB_DIRoverrides.ONEAPI_ROOT/mkl/latest.- Platform-standard install paths (
C:\Program Files (x86)\Intel\oneAPIon Windows,/opt/intel/oneapion Linux/macOS).
At runtime MKL’s bin/ (or lib/) directory must be on the loader
search path so that the dynamic libraries can be found.
Re-exports§
pub use enums::Diag;pub use enums::Layout;pub use enums::Side;pub use enums::Transpose;pub use enums::UpLo;pub use error::Error;pub use error::Result;pub use error::SparseStatus;pub use matrix::MatrixMut;pub use matrix::MatrixRef;pub use scalar::ComplexScalar;pub use scalar::RealScalar;pub use scalar::Scalar;pub use onemkl_sys as sys;
Modules§
- blas
- Basic Linear Algebra Subprograms (BLAS).
- data_
fitting - Data fitting — 1-D spline interpolation and integration.
- dss
- Direct Sparse Solver (DSS) — alternative interface to oneMKL PARDISO with a slightly more verbose but cleaner API.
- enums
- BLAS / LAPACK enumeration types.
- error
- Unified error types for the safe oneMKL wrapper.
- feast
- Extended Eigensolver — the FEAST contour-integration eigensolver.
- fft
- Discrete Fourier Transform (DFT) — fast Fourier transform via the oneMKL DFTI interface.
- iss
- Iterative sparse solvers — Conjugate Gradient (CG) and Flexible GMRES (FGMRES) via oneMKL’s RCI (reverse-communication interface).
- lapack
- LAPACK linear algebra routines.
- matrix
- Strided matrix views.
- optim
- Nonlinear optimization — trust-region nonlinear least-squares (TRNLS) and bound-constrained variant (TRNLSPBC).
- pardiso
- Intel oneMKL PARDISO direct sparse solver.
- pde
- PDE support — trigonometric transforms (DCT / DST) used in spectral PDE solvers and signal processing.
- preconditioners
- Preconditioners for iterative sparse solvers — Incomplete LU
factorization (
ILU0andILUT). - prelude
- Convenience prelude exporting the items most numerical Rust code
will reach for: foundation enums (
Layout,Transpose,UpLo,Side,Diag), theError/Resulttypes, matrix views, and the per-domain scalar traits when their feature is enabled. - rng
- Random number generation via the Vector Statistical Library (VSL).
- scalar
- Scalar type abstractions used throughout oneMKL.
- service
- Service routines: version info, threading control, memory tracking, verbose mode, and overall library lifecycle.
- sparse
- Inspector-Executor Sparse BLAS — sparse linear algebra with reusable handles.
- vm
- Vector Mathematical Functions (VM).