Lecture 16
Learning objectives
After this class, you should be able to:
- Parallelize matrix-vector multiplication using pthreads.
- Explain the idea of race conditions and critical sections.
- Explain some disadvantages of the busy-waiting solution provided in the text book for mutual exclusions.
- Use
pthreads locks
to implement mutual exclusions.
Reading assignment
- Section 4.3 - 4.6.
- Lecture 16 slides.
- Lecture 16 example codes.
Exercises and review questions
- Questions on current lecture's material
- Rewrite the
pi
example from the previous homework so that all threads directly update the partial sum, using pthreads locks to avoid race conditions.- (Post on the discussion board) Modify the matrix-vector multiplication code from the book so that it has two types of parallelization: cyclic and block. Give the time taken by each version.
- Questions on next lecture's material
- None.