Learning materials
Chapter 4: OpenMP Case Study: N-body problem
On this page
The problem
Simulate the motion of stars, planets, etc.
Math
Divide time to small sections. Calculate physical variables at every time stop progressively.
Serial Solution
Two layer of nested loops. One outer loop and multiple inner loops. Data dependency exists between loops in the inner layer.
OpenMP Optimization
- Optimize inner layer loops
- Use
#pragma omp parallelon outer loop to pre-fork threads - Use
#pragma omp foron inner layers - Barriers and critical sections