Skip to content

Example program for computing a sparse matrix-vector multiplication with a matrix in the compressed sparse row (CSR) format.

License

Notifications You must be signed in to change notification settings

jamtrott/csrspmv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is the README file for csrspmv, a program for benchmarking sparse
marix-vector multiplication (SpMV) for matrices in the compressed
sparse row (CSR) format.

  Copyright (C) 2023 James D. Trotter

  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.

Building
--------
The `csrspmv' program can be built with `make'. Compilation and
linking may be configured through the environment variable `CC', which
is used to choose a compiler, and `CFLAGS' and `LDFLAGS', which are
used to set compiler flags and linker flags, respectively. Here is an
example:

     make CC=gcc CFLAGS="-O3 -march=native"

Usage
-----
The `csrspmv' program is used to load a matrix from a file in Matrix
Market format (see https://math.nist.gov/MatrixMarket/formats.html),
convert it to a compressed sparse row (CSR) representation, and
multiply it with a dense vector. The vector can also be loaded from a
file in the Matrix Market format. Otherwise, a vector of all ones is
used. The vector resulting from the multiplication can also be written
to a file in the Matrix Market format.

Since OpenMP is used for shared-memory parallel computations, the
environment variable `OMP_NUM_THREADS' can be set to control the
number of threads that are used. In addition, `OMP_PROC_BIND' can be
set to bind threads to particular cores.

If the option `--verbose' is supplied, then some information about the
matrix is printed, as well as the information about the matrix-vector
multiplication, such as the time spent and number of arithmetic
operations performed.

Here is an example of the output:

     ./csrspmv --verbose test.mtx
     matrix_market_read: 0.000128 seconds matrix object coordinate format real field general symmetry 4 rows 5 columns 7 nonzeros
     csr_matrix_int32_from_matrix_market: 0.018245 seconds 4 rows 5 columns 7 nonzeros
     csr_matrix_int32_spmv: 0.000089 seconds 1 multiplications 14 flops

Copying
-------
csrspmv is free software. See the file COPYING for copying conditions.

About

Example program for computing a sparse matrix-vector multiplication with a matrix in the compressed sparse row (CSR) format.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published