Loading [MathJax]/extensions/TeX/autobold.js
Parallelization with MPI and OpenMP and discussions of project 1
Contents
Plans for the week of March 18-22
Alternatives for project 2
What is OpenMP
Getting started, things to remember
OpenMP syntax
Different OpenMP styles of parallelism
General code structure
Parallel region
Hello world, not again, please!
Hello world, yet another variant
Important OpenMP library routines
Private variables
Master region
Parallel for loop
Parallel computations and loops
Scheduling of loop computations
Example code for loop scheduling
Example code for loop scheduling, guided instead of dynamic
More on Parallel for loop
What can happen with this loop?
Inner product
Different threads do different tasks
Single execution
Coordination and synchronization
Data scope
Some remarks
Parallelizing nested for-loops
Nested parallelism
Parallel tasks
Common mistakes
Not all computations are simple
Not all computations are simple, competing threads
How to find the max value using OpenMP
Then deal with the race conditions
What can slow down OpenMP performance?
What can slow down OpenMP performance?
Find the max location for each thread
Combine the values from each thread
"Matrix-matrix multiplication":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/ParallelizationOpenMP/OpenMPvectornorm.cpp"
"Matrix-matrix multiplication":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/ParallelizationOpenMP/OpenMPmatrixmatrixmult.cpp"
Parallel region
A parallel region is a block of code that is executed by a team of threads
The following compiler directive creates a parallel region
#pragma omp parallel { ... }
Clauses can be added at the end of the directive
Most often used clauses:
default(shared)
or
default(none)
public(list of variables)
private(list of variables)
«
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
41
»