Skip to content

Commit 57ffd4f

Browse files
committed
up
1 parent 940f218 commit 57ffd4f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

website/lecture5.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<h1>Lecture 5: Parallel Programming</h1>
44
~~~
55

6+
7+
\toc
8+
9+
610
## Caveats First
711

812
* You hear often: "sure, that's a big problem you have there. But you can parallelize it!" Whether that will help in your case is strictly problem-specific. You need to _try it out_ in order to know.
@@ -18,7 +22,7 @@
1822
* The smallest parallel computation unit lives on your CPU.
1923
* The basic idea is simple: If a computational task of duration `M` can split into `N` subtasks, which can be performed _concurrently_ (at the same time), without interfering with each other, then _in theory_, the duration of the task should fall to `M/N`. _In practice_ we almost never achieve this theoretical bound, because of time spent communicating between computational units and other _system time_.
2024

21-
## Resources:
25+
## Resources
2226

2327
1. Julia [whitepaper](https://juliahub.com/assets/pdf/Parallel-Computing-Guide-for-Julia-byJuliaHub.pdf)
2428
2. [Guide](https://www.sas.upenn.edu/~jesusfv/Guide_Parallel.pdf) by Jesus Fernandez-Villaverde and David Zurrak-Valencia
@@ -44,7 +48,7 @@ Paradigms 1. and 2. live in a _shared memory_ world, i.e. they operate within th
4448

4549
Paradigms 3. and 4. are different, because they (can) rely on **separate** hardware. We can start a distributed julia process inside a single machine, but this will behave _like another computer_ (almost), so you will have to worry about making data and functions accessible to all worker processes.
4650

47-
## 1. Asyncronous Tasks or Coroutines
51+
## Asyncronous Tasks or Coroutines
4852

4953
Even within a single thread there may be computational operations which can be performed next to each other. *Coroutines* split a single task into multiple chunks, and there is an efficient process which allows *non-blocking execution*. This may be beneficial in I/O operations or when we wait for something to arrive via a network. It is *not* beneficial if our operation involvs many CPU cycles (i.e. if it's compute intensive). Let's see an example.
5054

@@ -147,7 +151,7 @@ You can see that julia makes it extremely easy to run *concurrent* tasks.
147151
Check out more in the manual: https://docs.julialang.org/en/v1/manual/parallel-computing/
148152

149153

150-
## 2. Multi-Threading
154+
## Multi-Threading
151155

152156
* What are threads again? _Threads are sequences of instructions given to the CPU_ which can be executed concurrently. So, multithreading is something that happens on a _core_ of CPU. Your CPU may have several _cores_.
153157
* The [manual](https://docs.julialang.org/en/v1/manual/multi-threading/#man-multithreading) is the authorative source - very comprehensive.
@@ -406,7 +410,7 @@ Threads.@threads for i in 1:100
406410
end
407411
```
408412

409-
#### Data Race Conditions
413+
### Data Race Conditions
410414

411415
```julia
412416
julia> function sum_single(a)
@@ -457,7 +461,7 @@ julia> sum_multi_good(1:1_000_000)
457461
In this [research project - [private repo]](https://github.com/floswald/FMig.jl/pull/17/commits/119b34bbf621374be187a023399d74a5e16c3934) we encountered a situation very similar to the above.
458462

459463

460-
## 3. Distributed Computing
464+
## Distributed Computing
461465

462466
The [manual](https://docs.julialang.org/en/v1/manual/distributed-computing/) is again very helpful here.
463467

@@ -589,7 +593,7 @@ I would recommend
589593
* define all required data within the `module` you load on the workers, such that each of them has access to all required data. This may not be feasible if you require huge amounts of input data.
590594
* Example: [private repo again]
591595

592-
### Example Setup Real World Project
596+
### Example Setup Real World HPC Project
593597

594598
Suppose we have the following structure on an HPC cluster.
595599

@@ -677,4 +681,4 @@ ENV["RESULTS"] = JSON3.write(results)
677681

678682
### Parallel Map and Loops
679683

680-
This is most relevant use case in most of our applications.
684+
This is most relevant use case in most of our applications. tbc.

0 commit comments

Comments
 (0)