Cut my life into pieces
This is my last resort

![]()
adapted from original image by MPI-M
(#pragma is a keyword for the compiler)
Get the example code from here
Load the GNU compiler on Levante
What does the additional output mean?
Now uncomment/adapt
schedule(static,100)schedule(static,10) and interpret the results.Bake mini-pancake dessert




Images generated by Pradipta Samanta (DKRZ) with DALL-E
Starting with 1 pan, we can (perfect) scale this by using \(N\) pans in two ways:
| Parameter | Initial | Strong scaling | Weak scaling |
|---|---|---|---|
| Resources (e.g. pans) |
1 | \(N\) | \(N\) |
| Total workload (e.g. pancake count) |
\(8\) | \(8\) | \(8 \times N\) |
| Workload per worker (e.g. pancakes per pan) |
\(8\) | \(8/N\) | \(8\) |
| Total time | \(T\) | \(T/N\) | \(T\) |
The problem is called “data race”.
Assume 2 threads!
For other reduction operations like e.g. max see OpenMP documentation
Parallel computing is the simultaneous use of multiple compute resources to solve a computational problem
– Introduction to Parallel Computing Tutorial, LLNL
Two consecutive instructions or code segments can be executed in parallel if they are independent.
What does dependence mean?
The intersection between read-write set, write-read set and write-write set of instructions is null.
– Bernstein’s condition for data independence.
Read and write sets for S1 and S2: \[ R_1 = \{a,b\} ; W_1 = \{c\} \\ R_2 = \{a,b\} ; W_2 = \{d\} \\ \]
Bernstein’s conditions:
\[ R_1 \cap W_2 = \emptyset \\ W_1 \cap R_2 = \emptyset \\ W_1 \cap W_2 = \emptyset \]
S1 and S2 can be executed in parallel!
Read and write sets for S1 and S2: \[ R_1 = \{a,b\} ; W_1 = \{c\} \\ R_2 = \{c,b\} ; W_2 = \{d\} \\ \]
Bernstein’s conditions:
\[ R_1 \cap W_2 = \emptyset \\ W_1 \cap R_2 = \{c\} \\ W_1 \cap W_2 = \emptyset \]
S1 and S2 can NOT be executed in parallel!