PETSc algebraic solvers can now use pthreads on Vec and Mat operations. This sometimes provides an alternative to the all MPI approach.
Thread usage in PETSc is available in release 3.2, but because things are changing rapidly, we recommend working with petsc-dev if you want to explore this feature.
- Installation of PETSc with threads
-
Quick summary of usage in petsc-dev:
- Threads can be used via native pthread lockfree implementation or OpenMP.
-
The three important run-time options for using threads are:
- -threadcomm_nthreads <nthreads>: Sets the number of threads
- -threadcomm_affinities <list_of_affinities>: Sets the core affinities of threads
- -threadcomm_type <nothread,pthread,openmp>: Threading model (OpenMP, pthread, nothread)
- Run with -help to see the avialable options with threads.
- A few tutorial examples are located at $PETSC_DIR/src/sys/threadcomm/examples/tutorials
-
Quick summary of usage in petsc-3.3:
- The VecType VECSEQPTHREAD or VECPTHREAD maybe used
with VecSetType() or -vec_type seqpthread or pthread
when
VecSetFromOptions() is used.
- The MatType MATSEQAIJPTHREAD, MATPTHREAD
maybe used with MatSetType or -mat_type
seqaijpthread or
aijpthread when MatSetOptions() is used.
- If you are creating the vectors and matrices with a DM, you can use -dm_vec_type pthread and -dm_mat_type pthread
- It is useful to develop your code with the default vectors and matrices and then run production runs with the command line options to use the pthread classes.
- The VecType VECSEQPTHREAD or VECPTHREAD maybe used
with VecSetType() or -vec_type seqpthread or pthread
when
VecSetFromOptions() is used.
- We could use your help in further developing PETSc with threads; see petsc-dev