Lecture 20
Learning objectives
After this class, you should be able to:
- Explain OpenMP's programming model.
- Use the following OpenMP features to write parallel code:
parallelandcriticaldirectives,omp_get_thread_num, andomp_get_num_threads.
Reading assignment
- Section 5.1 - 5.3.
- Lecture 20 slides.
- Lecture 20 example code.
- OpenMP tutorial.
- Page 224.
Exercises and review questions
- Questions on current lecture's material
- Output the result of
omp_get_num_threadsin parallel and sequential regions. What difference do you see?- Change the
helloexample so that the number of threads is set usingomp_set_num_threads. Useomp_get_num_procsto determine a suitable number of threads.- Questions on next lecture's material
- Give one OpenMP directive that helps with work sharing.