Introduction
|
OpenMP programs are limited to a single physical machine
You use OpenMP with C, C++, or Fortran
|
Hello World
|
Pragmas are directives to the compiler to parallelize something
Thread number is typically controlled with an environment variable, OMP_NUM_THREADS
Order of execution of parallel elements is not guaranteed.
If the compiler doesn’t recognize OpenMP pragmas, it will compile a single-threaded program. But you may need to escape OpenMP function calls.
|
Linear algebra
|
The PARALLEL FOR (or PARALLEL DO) pragma makes a loop execute in parallel
A single variable accessed by different threads can cause wrong results
The PRIVATE clause makes a copy of a variable for each thread
|
Numeric Integration - Calculating Areas
|
|
Searching through data
|
Reduction operators handle the common case of summation, and analogous operations
OpenMP can manage general parallel sections
You can use ‘pragma omp single’ to have a single thread execute something
|
Calculating Fibonacci numbers
|
|
Drawing the Mandelbrot set
|
|