Focused CUDA sparse matrix-vector multiplication library
CSR + ELL formats · 4 kernels · explicit errors · minimal maintenance surface
GPU SpMV is a C++17 / CUDA library for sparse matrix-vector multiplication on NVIDIA GPUs. The repository now concentrates on the core library only:
- Storage: CSR and ELL sparse formats
- Execution: Scalar CSR, Vector CSR, Merge Path, and ELL kernels
- Engineering:
CudaBuffer<T>RAII, explicitSpMVError, CPU reference paths, focused tests
Non-core showcase modules and AI governance layers have been removed to keep the codebase smaller and easier to maintain.
git clone https://github.com/AICL-Lab/gpu-spmv.git
cd gpu-spmv
cmake --preset cuda-linux
cmake --build --preset cuda-linux
ctest --preset cuda-linuxCPU-only environments can use:
cmake -S . -B build-no-cuda -DSPMV_REQUIRE_CUDA=OFF
cmake --build build-no-cuda
ctest --test-dir build-no-cuda --output-on-failureOn Linux, GPU builds now have first-class presets that pin the system GCC/G++ host toolchain and avoid Conda compiler leakage:
cmake --preset cuda-linux
cmake --build --preset cuda-linux
ctest --preset cuda-linuxFor release builds:
cmake --preset cuda-linux-release
cmake --build --preset cuda-linux-release
ctest --preset cuda-linux-release#include <spmv/csr_matrix.h>
#include <spmv/cuda_buffer.h>
#include <spmv/spmv.h>
int main() {
float dense[] = {
1.0f, 0.0f, 2.0f,
0.0f, 3.0f, 4.0f,
0.0f, 0.0f, 5.0f,
};
spmv::CSRMatrix* csr = spmv::csr_create(3, 3, 5);
spmv::csr_from_dense(csr, dense, 3, 3);
spmv::csr_to_gpu(csr);
spmv::CudaBuffer<float> d_x(3);
spmv::CudaBuffer<float> d_y(3);
const float h_x[] = {1.0f, 1.0f, 1.0f};
cudaMemcpy(d_x.data(), h_x, sizeof(h_x), cudaMemcpyHostToDevice);
spmv::SpMVConfig config = spmv::spmv_auto_config(csr);
spmv::SpMVResult result = spmv::spmv_csr(csr, d_x.data(), d_y.data(), &config, 3);
spmv::csr_destroy(csr);
return result.error_code == 0 ? 0 : 1;
}gpu-spmv/
├── include/spmv/ # Public headers
├── src/ # Core library implementation
├── tests/ # Unit and regression tests
├── docs/ # GitHub Pages site
├── CHANGELOG.md # Single project changelog
└── CMakeLists.txt
Documentation is published at https://aicl-lab.github.io/gpu-spmv/.
| Page | Purpose |
|---|---|
| Quick Start | Installation and build flow |
| API Reference | Core public API |
| Architecture | Data flow and kernel selection |
| Performance Guide | Practical tuning notes |
| Examples | End-to-end usage |
Version history is kept only in the root CHANGELOG.md.
Keep changes boring and verifiable:
- Make the smallest change that improves the core library.
- Preserve RAII resource handling; do not introduce raw
cudaMalloc/cudaFree. - Run the existing build and test commands.
- Update the relevant documentation when behavior changes.
See CONTRIBUTING.md for the short contribution workflow.
MIT License. See LICENSE.