-
Notifications
You must be signed in to change notification settings - Fork 194
draft for joss paper on sparse matrices #1032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jalvesz
wants to merge
22
commits into
fortran-lang:joss
Choose a base branch
from
jalvesz:joss
base: joss
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+296
−0
Open
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ffc46a7
first draft for stdlib_sparse paper
jalvesz 60de278
try actions change to output pdf
jalvesz 01e9469
rollback actions name
jalvesz 678c315
try change name
jalvesz b21c165
try changing path
jalvesz e3fadee
add orcid
jalvesz e01c83e
try mv
jalvesz 7d3a8c0
trial
jalvesz c7db002
trial
jalvesz d1215cc
trial
jalvesz 1b1983b
updates
jalvesz ea9b2ca
update orcid
jalvesz f09171d
Update joss/paper_sparse.md
jalvesz fadcb3e
Update joss/paper_sparse.md
jalvesz 34ff16b
Update joss/paper_sparse.md
jalvesz 4895e92
Update joss/paper_sparse.md
jalvesz fef07b4
Update joss/paper_sparse.md
jalvesz e21f94b
mention psblas
jalvesz b45467c
reviews from Ivan
jalvesz d40d39f
move files to respect the joss name "paper" only
jalvesz 29ad30e
forgot to rename bib file
jalvesz b341be7
fix multi citation
jalvesz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Draft PDF | ||
on: | ||
push: | ||
paths: | ||
- joss/** | ||
- .github/workflows/draft-pdf.yml | ||
|
||
jobs: | ||
paper: | ||
runs-on: ubuntu-latest | ||
name: Paper Draft | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build draft PDF | ||
uses: openjournals/openjournals-draft-action@master | ||
with: | ||
journal: joss | ||
paper-path: joss/paper_sparse.md | ||
|
||
- name: Upload PDF | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: paper | ||
path: joss/paper.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
@book{saad2003iterative, | ||
title={Iterative methods for sparse linear systems}, | ||
author={Saad, Yousef}, | ||
year={2003}, | ||
publisher={SIAM} | ||
} | ||
@article{MUMPS:1, | ||
title = {A Fully Asynchronous Multifrontal Solver Using Distributed Dynamic Scheduling}, | ||
author = {P.R. Amestoy and I. S. Duff and J. Koster and J.-Y. L'Excellent}, | ||
journal = {SIAM Journal on Matrix Analysis and Applications}, | ||
volume = {23}, | ||
number = {1}, | ||
year = {2001}, | ||
pages = {15-41} | ||
} | ||
@article{MUMPS:2, | ||
title = {{Performance and Scalability of the Block Low-Rank Multifrontal | ||
Factorization on Multicore Architectures}}, | ||
author = {P.R. Amestoy and A. Buttari and J.-Y. L'Excellent and T. Mary}, | ||
journal = {ACM Transactions on Mathematical Software}, | ||
volume = 45, | ||
issue = 1, | ||
pages = {2:1--2:26}, | ||
year={2019}, | ||
} | ||
|
||
@Misc{petsc-web-page, | ||
author = {Satish Balay and Shrirang Abhyankar and Mark~F. Adams and Jed Brown and Peter Brune | ||
and Kris Buschelman and Lisandro Dalcin and Victor Eijkhout and William~D. Gropp | ||
and Dinesh Kaushik and Matthew~G. Knepley | ||
and Lois Curfman McInnes and Karl Rupp and Barry~F. Smith | ||
and Stefano Zampini and Hong Zhang}, | ||
title = {{PETS}c {W}eb page}, | ||
url = {http://www.mcs.anl.gov/petsc}, | ||
howpublished = {\url{http://www.mcs.anl.gov/petsc}}, | ||
year = {2015} | ||
} | ||
|
||
@techreport{bell2008efficient, | ||
title={Efficient sparse matrix-vector multiplication on CUDA}, | ||
author={Bell, Nathan and Garland, Michael}, | ||
year={2008}, | ||
institution={Nvidia Technical Report NVR-2008-004, Nvidia Corporation} | ||
} | ||
@book{magoules2017calcul, | ||
title={Calcul scientifique parall{\`e}le-2e {\'e}d.: Cours, exemples avec openMP et MPI, exercices corrig{\'e}s}, | ||
author={Magoul{\`e}s, Fr{\'e}d{\'e}ric and Roux, Fran{\c{c}}ois-Xavier}, | ||
year={2017}, | ||
publisher={Dunod} | ||
} | ||
@article{anzt2014implementing, | ||
title={Implementing a Sparse Matrix Vector Product for the SELL-C/SELL-C-$\sigma$ formats on NVIDIA GPUs}, | ||
author={Anzt, Hartwig and Tomov, Stanimire and Dongarra, Jack}, | ||
journal={University of Tennessee, Tech. Rep. ut-eecs-14-727}, | ||
year={2014} | ||
} | ||
@software{fsparse2024, | ||
author = {José Alves and | ||
Samuele Giuli}, | ||
title = {FSPARSE: Fortran Sparse Gallery library}, | ||
month = may, | ||
year = 2024, | ||
publisher = {Zenodo}, | ||
version = {v0.1.1}, | ||
doi = {10.5281/zenodo.11175000}, | ||
url = {https://doi.org/10.5281/zenodo.11175000}, | ||
} | ||
@ARTICLE{2020SciPy-NMeth, | ||
author = {Virtanen, Pauli and Gommers, Ralf and Oliphant, Travis E. and | ||
Haberland, Matt and Reddy, Tyler and Cournapeau, David and | ||
Burovski, Evgeni and Peterson, Pearu and Weckesser, Warren and | ||
Bright, Jonathan and {van der Walt}, St{\'e}fan J. and | ||
Brett, Matthew and Wilson, Joshua and Millman, K. Jarrod and | ||
Mayorov, Nikolay and Nelson, Andrew R. J. and Jones, Eric and | ||
Kern, Robert and Larson, Eric and Carey, C J and | ||
Polat, {\.I}lhan and Feng, Yu and Moore, Eric W. and | ||
{VanderPlas}, Jake and Laxalde, Denis and Perktold, Josef and | ||
Cimrman, Robert and Henriksen, Ian and Quintero, E. A. and | ||
Harris, Charles R. and Archibald, Anne M. and | ||
Ribeiro, Ant{\^o}nio H. and Pedregosa, Fabian and | ||
{van Mulbregt}, Paul and {SciPy 1.0 Contributors}}, | ||
title = {{{SciPy} 1.0: Fundamental Algorithms for Scientific | ||
Computing in Python}}, | ||
journal = {Nature Methods}, | ||
year = {2020}, | ||
volume = {17}, | ||
pages = {261--272}, | ||
adsurl = {https://rdcu.be/b08Wh}, | ||
doi = {10.1038/s41592-019-0686-2}, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
--- | ||
title: 'stdlib sparse: A high level Fortran sparse matrix library' | ||
tags: | ||
- Fortran | ||
- linear algebra | ||
- sparse matrix | ||
authors: | ||
- name: José Alves | ||
corresponding: true | ||
orcid: 0000-0001-9448-0145 | ||
affiliation: 1 | ||
- name: Ivan Pribec | ||
affiliation: 2 | ||
orcid: 0000-0001-8436-882X | ||
- name: Jeremie Vandenplas | ||
affiliation: 3 | ||
orcid: 0000-0002-2554-072X | ||
- name: Federico Perini | ||
affiliation: 4 | ||
orcid: 0000-0001-8017-1747 | ||
affiliations: | ||
- name: Transvalor S.A., France | ||
index: 1 | ||
- name: Leibniz Centre of Supercomputing, Germany | ||
index: 2 | ||
- name: Wageningen University, The Netherlands | ||
index: 3 | ||
- name: Wisconsin Engine Research Consultants, USA | ||
index: 4 | ||
date: 17 September 2025 | ||
bibliography: paper_sparse.bib | ||
--- | ||
|
||
# Summary | ||
|
||
Sparse matrices are a core building block in scientific computing, particularly in fields such as computational physics, engineering, and graph analysis. Despite Fortran’s long tradition in numerical computing, its ecosystem lacks a canonical, modern, high-level library for sparse data structures. | ||
|
||
We present stdlib_sparse, a sparse matrix library implemented in modern Fortran as part of the (community) Fortran Standard Library (stdlib). It provides well-defined sparse storage formats, conversion routines, and core operations such as sparse matrix–vector multiplication. This library aims to improve reproducibility, interoperability, and performance across Fortran applications by offering standardized, extensible data structures. | ||
jalvesz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
# Statement of need | ||
|
||
Many scientific applications require sparse linear algebra routines for efficient storage and computation with large, structured matrices. Fortran users have traditionally relied on external libraries (e.g. SPARSKIT, MUMPS, SuiteSparse) or custom implementations. This fragmentation leads to challenges in portability, maintainability, and discoverability. | ||
|
||
The stdlib_sparse library addresses this gap by offering: | ||
|
||
* A consistent set of sparse matrix formats (COO, CSR, CSC, ELLPACK, SELL-C). | ||
* Format conversion routines to enable interoperability. | ||
* Standardized operations such as sparse matrix–vector multiplication (SpMV). | ||
* A unified API, following modern Fortran practices, as part of the official Fortran stdlib project. | ||
|
||
By integrating directly into stdlib, stdlib_sparse lowers the barrier for Fortran developers to adopt sparse methods, reduces code duplication, and promotes best practices for numerical software development. | ||
jalvesz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
# Related work | ||
|
||
Several sparse libraries exist in Fortran and other languages: | ||
|
||
* SPARSKIT (Fortran 77, Saad 1994) — influential, but outdated syntax and limited interoperability [@saad2003iterative]. | ||
* MUMPS [@MUMPS:1] and PETSc [@petsc-web-page] — high-performance solvers written in Fortran/C with broad functionality, but heavy dependencies and steeper learning curve. | ||
* SciPy.sparse (Python) [@2020SciPy-NMeth] and Eigen (C++) — modern high-level APIs in other ecosystems, demonstrating the value of standardized interfaces. | ||
|
||
Compared to these, stdlib_sparse focuses on providing a lightweight, modern Fortran interface integrated into the stdlib, emphasizing portability and extensibility rather than complete solver functionality. | ||
|
||
# Design and implementation | ||
## Data structures | ||
|
||
All sparse formats extend an abstract base type sparse_type, which holds metadata such as number of rows, columns, and nonzeros. Implementations include: | ||
jalvesz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
* COO: coordinate (triplet) format. | ||
* CSR: compressed sparse row (Yale) format. | ||
* CSC: compressed sparse column format. | ||
* ELLPACK: fixed number of nonzeros per row, suited for vectorization. | ||
* SELL-C: sliced ELLPACK, balancing CSR and ELLPACK trade-offs [@anzt2014implementing]. | ||
|
||
## Core functionality | ||
|
||
* Construction: from triplet (`i,j,v`) arrays or dense matrices. | ||
* Data accessors: `add` (insert/update entries) and `at` (element access with management zero/NaN handling of missing entries). | ||
* Operations: sparse matrix–vector multiplication (`spmv`), with optional transpose and hermitian variants: | ||
$$ y = \alpha op(A) * x + \beta * y$$ | ||
* Conversions: between sparse formats and dense matrices. | ||
* Utilities: diagonal extraction, symmetry flags, duplicate entry handling. | ||
|
||
## Implementation details | ||
|
||
Before introducing stdlib_sparse, the core structure and API was crafted under a stand-aline project, FSPARSE [@fsparse2024]. This enabled testing and refinement of the library before integration into stdlib. | ||
jalvesz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
The module is designed with the following key features: | ||
|
||
* Generic procedures support both real and complex kinds. | ||
* Memory is allocated dynamically with type-bound malloc routines. | ||
* Conversions handle duplicate entries, with options for summation or overwriting. | ||
|
||
# Example usage | ||
|
||
```fortran | ||
program main | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_sparse | ||
implicit none | ||
|
||
integer, parameter :: m = 4, n = 2 | ||
real(dp) :: A(m,n), x(n) | ||
real(dp) :: y_dense(m), y_coo(m), y_csr(m) | ||
real(dp) :: alpha, beta | ||
type(COO_dp_type) :: COO | ||
type(CSR_dp_type) :: CSR | ||
|
||
call random_number(A) | ||
! Convert from dense to COO and CSR matrices | ||
call dense2coo( A , COO ) | ||
call coo2csr( COO , CSR ) | ||
|
||
! Initialize vectors | ||
x = 1._dp | ||
y_dense = 2._dp | ||
y_coo = y_dense | ||
y_csr = y_dense | ||
|
||
! Perform matrix-vector product | ||
alpha = 3._dp; beta = 2._dp | ||
y_dense = alpha * matmul(A,x) + beta * y_dense | ||
call spmv( COO , x , y_coo , alpha = alpha, beta = beta ) | ||
call spmv( CSR , x , y_csr , alpha = alpha, beta = beta ) | ||
|
||
print *, 'dense :', y_dense | ||
print *, 'coo :', y_coo | ||
print *, 'csr :', y_csr | ||
|
||
end program main | ||
``` | ||
|
||
# Performance and limitations | ||
|
||
Sparse matrix–vector multiplication has been implemented for all formats. Preliminary tests confirm correctness and scalability to moderately large problems. However: | ||
|
||
* No sparse matrix–matrix multiplication or factorizations are yet implemented. | ||
* For data-parallelism (multi-processing with MPI or coarrays) the `spmv` kernel can be used as basis within each process. Multi-threading or GPU acceleration is not currently supported. | ||
* Interfaces are subject to change while the module remains experimental. | ||
|
||
Future work will address these limitations by adding additional kernels, improving performance portability, and expanding supported formats. | ||
|
||
# Acknowledgements | ||
|
||
This work is part of the Fortran-lang community project. We thank the contributors to stdlib and the Fortran community for discussions, reviews, and development efforts. | ||
|
||
# References |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.