This directory contains files to support a short, three-day overview of OpenMP, a standard for multi-threaded, parallel computing in C++. The tutorial is organized by exercise.
Use OpenMP to produce a program that displays several messages of the form
Hello, from thread 1 of 4
. This will require that students use the
parallel
directive, access the thread ID, and access the number of threads.
To be interesting, students should also modify the number of threads.
Introduces
- concept of fork/join model
parallel
directive<omp.h>
omp_get_num_threads
omp_get_thread_num
OMP_NUM_THREADS
Given two std::vectors a
and b
, compute their element-wise sum c
in
parallel using just the parallel
directive, the thread ID, and the number
of threads.
Introduces
omp_get_wtime
- concept of "work sharing"
- concept of shared memory
Repeat Exercise 2 by using the for
directive, thereby eliminating any
need for explicit work sharing.
Introduces
for
directive
Use the parallel
and for
directives to compute the dot product of two
arrays a
and b
. Assess the parallel efficiency for various thread
counts and various problem sizes.
Introduces
- concept of private memory
- concept of race conditions
critical
directiveatomic
directivereduce
directive
Use the same basic structure from Exercise 4 to compute the sum of 1, 2, ..., n. How does the performance differ from those of Exercise 4?
Introduces
- concept of memory bandwidth limitations
You are given a basic program that computes the temperature in a two-dimensional box subject to fixed boundary temperatures. Your job is to parallelize this code and to extract the best performance possible.