ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SellMatrix.h File Reference

A sparse matrix in the format SELL- \( C \)- \( \sigma \) of Kreutzer, Hager, Wellein, Fehske and Bishop, beyond the book: the rows, sorted by their number of nonzeros within windows of \( \sigma \) consecutive rows, go in chunks of \( C \) rows, and each chunk keeps its nonzeros by columns of the chunk, the \( k \)-th nonzero of its \( C \) rows side by side, padded with zeros to the longest of its rows. More...

#include "ADS/Contract.h"
#include "ADS/numeric/CsrMatrix.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <numeric>
#include <vector>
#include "ADS/numeric/impl/SellMatrix.tpp"

Go to the source code of this file.

Classes

class  ADS::SellMatrix< C >
 a sparse matrix of doubles in SELL- \( C \)- \( \sigma \), chunks of \( C \) rows (4 by default, the fastest on a Xeon Gold 5120 with AVX-512: the gathers of 8 lanes cost more than they save) More...

Namespaces

namespace  ADS

Detailed description

A sparse matrix in the format SELL- \( C \)- \( \sigma \) of Kreutzer, Hager, Wellein, Fehske and Bishop, beyond the book: the rows, sorted by their number of nonzeros within windows of \( \sigma \) consecutive rows, go in chunks of \( C \) rows, and each chunk keeps its nonzeros by columns of the chunk, the \( k \)-th nonzero of its \( C \) rows side by side, padded with zeros to the longest of its rows.

The product \( y = A x \) then runs the \( C \) rows of a chunk in the \( C \) lanes of the vector registers (\( C = 8 \) doubles for AVX-512, 4 for AVX2), the values and the columns of a step loaded in one stream and \( x \) gathered, instead of one row at a time with a reduction at its end, as in CSR [see CsrMatrix.h]. The sort within the windows makes the rows of a chunk nearly as long, so that the padding, \( \sum_c C \max_{i \in c} r_i - \mathit{nnz} \) for the chunks \( c \) and the row lengths \( r_i \), is small (none on the rows of equal length of a stencil), while a window of \( \sigma \ll m \) rows keeps the rows near their place and so the reads of \( x \) and the writes of \( y \) near each other.

  • The matrix is built from a CsrMatrix in \( O( \mathit{nnz} + m \log \sigma ) \) time: the sort of each window by row length (stable, so that rows of equal length keep their order), the widths of the chunks, and the placement of the nonzeros; it takes \( 12 ( \mathit{nnz} + \mathit{pad} ) + 8 m / C + 4 m \) bytes: the values and the columns, the offset and the width of each chunk, and the permutation of the rows.
  • multiply() is \( y = A x \): for each chunk, \( C \) sums in the lanes over the width of the chunk, then each sum written to its row; \( 2 ( \mathit{nnz} + \mathit{pad} ) \) operations, all of them in full vectors.

The contracts [see Contract.h]: \( \sigma \ge 1 \) and \( m < 2^{32} \); \( x \) has \( n \) entries and \( y \) \( m \) entries. The functions are defined in SellMatrix.tpp.

See also
M. Kreutzer, G. Hager, G. Wellein, H. Fehske, A. R. Bishop, A unified sparse matrix data format for efficient general sparse matrix-vector multiplication on modern processors with wide SIMD units, SIAM Journal on Scientific Computing 36(5), C401-C423, 2014, doi:10.1137/130930352
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa