SeSE Course: HPC II 2014 - Assignment 2

Assignment 2

Remember to load the SLEPc module (which will include the PETSc module as well).

First Part - PETSc

In this exercise you will solve linear systems in parallel with PETSc. The program lab1.c solves the Poisson equation using the finite-difference method on a square regular grid with n+1 subdivisions on each side. Modify the program so that it computes the residual norm and prints it, together with the number of iterations performed by the solver.

Try different combinations of iterative solver and preconditioner, such as gmres+bjacobi or bcgs+sor. Use -ksp_view to check the actual parameters used by the solver. Compare also with a direct linear solver.

The program lab2.c is similar to the previous one, but loads the matrix from a binary file. Use the -log_summary option to make a performance analysis for varying number of processes with matrix 'bbmat'.

Second part - SLEPc

The idea of this second part is to take a guided tour on SLEPc functionality through the hands-on exercises available at

After that you should be able to compute the following:

  • Rightmost and leftmost eigenvalues of matrix 'stomach'
  • Smallest magnitude eigenvalues of matrix 'stomach' (use the shift-and-invert technique)
  • Condition number of matrix 'stomach' as the quotient of largest to smallest singular value


The source code is available on abisko. The following command will create a directory with the files:

          tar xzf ~mr/Public/HPCII/ass2.tgz

The matrices needed can be found in


Updated: 2018-12-12, 14:43