Thanks for your interest in rv-sparse. Pull requests, bug reports, documentation, and new kernels are all welcome.
Use the GitHub issue tracker for bugs and feature requests. Search existing issues first. If an issue already covers your case, add details there instead of opening a duplicate.
For anything larger than a bug fix, open an issue to discuss the approach before writing code. This helps make sure the change fits the project before implementation starts.
Fork the repository and work on a branch. Do not commit directly to main.
git checkout -b my-change
# work, commit
git push -u origin my-changeOpen a pull request against main. Keep each pull request focused on a single
fix or feature. Avoid reformatting or refactoring unrelated code in the same
change.
The pull request description should explain what the change does, how it was tested, and whether it changes the public API.
Before opening a pull request, build and run the tests:
make
make testFor a RISC-V vector build, set TARGET_ARCH=riscv. This uses the
riscv64-linux-gnu cross-toolchain, enables the vector extension, and runs the
tests under qemu-riscv64-static. Physical hardware is not required.
make test TARGET_ARCH=riscvOther build options include:
make BUILD_TYPE=debug # unoptimized build with debug symbols
make OPENMP=1 # enable OpenMP
make print-config # print the resolved toolchain and flagsTests are discovered automatically. A new .c file at the top level of
tests/ is picked up without any Makefile changes. Tests in tests/legacy/
cover superseded kernels and are not run.
See docs/directory_structure.md for the repository layout.
A change that does not build or breaks a test will not be merged. If you fix a bug, add a test that fails before the fix and passes after it.
The SpGEMM strategies shipped today share one Gustavson driver and differ only in how they accumulate. Adding another strategy that follows this design uses the same pattern:
- Add
src/kernels/spgemm/accum_<name>_f32.c. DefineRVSP_KERNEL_NAMEand includegustavson_core_f32.inc. The file provides onlyrvsp_accum_row. The driver and symbolic phase are shared. - Declare
rvsp_spgemm_<name>_f32andrvsp_spgemm_<name>_f32_numericinsrc/kernels/spgemm/rvsp_spgemm.h. The.incfile emits both functions, andnumeric_for()needs the second one declared. - Add the strategy to
rvsp_spgemm_algo_tininclude/rv_sparse_types.h. - Add the case to
numeric_for()insrc/core/spgemm_descr.c. Guard it with__riscv_vectorif it uses vector intrinsics. - Add the source to
VECTOR_SRCSin the Makefile if it must not be compiled for scalar targets.
The symbolic phase is shared, so a strategy following this design changes how values are accumulated but does not change the output structure.
If a contribution needs a different dataflow or a different approach to accumulation, open an issue first so we can decide how it should fit into the library.
The compute kernels assume canonical CSR input. This means row_ptr[0] is 0,
row_ptr is non-decreasing, column indices are in range, column indices are
sorted within each row, and no column repeats within a row.
The kernels do not check these conditions in the hot loop. Validate or canonicalize the input once before calling a kernel, and keep that work outside any timed region.
Vector kernels require the RISC-V V extension. If the extension is not available, the kernel should fail to compile rather than silently falling back to scalar code.
#if defined(__riscv_vector)
#include <riscv_vector.h>
#else
#error "accum_<name>_f32.c requires the RISC-V V extension"
#endifThe build system controls whether vector sources are compiled. Add the source
to VECTOR_SRCS so the Makefile excludes it when -march does not enable V.
For code that uses RVV intrinsics, add comments explaining the vector type, the memory access pattern, and any assumptions about index validity. Follow the style of the existing kernels.
include/rv_sparse.h and include/rv_sparse_types.h are the public API.
Keep the public API stable. Discuss any API change in an issue before implementing it.
rv-sparse is licensed under GPL-3.0-only, and contributions are accepted under the same license.
Add the SPDX header to new files:
/*
* Copyright (C) 2026 rv-sparse contributors
*
* SPDX-License-Identifier: GPL-3.0-only
*/