From 4c79658ac9de51c11e1ae699a6055f5af7b3d228 Mon Sep 17 00:00:00 2001 From: Georgiana Mania <mania@dkrz.de> Date: Fri, 7 Jun 2024 15:36:02 +0200 Subject: [PATCH] fix pancake example & other FIXME --- lectures/parallelism/slides.qmd | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lectures/parallelism/slides.qmd b/lectures/parallelism/slides.qmd index eaf7139..7509f35 100644 --- a/lectures/parallelism/slides.qmd +++ b/lectures/parallelism/slides.qmd @@ -113,16 +113,15 @@ module load gcc ``` 2. Compile and run the serial example ```bash -gcc main.c -o serial.x -lm +gcc -O3 main.c -o serial.x -lm time ./serial.x # use `time` to check the runtime ``` 3. Compile and run the example using OpenMP ```bash -gcc -fopenmp main.c -o parallel.x -lm -time OMP_NUM_THREADS=2 ./parallel.x +gcc -O3 -fopenmp main.c -o parallel.x -lm +export OMP_NUM_THREADS=2 +time ./parallel.x ``` -FIXME: time is often a shell builtin, so output varies and also the place -where the env-var needs to be set. 4. See next slide! @@ -131,11 +130,12 @@ where the env-var needs to be set. 4. Now compile/run with ```bash gcc -fopenmp main.c -o parallel.x -lm -DWRITE_DECOMP -OMP_NUM_THREADS=4 time ./parallel.x +export OMP_NUM_THREADS=4 +time ./parallel.x ``` 5. What does the additional output mean? -4. Now uncomment/adapt +6. Now uncomment/adapt * `schedule(static,100)` * `schedule(static,10)` and interpret the results. @@ -182,16 +182,16 @@ Images generated by Pradipta Samanta with DALL-E ## Strong vs weak scaling :::{.smaller} -Starting with batter for $N$ pancakes and 1 pan, we can scale by using $P$ pans in two ways: +Starting with 1 pan, we can (perfect) scale this by using $P$ pans in two ways: ::: :::{.fragment} |Parameter / Scaling type |Strong|Weak| |-------|---|---| |Resources <br> (e.g. pans) | $P$| $P$ | -|Total workload <br> (e.g. pancake count)| $N$ | $P \times N$ | +|Total workload <br> (e.g. pancake count)| $N$ | $N \times P$ | |Workload per worker <br> (e.g. pancakes per pan) | $N/P$ | $N$ | -|Total time | $T_1 \times N/P$ | $T_1 \times N$ | +|Total time | $T_1 \times N/P$ | $T_1 \times N \times P$ | ::: @@ -203,7 +203,7 @@ Starting with batter for $N$ pancakes and 1 pan, we can scale by using $P$ pans * Weak scaling --> -# Reductions FIXME title should be more generic +# Aggregate parallel results ## What is happening here? ```c++ int a[] = {2, 4, 6}; -- GitLab