diff --git a/lectures/parallelism/slides.qmd b/lectures/parallelism/slides.qmd index 37ce2006a29dcb0ab65a0526b3107a4987a6cc48..5747f359839c5d268bc003f5d0c3a31bffefc024 100644 --- a/lectures/parallelism/slides.qmd +++ b/lectures/parallelism/slides.qmd @@ -217,8 +217,11 @@ Wikipedia ## Types of parallelism -* Data-level parallelism - what we've been discussing -* Task-level parallelism - Example: Atmosphere ocean coupling + +* Data-level parallelism + * what we've been discussing +* Task-level parallelism + * Example: Atmosphere ocean coupling ## Precondition for parallel execution @@ -331,6 +334,62 @@ d = c - b; // S2 ``` ::: +## Bernstein's parallelism conditions {.alignleft} + +:::{.fragment .semi-fade-out} +```c++ +c = a + b; // S1 +d = a - b; // S2 +``` +::: + + +:::{.fragment} +Replace `a` with `c` in statement 2 +```c++ +c = a + b; // S1 +d = c - b; // S2 +``` +::: + +:::{.smaller} + +:::: {.columns} + +::: {.column width="50%"} + +:::{.fragment} + +Read and write sets for S1 and S2: +$$ +R_1 = \{a,b\} ; W_1 = \{c\} \\ +R_2 = \{c,b\} ; W_2 = \{d\} \\ +$$ + +::: +::: + +::: {.column width="50%"} + +:::{.fragment} +Bernstein's conditions: + +$$ +R_1 \cap W_2 = \emptyset \\ +W_1 \cap R_2 = \{c\} \\ +W_1 \cap W_2 = \emptyset +$$ +::: + +::: +::: +:::: + +:::{.fragment} +S1 and S2 can NOT be executed in parallel! +::: + + ## Best practices * Parallelisation should not change the results! Exceptions to be discussed next week!