MMatrix is a C project for matrix and tensor operations, built with Bazel. It targets macOS and Linux, with CPU acceleration (BLAS/OpenMP) and optional MPS/Metal support on Apple Silicon.
app/matrix: dense (sm,dm) and sparse (dms) matrix modulesapp/vector: dense (sv,dv), strided view (vv), sparse (dvs) and fixed-size geometry (vec3) vector modulesapp/matrix:sm_mps: explicit Apple Silicon MPS path for GPU-resident large dense GEMMs; check around1024^3, recommended for2048^3-class matrices.app/tensor: N-dimensional tensor module (st) with CPU and optional MPS backend (only on Apple Silicon).
Install system libraries on macOS (Homebrew):
brew install openblas suite-sparse llvmopenmp (@openmp//:libomp) and matio (@matio//:matio) are resolved via Bzlmod from the configured Bazel registry.
llvm is optional for normal builds, but useful for tooling such as clang-doc.
Build everything:
bazel build //...Build specific modules:
bazel build //app/matrix
bazel build //app/vector
bazel build //app/tensorOptional backend configs (matrix):
bazel build //app/matrix --config=accelerate
bazel build //app/matrix --config=openblas
bazel build //app/matrix --config=openmp_onlybazel test //...Unit tests are in app/matrix/tests/ and app/tensor/tests/.
Build docs:
bazel build //:docs
Serve docs locally:
bazel run //:docs_serve
Regenerate Tensor + Matrix API pages from public header docs (Doxygen XML -> Markdown):
bazel run //:docs_refresh_api
The short aliases //:docs and //:docs_serve are the recommended user entrypoints.
Install headers and libraries to a custom directory:
bazel run //:matrix_installer -- $(PWD)/lib/matrixModes:
bazel run //:matrix_installer -- --mode=standard $(PWD)/lib/matrix
bazel run //:matrix_installer -- --mode=bundle $(PWD)/lib/matrix_bundle- macOS ARM64 (Apple Silicon)
- Linux x86-64
MIT (see LICENSE.txt).
Third-party licenses are provided by the respective upstream projects.