Skip to content
Snippets Groups Projects
Commit 625e2593 authored by Jan Frederik Engels's avatar Jan Frederik Engels :new_moon:
Browse files

Some improvements.

parent 6dd136cc
No related branches found
No related tags found
1 merge request!72Draft: Compute devices lecture
...@@ -107,28 +107,31 @@ N = 8 ...@@ -107,28 +107,31 @@ N = 8
```bash ```bash
module load gcc module load gcc
``` ```
2. Compile and run the serial example 2. Compile and run the serial example
```bash ```bash
gcc main.c -o serial.x -lm gcc main.c -o serial.x -lm
time ./serial.x # use `time` to check the runtime time ./serial.x # use `time` to check the runtime
``` ```
3. Compile and run the example using OpenMP 3. Compile and run the example using OpenMP
```bash ```bash
gcc -fopenmp main.c -o parallel.x -lm gcc -fopenmp main.c -o parallel.x -lm
OMP_NUM_THREADS=2 time ./parallel.x OMP_NUM_THREADS=2 time ./parallel.x
``` ```
4. See next slide! 4. See next slide!
# Hands-on Session! {background-color=var(--dark-bg-color) .leftalign} # Hands-on Session! {background-color=var(--dark-bg-color) .leftalign}
4. Now add
* `schedule(static,1)`
* `schedule(static,10)`
* `schedule(FIXMEsomethingelse)`
* `schedule(FIXMEsomethingelse)`
and find out how the OpenMP runtime decomposes the problem domain.
FIXME: Maybe add something varying the number of threads, so that one can see 4. Now compile/run with
first ideas of strong/weak scaling. ```bash
gcc -fopenmp main.c -o parallel.x -lm -DWRITE_DECOMP
OMP_NUM_THREADS=4 time ./parallel.x
```
5. What does the additional output mean?
4. Now uncomment/adapt
* `schedule(static,100)`
* `schedule(static,10)`
and interpret the results.
# Scaling # Scaling
...@@ -257,7 +260,7 @@ Wikipedia ...@@ -257,7 +260,7 @@ Wikipedia
"Parallel computing is the simultaneous use of multiple compute resources to solve a computational problem" "Parallel computing is the simultaneous use of multiple compute resources to solve a computational problem"
:::{.smaller} :::{.smaller}
-- *Introduction to Parallel Computing Tutorial, LLNL * -- *Introduction to Parallel Computing Tutorial, LLNL *
::: :::
...@@ -267,7 +270,7 @@ Wikipedia ...@@ -267,7 +270,7 @@ Wikipedia
* what we've been discussing * what we've been discussing
* Task-level parallelism * Task-level parallelism
* Example: Atmosphere ocean coupling * Example: Atmosphere ocean coupling
## Precondition for parallel execution ## Precondition for parallel execution
...@@ -441,9 +444,13 @@ S1 and S2 can NOT be executed in parallel! ...@@ -441,9 +444,13 @@ S1 and S2 can NOT be executed in parallel!
# FIXME # FIXME
* Homework: * Homework:
* Do something where you run into hardware-constraints (i.e. Numa, too many threads, ...) * Revisit `schedule` and try `dynamic` and explain why that happens.
* Give some example with race condition or stuff and have them find it. * Parallelize the loop in `maxval`.
* Have them discuss the concepts from the lecture using the metaphor of a kitchen workflow? * Do a strong-scaling experiment starting with 2 threads and up to 32
threads and plot the result.
* If you were to increase the number of threads, do you expect the speedup
to continue indefinitely? If not, which limits can you imagine? Feel free
to use kitchen metaphors.
# Additional reading # Additional reading
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment