This material is part of the course Practical Introduction to Parallel Programming and meant for educational purposes only.
Implement a program that reads a sparse matrix \(\mathbf{A}\) from a file, stores it in a Compressed Sparse Row (CSR) format, and performs a series of parallel, sparse matrix-vector products of the form
The first vector \(\mathbf{x}_{0}\) is generated randomly.
This code given below implements the sequential version of the program. It defines a struct sparse_matrix_t
that represents a sparse matrix.
The program reads a sparse matrix from a file named matrix.dat
.
You should (try to) implement three parallel versions of sparse matrix-vector product: one with MPI; one with OpenMP and one with threads.
Hints
Partition the matrix row wise and assign each batch of rows to a different thread or process.
Read the matrix on the master thread/process.
Start with the parallel implementation based on OpenMP as this is the most straightforward.
Compare the parallel performance of each implementation. Is there a significant difference?