NVIDIA/MatX

An efficient C++20 GPU numerical computing library with Python-like syntax

What it solves

MatX provides a way to write high-performance numerical computing code using a familiar, NumPy-like array syntax in C++. It eliminates the need to hand-write complex CUDA kernels for common numerical pipelines, reducing implementation code by up to 92% while maintaining or exceeding the speed of handwritten CUDA code.

How it works

MatX uses a lazy expression model where numerical operations (broadcasting, slicing, reductions, linear algebra) are composed into expressions rather than executed immediately. Users can then choose an "executor" to run these expressions. The cudaExecutor leverages optimized CUDA libraries, while the CUDAJITExecutor can fuse multiple compatible operations—including those from libraries like cuBLASDx, cuSolverDx, cuFFTDx, and cuRANDDx—into a single runtime-generated kernel. This fusion removes intermediate memory traffic and separate kernel launches, which is critical for memory-bound workloads.

Who it’s for

It is designed for developers who need the productivity of array-based programming (like Python's NumPy) but require the native speed and control of C++ and NVIDIA GPUs, specifically for real-time processing or high-throughput numerical analysis.

Highlights

  • NumPy-style syntax in C++: Supports arbitrary-rank tensors, broadcasting, and slicing.
  • JIT Kernel Fusion: Fuses numerical pipelines into a single kernel to eliminate intermediate tensors and launch overhead.
  • ** uma NVIDIA GPU speed**: Reaches near-handwritten CUDA performance with significantly less code.
  • Cross-Platform Execution: Supports both NVIDIA GPUs and multithreaded CPUs (via NVPL, FFTW, OpenBLAS, or BLIS).
  • Header-only library: Easy integration into C++20 projects via CMake.

Related

  • Project
  • Project
  • Project
  • Project
  • Project