Merge pull request #34 from fverdugo/francesc
Preparation work for 2024-25
12
docs/make.jl
@ -119,13 +119,13 @@ makedocs(;
|
|||||||
"Julia Basics" => "julia_basics.md",
|
"Julia Basics" => "julia_basics.md",
|
||||||
"Asynchronous programming in Julia" => "julia_async.md",
|
"Asynchronous programming in Julia" => "julia_async.md",
|
||||||
"Distributed computing in Julia" => "julia_distributed.md",
|
"Distributed computing in Julia" => "julia_distributed.md",
|
||||||
"Distributed computing with MPI" => "mpi_tutorial.md",
|
#"Distributed computing with MPI" => "mpi_tutorial.md",
|
||||||
"Matrix-matrix multiplication"=>"matrix_matrix.md",
|
"Matrix-matrix multiplication"=>"matrix_matrix.md",
|
||||||
"Jacobi method" => "jacobi_method.md",
|
#"Jacobi method" => "jacobi_method.md",
|
||||||
"All pairs of shortest paths" => "asp.md",
|
#"All pairs of shortest paths" => "asp.md",
|
||||||
"Gaussian elimination" => "LEQ.md",
|
#"Gaussian elimination" => "LEQ.md",
|
||||||
"Traveling salesperson problem" => "tsp.md",
|
#"Traveling salesperson problem" => "tsp.md",
|
||||||
"Partial differential equations" => "pdes.md",
|
#"Partial differential equations" => "pdes.md",
|
||||||
],
|
],
|
||||||
"Solutions" => "solutions_for_all_notebooks.md",
|
"Solutions" => "solutions_for_all_notebooks.md",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -129,7 +129,13 @@ If this runs without error and you see a version number, you are good to go!
|
|||||||
In this tutorial, when a code snipped starts with `$`, it should be run in the terminal. Otherwise, the code is to be run in the Julia REPL.
|
In this tutorial, when a code snipped starts with `$`, it should be run in the terminal. Otherwise, the code is to be run in the Julia REPL.
|
||||||
|
|
||||||
!!! tip
|
!!! tip
|
||||||
Avoid calling Julia code from the terminal, use the Julia REPL instead! Each time you call Julia from the terminal, you start a fresh Julia session and Julia will need to compile your code from scratch. This can be time consuming for large projects. In contrast, if you execute code in the REPL, Julia will compile code incrementally, which is much faster. Running code in a cluster (like in DAS-5 for the Julia assignment) is among the few situations you need to run Julia code from the terminal.
|
Avoid calling Julia code from the terminal, use the Julia REPL instead!
|
||||||
|
Each time you call Julia from the terminal, you start a fresh Julia session and Julia will need to compile your code from scratch.
|
||||||
|
This can be time consuming for large projects.
|
||||||
|
In contrast, if you execute code in the REPL, Julia will compile code incrementally, which is much faster.
|
||||||
|
Running code in a cluster (like in DAS-5 for the Julia assignment) is among the few situations you need to run Julia code
|
||||||
|
from the terminal. Visit this link ([Julia workflow tips](https://docs.julialang.org/en/v1/manual/workflow-tips/))
|
||||||
|
from the official Julia documentation for further information about how to develop Julia code effectivelly.
|
||||||
|
|
||||||
### Running parallel code
|
### Running parallel code
|
||||||
|
|
||||||
@ -199,11 +205,11 @@ To install a package, we need to enter *package* mode. Remember that we entered
|
|||||||
```julia
|
```julia
|
||||||
julia> ]
|
julia> ]
|
||||||
```
|
```
|
||||||
At this point, the prompt should have changed to `(@v1.8) pkg>` indicating that we are in package mode. The text between the parentheses indicates which is the active *project*, i.e., where packages are going to be installed. In this case, we are working with the global project associated with our Julia installation (which is Julia 1.8 in this example, but it can be another version in your case).
|
At this point, the prompt should have changed to `(@v1.10) pkg>` indicating that we are in package mode. The text between the parentheses indicates which is the active *project*, i.e., where packages are going to be installed. In this case, we are working with the global project associated with our Julia installation (which is Julia 1.10 in this example, but it can be another version in your case).
|
||||||
|
|
||||||
To install the MPI package, type
|
To install the MPI package, type
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> add MPI
|
(@v1.10) pkg> add MPI
|
||||||
```
|
```
|
||||||
Congrats, you have installed MPI!
|
Congrats, you have installed MPI!
|
||||||
|
|
||||||
@ -230,7 +236,7 @@ $ mpiexec -np 4 julia hello_mpi.jl
|
|||||||
But it will probably not work since the version of `mpiexec` needs to match with the MPI version we are using from Julia. Don't worry if you could not make it work! A more elegant way to run MPI code is from the Julia REPL directly, by using these commands:
|
But it will probably not work since the version of `mpiexec` needs to match with the MPI version we are using from Julia. Don't worry if you could not make it work! A more elegant way to run MPI code is from the Julia REPL directly, by using these commands:
|
||||||
```julia
|
```julia
|
||||||
julia> using MPI
|
julia> using MPI
|
||||||
julia> mpiexec(cmd->run(`$cmd -np 4 julia hello_mpi.jl`))
|
julia> run(`$(mpiexec()) -np 4 julia hello_mpi.jl`)
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, you should see output from 4 ranks.
|
Now, you should see output from 4 ranks.
|
||||||
@ -241,9 +247,9 @@ Now, you should see output from 4 ranks.
|
|||||||
|
|
||||||
We have installed the `MPI` package globally and it will be available in all Julia sessions. However, in some situations, we want to work with different versions of the same package or to install packages in an isolated way to avoid potential conflicts with other packages. This can be done by using local projects.
|
We have installed the `MPI` package globally and it will be available in all Julia sessions. However, in some situations, we want to work with different versions of the same package or to install packages in an isolated way to avoid potential conflicts with other packages. This can be done by using local projects.
|
||||||
|
|
||||||
A project is simply a folder in the hard disk. To use a particular folder as your project, you need to *activate* it. This is done by entering package mode and using the `activate` command followed by the path to the folder you want to activate.
|
A project is simply a folder in your file system. To use a particular folder as your project, you need to *activate* it. This is done by entering package mode and using the `activate` command followed by the path to the folder you want to activate.
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> activate .
|
(@v1.10) pkg> activate .
|
||||||
```
|
```
|
||||||
The previous command will activate the current working directory. Note that the dot `.` is indeed the path to the current folder.
|
The previous command will activate the current working directory. Note that the dot `.` is indeed the path to the current folder.
|
||||||
|
|
||||||
@ -253,7 +259,7 @@ The prompt has changed to `(lessons) pkg>` indicating that we are in the project
|
|||||||
You can activate a project directly when opening Julia from the terminal using the `--project` flag. The command `$ julia --project=.` will open Julia and activate a project in the current directory. You can also achieve the same effect by setting the environment variable `JULIA_PROJECT` with the path of the folder you want to activate.
|
You can activate a project directly when opening Julia from the terminal using the `--project` flag. The command `$ julia --project=.` will open Julia and activate a project in the current directory. You can also achieve the same effect by setting the environment variable `JULIA_PROJECT` with the path of the folder you want to activate.
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
The active project folder and the current working directory are two independent concepts! For instance, `(@v1.8) pkg> activate folderB` and then `julia> cd("folderA")`, will activate the project in `folderB` and change the current working directory to `folderA`.
|
The active project folder and the current working directory are two independent concepts! For instance, `(@v1.10) pkg> activate folderB` and then `julia> cd("folderA")`, will activate the project in `folderB` and change the current working directory to `folderA`.
|
||||||
|
|
||||||
At this point all package-related operations will be local to the new project. For instance, install the `DataFrames` package.
|
At this point all package-related operations will be local to the new project. For instance, install the `DataFrames` package.
|
||||||
|
|
||||||
@ -271,7 +277,7 @@ Now, we can return to the global project to check that `DataFrames` has not been
|
|||||||
```julia
|
```julia
|
||||||
(lessons) pkg> activate
|
(lessons) pkg> activate
|
||||||
```
|
```
|
||||||
The prompt is again `(@v1.8) pkg>`
|
The prompt is again `(@v1.10) pkg>`
|
||||||
|
|
||||||
Now, try to use `DataFrames`.
|
Now, try to use `DataFrames`.
|
||||||
|
|
||||||
@ -295,13 +301,13 @@ In other words, `Project.toml` contains the packages relevant for the user, wher
|
|||||||
You can see the path to the current `Project.toml` file by using the `status` operator (or `st` in its short form) while in package mode
|
You can see the path to the current `Project.toml` file by using the `status` operator (or `st` in its short form) while in package mode
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> status
|
(@v1.10) pkg> status
|
||||||
```
|
```
|
||||||
|
|
||||||
The information about the `Manifest.toml` can be inspected by passing the `-m` flag.
|
The information about the `Manifest.toml` can be inspected by passing the `-m` flag.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> status -m
|
(@v1.10) pkg> status -m
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing packages from a project file
|
### Installing packages from a project file
|
||||||
@ -325,7 +331,7 @@ julia> mkdir("newproject")
|
|||||||
|
|
||||||
To install all the packages registered in this file you need to activate the folder containing your `Project.toml` file
|
To install all the packages registered in this file you need to activate the folder containing your `Project.toml` file
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> activate newproject
|
(@v1.10) pkg> activate newproject
|
||||||
```
|
```
|
||||||
and then *instantiating* it
|
and then *instantiating* it
|
||||||
```julia
|
```julia
|
||||||
@ -339,12 +345,12 @@ The instantiate command will download and install all listed packages and their
|
|||||||
You can get help about a particular package operator by writing `help` in front of it
|
You can get help about a particular package operator by writing `help` in front of it
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> help activate
|
(@v1.10) pkg> help activate
|
||||||
```
|
```
|
||||||
|
|
||||||
You can get an overview of all package commands by typing `help` alone
|
You can get an overview of all package commands by typing `help` alone
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> help
|
(@v1.10) pkg> help
|
||||||
```
|
```
|
||||||
|
|
||||||
### Package operations in Julia code
|
### Package operations in Julia code
|
||||||
@ -357,7 +363,7 @@ julia> Pkg.status()
|
|||||||
```
|
```
|
||||||
is equivalent to calling `status` in package mode.
|
is equivalent to calling `status` in package mode.
|
||||||
```julia
|
```julia
|
||||||
(@v1.8) pkg> status
|
(@v1.10) pkg> status
|
||||||
```
|
```
|
||||||
|
|
||||||
## Conclusion
|
## Conclusion
|
||||||
|
|||||||
@ -44,7 +44,7 @@ julia> notebook()
|
|||||||
|
|
||||||
## Authors
|
## Authors
|
||||||
|
|
||||||
This material is created by [Francesc Verdugo](https://github.com/fverdugo/) with the help of [Gelieza Kötterheinrich](https://www.linkedin.com/in/gelieza/). Part of the notebooks are based on the course slides by [Henri Bal](https://www.vuhpdc.net/henri-bal/).
|
This material is created by [Francesc Verdugo](https://github.com/fverdugo/) with the help of [Gelieza Kötterheinrich](https://www.linkedin.com/in/gelieza-k/). Part of the notebooks are based on the course slides by [Henri Bal](https://www.vuhpdc.net/henri-bal/).
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@ -2,19 +2,6 @@
|
|||||||
|
|
||||||
## Julia Basics
|
## Julia Basics
|
||||||
|
|
||||||
### NB1-Q1
|
|
||||||
|
|
||||||
In the first, line we assign a variable to a value. In the second line, we assign another variable to the same value. Thus,we have 2 variables associated with the same value. In line 3, we associate `y` to a new value (re-assignment). Thus, we have 2 variables associated with 2 different values. Variable `x` is still associated with its original value. Thus, the value at the final line is `x=1`.
|
|
||||||
|
|
||||||
### NB1-Q2
|
|
||||||
|
|
||||||
It will be `1` for very similar reasons as in the previous questions: we are reassigning a local variable, not the global variable defined outside the function.
|
|
||||||
|
|
||||||
### NB1-Q3
|
|
||||||
|
|
||||||
It will be `6`. In the returned function `f2`, `x` is equal to `2`. Thus, when calling `f2(3)` we compute `2*3`.
|
|
||||||
|
|
||||||
|
|
||||||
### Exercise 1
|
### Exercise 1
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
@ -50,77 +37,10 @@ heatmap(x,y,(i,j)->mandel(i,j,max_iters))
|
|||||||
|
|
||||||
## Asynchronous programming in Julia
|
## Asynchronous programming in Julia
|
||||||
|
|
||||||
### NB2-Q1
|
|
||||||
|
|
||||||
Evaluating `compute_π(100_000_000)` takes about 0.25 seconds. Thus, the loop would take about 2.5 seconds since we are calling the function 10 times.
|
|
||||||
|
|
||||||
### NB2-Q2
|
|
||||||
|
|
||||||
The time in doing the loop will be almost zero since the loop just schedules 10 tasks, which should be very fast.
|
|
||||||
|
|
||||||
### NB2-Q3
|
|
||||||
|
|
||||||
It will take 2.5 seconds, like in question 1. The `@sync` macro forces to wait for all tasks we have generated with the `@async` macro. Since we have created 10 tasks and each of them takes about 0.25 seconds, the total time will be about 2.5 seconds.
|
|
||||||
|
|
||||||
### NB2-Q4
|
|
||||||
|
|
||||||
It will take about 3 seconds. The channel has buffer size 4, thus the call to `put!`will not block. The call to `take!` will not block neither since there is a value stored in the channel. The taken value is 3 and therefore we will wait for 3 seconds.
|
|
||||||
|
|
||||||
### NB2-Q5
|
|
||||||
|
|
||||||
The channel is not buffered and therefore the call to `put!` will block. The cell will run forever, since there is no other task that calls `take!` on this channel.
|
|
||||||
|
|
||||||
## Distributed computing in Julia
|
## Distributed computing in Julia
|
||||||
|
|
||||||
### NB3-Q1
|
|
||||||
|
|
||||||
We send the matrix (16 entries) and then we receive back the result (1 extra integer). Thus, the total number of transferred integers in 17.
|
|
||||||
|
|
||||||
### NB3-Q2
|
|
||||||
|
|
||||||
Even though we only use a single entry of the matrix in the remote worker, the entire matrix is captured and sent to the worker. Thus, we will transfer 17 integers like in Question 1.
|
|
||||||
|
|
||||||
### NB3-Q3
|
|
||||||
|
|
||||||
The value of `x` will still be zero since the worker receives a copy of the matrix and it modifies this copy, not the original one.
|
|
||||||
|
|
||||||
### NB3-Q4
|
|
||||||
|
|
||||||
In this case, the code `a[2]=2` is executed in the main process. Since the matrix is already in the main process, it is not needed to create and send a copy of it. Thus, the code modifies the original matrix and the value of `x` will be 2.
|
|
||||||
|
|
||||||
## Distributed computing with MPI
|
|
||||||
|
|
||||||
### Exercise 1
|
### Exercise 1
|
||||||
|
|
||||||
```julia
|
|
||||||
using MPI
|
|
||||||
MPI.Init()
|
|
||||||
comm = MPI.Comm_dup(MPI.COMM_WORLD)
|
|
||||||
rank = MPI.Comm_rank(comm)
|
|
||||||
nranks = MPI.Comm_size(comm)
|
|
||||||
buffer = Ref(0)
|
|
||||||
if rank == 0
|
|
||||||
msg = 2
|
|
||||||
buffer[] = msg
|
|
||||||
println("msg = $(buffer[])")
|
|
||||||
MPI.Send(buffer,comm;dest=rank+1,tag=0)
|
|
||||||
MPI.Recv!(buffer,comm;source=nranks-1,tag=0)
|
|
||||||
println("msg = $(buffer[])")
|
|
||||||
else
|
|
||||||
dest = if (rank != nranks-1)
|
|
||||||
rank+1
|
|
||||||
else
|
|
||||||
0
|
|
||||||
end
|
|
||||||
MPI.Recv!(buffer,comm;source=rank-1,tag=0)
|
|
||||||
buffer[] += 1
|
|
||||||
println("msg = $(buffer[])")
|
|
||||||
MPI.Send(buffer,comm;dest,tag=0)
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
### Exercise 2
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
f = () -> Channel{Int}(1)
|
f = () -> Channel{Int}(1)
|
||||||
chnls = [ RemoteChannel(f,w) for w in workers() ]
|
chnls = [ RemoteChannel(f,w) for w in workers() ]
|
||||||
@ -160,6 +80,38 @@ end
|
|||||||
msg = 2
|
msg = 2
|
||||||
@fetchfrom 2 work(msg)
|
@fetchfrom 2 work(msg)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## MPI (Point-to-point)
|
||||||
|
|
||||||
|
### Exercise 1
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using MPI
|
||||||
|
MPI.Init()
|
||||||
|
comm = MPI.Comm_dup(MPI.COMM_WORLD)
|
||||||
|
rank = MPI.Comm_rank(comm)
|
||||||
|
nranks = MPI.Comm_size(comm)
|
||||||
|
buffer = Ref(0)
|
||||||
|
if rank == 0
|
||||||
|
msg = 2
|
||||||
|
buffer[] = msg
|
||||||
|
println("msg = $(buffer[])")
|
||||||
|
MPI.Send(buffer,comm;dest=rank+1,tag=0)
|
||||||
|
MPI.Recv!(buffer,comm;source=nranks-1,tag=0)
|
||||||
|
println("msg = $(buffer[])")
|
||||||
|
else
|
||||||
|
dest = if (rank != nranks-1)
|
||||||
|
rank+1
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
MPI.Recv!(buffer,comm;source=rank-1,tag=0)
|
||||||
|
buffer[] += 1
|
||||||
|
println("msg = $(buffer[])")
|
||||||
|
MPI.Send(buffer,comm;dest,tag=0)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
## Matrix-matrix multiplication
|
## Matrix-matrix multiplication
|
||||||
|
|
||||||
### Exercise 1
|
### Exercise 1
|
||||||
@ -209,10 +161,6 @@ end
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### Exercise 2
|
|
||||||
|
|
||||||
At each call to @spawnat we will communicate O(N) and compute O(N) in a worker process just like in algorithm 1. However, we will do this work N^2/P times on average at each worker. Thus, the total communication and computation on a worker will be O(N^3/P) for both communication and computation. Thus, the communication over computation ratio will still be O(1) and thus the communication will dominate in practice, making the algorithm inefficient.
|
|
||||||
|
|
||||||
## Jacobi method
|
## Jacobi method
|
||||||
|
|
||||||
### Exercise 1
|
### Exercise 1
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 6.2 MiB After Width: | Height: | Size: 6.5 MiB |
@ -365,6 +365,84 @@
|
|||||||
id="path8527-8"
|
id="path8527-8"
|
||||||
inkscape:connector-curvature="0" />
|
inkscape:connector-curvature="0" />
|
||||||
</marker>
|
</marker>
|
||||||
|
<marker
|
||||||
|
style="overflow:visible"
|
||||||
|
id="marker8529-3-3"
|
||||||
|
refX="0"
|
||||||
|
refY="0"
|
||||||
|
orient="auto"
|
||||||
|
inkscape:stockid="Arrow2Mend"
|
||||||
|
inkscape:isstock="true"
|
||||||
|
inkscape:collect="always">
|
||||||
|
<path
|
||||||
|
transform="scale(-0.6)"
|
||||||
|
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
||||||
|
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||||
|
id="path8527-8-6"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
inkscape:isstock="true"
|
||||||
|
inkscape:stockid="Arrow2Mend"
|
||||||
|
orient="auto"
|
||||||
|
refY="0"
|
||||||
|
refX="0"
|
||||||
|
id="marker4031-1"
|
||||||
|
style="overflow:visible"
|
||||||
|
inkscape:collect="always">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path4029-0"
|
||||||
|
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||||
|
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
||||||
|
transform="scale(-0.6)" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
style="overflow:visible"
|
||||||
|
id="marker4223-6"
|
||||||
|
refX="0"
|
||||||
|
refY="0"
|
||||||
|
orient="auto"
|
||||||
|
inkscape:stockid="Arrow2Mend"
|
||||||
|
inkscape:isstock="true">
|
||||||
|
<path
|
||||||
|
transform="scale(-0.6)"
|
||||||
|
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
||||||
|
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||||
|
id="path4221-3"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
inkscape:isstock="true"
|
||||||
|
inkscape:stockid="Arrow2Mend"
|
||||||
|
orient="auto"
|
||||||
|
refY="0"
|
||||||
|
refX="0"
|
||||||
|
id="marker4031-5"
|
||||||
|
style="overflow:visible"
|
||||||
|
inkscape:collect="always">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path4029-3"
|
||||||
|
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||||
|
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
||||||
|
transform="scale(-0.6)" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
style="overflow:visible"
|
||||||
|
id="marker4223-5"
|
||||||
|
refX="0"
|
||||||
|
refY="0"
|
||||||
|
orient="auto"
|
||||||
|
inkscape:stockid="Arrow2Mend"
|
||||||
|
inkscape:isstock="true">
|
||||||
|
<path
|
||||||
|
transform="scale(-0.6)"
|
||||||
|
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
||||||
|
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||||
|
id="path4221-6"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</marker>
|
||||||
</defs>
|
</defs>
|
||||||
<sodipodi:namedview
|
<sodipodi:namedview
|
||||||
id="base"
|
id="base"
|
||||||
@ -373,9 +451,9 @@
|
|||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="0.70000001"
|
inkscape:zoom="0.98994951"
|
||||||
inkscape:cx="4005.3666"
|
inkscape:cx="6863.501"
|
||||||
inkscape:cy="58.38566"
|
inkscape:cy="332.85381"
|
||||||
inkscape:document-units="mm"
|
inkscape:document-units="mm"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
inkscape:document-rotation="0"
|
inkscape:document-rotation="0"
|
||||||
@ -2678,5 +2756,439 @@
|
|||||||
y="194.96161"
|
y="194.96161"
|
||||||
x="1153.2484">20</tspan></text>
|
x="1153.2484">20</tspan></text>
|
||||||
</g>
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(192.3794,-112.09032)"
|
||||||
|
id="g5148-2"
|
||||||
|
inkscape:export-filename="/home/francesc/Downloads/g5148.png"
|
||||||
|
inkscape:export-xdpi="200"
|
||||||
|
inkscape:export-ydpi="200">
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.529167;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 1359.9626,79.585912 h 20.9409"
|
||||||
|
id="path978-3-6-3-0"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
id="path1168-6-1-6-6"
|
||||||
|
d="m 1314.5268,79.585912 h 20.9408"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.529167;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<g
|
||||||
|
transform="translate(1155.5468,183.31702)"
|
||||||
|
id="g1148-7-5-75-1">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1063-5-5-3-5"
|
||||||
|
d="m 129.89807,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
id="path1065-3-4-5-5"
|
||||||
|
d="m 142.88845,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc"
|
||||||
|
id="path1067-56-7-62-4"
|
||||||
|
d="m 129.89807,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1069-2-6-9-7"
|
||||||
|
d="m 147.21857,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1071-91-5-1-6"
|
||||||
|
d="m 145.48652,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1073-2-6-2-5"
|
||||||
|
d="m 145.48652,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1075-7-9-7-6"
|
||||||
|
d="m 145.48652,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(1163.1327,183.31701)"
|
||||||
|
id="g1157-09-3-0-9">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1086-3-7-93-3"
|
||||||
|
d="m 169.05642,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
id="path1088-6-4-6-7"
|
||||||
|
d="m 182.0468,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc"
|
||||||
|
id="path1090-0-5-0-4"
|
||||||
|
d="m 169.05642,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1092-6-2-6-5"
|
||||||
|
d="m 186.37692,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1094-2-5-2-2"
|
||||||
|
d="m 184.64487,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1096-6-4-6-5"
|
||||||
|
d="m 184.64487,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1098-1-7-1-4"
|
||||||
|
d="m 184.64487,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
y="15.986771"
|
||||||
|
x="1244.8425"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);stroke-width:1.87007797"
|
||||||
|
id="text1128-7-8-4-8-7"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="stroke-width:1.87007797"
|
||||||
|
id="tspan78-79-4-7-4"
|
||||||
|
y="103.6842"
|
||||||
|
x="1289.8303">worker 1</tspan></text>
|
||||||
|
<text
|
||||||
|
y="15.986771"
|
||||||
|
x="1294.8483"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1184);stroke-width:1.87007797"
|
||||||
|
id="text1182-0-0-2-3"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="stroke-width:1.87007797"
|
||||||
|
id="tspan83-2-7-0-0"
|
||||||
|
y="103.6842"
|
||||||
|
x="1339.8361">worker 2</tspan></text>
|
||||||
|
<g
|
||||||
|
id="g970-7-6-3-8"
|
||||||
|
transform="translate(1209.6376,183.31701)">
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 169.05642,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||||
|
id="path956-5-8-7-6"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 182.0468,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||||
|
id="path958-92-8-5-8"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 169.05642,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||||
|
id="path960-2-4-9-8"
|
||||||
|
sodipodi:nodetypes="ccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 186.37692,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||||
|
id="path962-8-3-2-4"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 184.64487,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||||
|
id="path964-9-1-2-3"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 184.64487,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||||
|
id="path966-7-4-8-1"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 184.64487,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||||
|
id="path968-3-9-9-4"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
id="text976-6-2-7-9"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1184);stroke-width:1.87007797"
|
||||||
|
x="1342.9568"
|
||||||
|
y="15.986771"><tspan
|
||||||
|
x="1387.9445"
|
||||||
|
y="103.6842"
|
||||||
|
id="tspan974-1-0-3-2"
|
||||||
|
style="stroke-width:1.87007797">worker 3</tspan></text>
|
||||||
|
<text
|
||||||
|
y="-54.098297"
|
||||||
|
x="1247.6248"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="text1128-7-8-7-3-7-0-06"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="tspan78-79-8-2-1-3-8"
|
||||||
|
y="33.599152"
|
||||||
|
x="1292.6124">msg</tspan></text>
|
||||||
|
<path
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1386-9"
|
||||||
|
d="m 1304.0316,27.773394 c 16.0706,-14.103005 27.5564,-13.085868 41.886,-0.615601"
|
||||||
|
style="fill:none;stroke:#0000ff;stroke-width:0.76499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker8529-3-3)" />
|
||||||
|
<text
|
||||||
|
y="-54.561871"
|
||||||
|
x="1290.4174"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="text1128-7-8-7-3-7-0-0-2"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="tspan78-79-8-2-1-3-6-6"
|
||||||
|
y="33.135578"
|
||||||
|
x="1335.405">msg+=1</tspan></text>
|
||||||
|
<text
|
||||||
|
y="-53.871326"
|
||||||
|
x="1338.3951"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="text1128-7-8-7-3-7-0-0-3-6"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="tspan78-79-8-2-1-3-6-2-4"
|
||||||
|
y="33.826126"
|
||||||
|
x="1383.3828">msg+=1</tspan></text>
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#0000ff;stroke-width:0.76499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4031-1)"
|
||||||
|
d="m 1354.3024,27.773394 c 16.0706,-14.103005 27.5564,-13.085868 41.886,-0.615601"
|
||||||
|
id="path4027-9"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path4219-5"
|
||||||
|
d="m 1402.8962,28.340358 c -14.7223,-30.9560949 -88.632,-34.6967981 -104.63,-1.371553"
|
||||||
|
style="fill:none;stroke:#0000ff;stroke-width:0.76499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4223-6)" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g2038"
|
||||||
|
inkscape:export-xdpi="200"
|
||||||
|
inkscape:export-ydpi="200">
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.529167;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 1861.8989,152.34405 h 20.9409"
|
||||||
|
id="path978-3-6-3-1"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
id="path1168-6-1-6-2"
|
||||||
|
d="m 1816.4631,152.34405 h 20.9408"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.529167;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<g
|
||||||
|
transform="translate(1657.4831,256.07516)"
|
||||||
|
id="g1148-7-5-75-7">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1063-5-5-3-0"
|
||||||
|
d="m 129.89807,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
id="path1065-3-4-5-9"
|
||||||
|
d="m 142.88845,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc"
|
||||||
|
id="path1067-56-7-62-3"
|
||||||
|
d="m 129.89807,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1069-2-6-9-6"
|
||||||
|
d="m 147.21857,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1071-91-5-1-0"
|
||||||
|
d="m 145.48652,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1073-2-6-2-6"
|
||||||
|
d="m 145.48652,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1075-7-9-7-2"
|
||||||
|
d="m 145.48652,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(1665.069,256.07515)"
|
||||||
|
id="g1157-09-3-0-6">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1086-3-7-93-1"
|
||||||
|
d="m 169.05642,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
id="path1088-6-4-6-8"
|
||||||
|
d="m 182.0468,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc"
|
||||||
|
id="path1090-0-5-0-7"
|
||||||
|
d="m 169.05642,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1092-6-2-6-9"
|
||||||
|
d="m 186.37692,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1094-2-5-2-20"
|
||||||
|
d="m 184.64487,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1096-6-4-6-2"
|
||||||
|
d="m 184.64487,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1098-1-7-1-3"
|
||||||
|
d="m 184.64487,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
y="88.744911"
|
||||||
|
x="1746.7788"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);stroke-width:1.87007797"
|
||||||
|
id="text1128-7-8-4-8-75"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="stroke-width:1.87007797"
|
||||||
|
id="tspan78-79-4-7-9"
|
||||||
|
y="176.44234"
|
||||||
|
x="1791.7666">rank 0<tspan
|
||||||
|
id="tspan76-2-3-9-2"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;stroke-width:1.87007797" /></tspan></text>
|
||||||
|
<text
|
||||||
|
y="88.744911"
|
||||||
|
x="1796.7845"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1184);stroke-width:1.87007797"
|
||||||
|
id="text1182-0-0-2-2"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="stroke-width:1.87007797"
|
||||||
|
id="tspan83-2-7-0-8"
|
||||||
|
y="176.44234"
|
||||||
|
x="1841.7723">rank 1<tspan
|
||||||
|
id="tspan81-3-8-2-9"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;stroke-width:1.87007797" /></tspan></text>
|
||||||
|
<g
|
||||||
|
id="g970-7-6-3-7"
|
||||||
|
transform="translate(1711.5739,256.07515)">
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 169.05642,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||||
|
id="path956-5-8-7-3"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 182.0468,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||||
|
id="path958-92-8-5-6"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 169.05642,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||||
|
id="path960-2-4-9-1"
|
||||||
|
sodipodi:nodetypes="ccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 186.37692,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||||
|
id="path962-8-3-2-2"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 184.64487,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||||
|
id="path964-9-1-2-9"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 184.64487,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||||
|
id="path966-7-4-8-3"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 184.64487,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||||
|
id="path968-3-9-9-1"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
id="text976-6-2-7-94"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1184);stroke-width:1.87007797"
|
||||||
|
x="1844.8931"
|
||||||
|
y="88.744911"><tspan
|
||||||
|
x="1889.8807"
|
||||||
|
y="176.44234"
|
||||||
|
id="tspan974-1-0-3-7"
|
||||||
|
style="stroke-width:1.87007797">rank 2</tspan></text>
|
||||||
|
<text
|
||||||
|
y="-2.3611109"
|
||||||
|
x="1822.4244"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="text1128-7-8-7-3-7-0-0-3-61"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="tspan78-79-8-2-1-3-6-2-0"
|
||||||
|
y="85.336334"
|
||||||
|
x="1867.4121">msg</tspan></text>
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#0000ff;stroke-width:0.76499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4031-5)"
|
||||||
|
d="m 1854.3678,99.061558 c 16.0706,-14.103008 27.5564,-13.085871 41.886,-0.615604"
|
||||||
|
id="path4027-6"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<text
|
||||||
|
y="18.408323"
|
||||||
|
x="1793.9163"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="text1128-7-8-7-3-7-0-0-3-61-2"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
style="fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
id="tspan78-79-8-2-1-3-6-2-0-0"
|
||||||
|
y="106.10577"
|
||||||
|
x="1838.9039">MPI_Send</tspan></text>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
id="text1992"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||||
|
x="1841.223"
|
||||||
|
y="18.408323"><tspan
|
||||||
|
x="1886.2107"
|
||||||
|
y="106.10577"
|
||||||
|
id="tspan1990"
|
||||||
|
style="fill:#0000ff;stroke-width:1.87007797">MPI_Recv</tspan><tspan
|
||||||
|
id="tspan1994"
|
||||||
|
x="1886.2107"
|
||||||
|
y="106.10577"
|
||||||
|
style="fill:#0000ff;stroke-width:1.87007797" /></text>
|
||||||
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 189 KiB |
BIN
notebooks/figures/fig_p2p.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
notebooks/figures/g5148-2.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
notebooks/figures/g5148.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
@ -28,6 +28,56 @@
|
|||||||
"Understanding these concepts is important to learn distributed computing later."
|
"Understanding these concepts is important to learn distributed computing later."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "cde5ee75",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"<div class=\"alert alert-block alert-info\">\n",
|
||||||
|
"<b>Note:</b> Do not forget to execute the next cell before starting this notebook! \n",
|
||||||
|
"</div>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "0b0496c7",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"function why_q1()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" Evaluating compute_π(100_000_000) takes about 0.25 seconds on the teacher's laptop. Thus, the loop would take about 2.5 seconds since we are calling the function 10 times.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"function why_q2()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" The time in doing the loop will be almost zero since the loop just schedules 10 tasks, which should be very fast.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"function why_q3()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" It will take 2.5 seconds, like in question 1. The @sync macro forces to wait for all tasks we have generated with the @async macro. Since we have created 10 tasks and each of them takes about 0.25 seconds, the total time will be about 2.5 seconds.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"function why_q4()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" It will take about 3 seconds. The channel has buffer size 4, thus the call to put!will not block. The call to take! will not block neither since there is a value stored in the channel. The taken value is 3 and therefore we will wait for 3 seconds.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"function why_q5()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" The channel is not buffered and therefore the call to put! will block. The cell will run forever, since there is no other task that calls take! on this channel.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"println(\"🥳 Well done! \")"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "caf64254",
|
"id": "caf64254",
|
||||||
@ -37,7 +87,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"### Creating a task\n",
|
"### Creating a task\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Technically, a task in Julia is a *symmetric co-routine*. More informally, a task is a piece of computation work that can be started (scheduled) at some point in the future, and that can be interrupted and resumed. To create a task, we first need to create a function that represents the work to be done in the task. In next cell, we generate a task that generates and sums two matrices."
|
"Technically, a task in Julia is a *symmetric* [*co-routine*](https://en.wikipedia.org/wiki/Coroutine). More informally, a task is a piece of computational work that can be started (scheduled) at some point in the future, and that can be interrupted and resumed. To create a task, we first need to create a function that represents the work to be done in the task. In next cell, we generate a task that generates and sums two matrices."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -726,6 +776,16 @@
|
|||||||
"end"
|
"end"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d6b8382e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q1()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "5f19d38c",
|
"id": "5f19d38c",
|
||||||
@ -754,6 +814,16 @@
|
|||||||
"end"
|
"end"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "edff9747",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q2()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "5041c355",
|
"id": "5041c355",
|
||||||
@ -781,6 +851,16 @@
|
|||||||
"end"
|
"end"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "87bc7c5c",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q3()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "841b690e",
|
"id": "841b690e",
|
||||||
@ -821,6 +901,16 @@
|
|||||||
"end"
|
"end"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "a18a0a7d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q4()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "df663f11",
|
"id": "df663f11",
|
||||||
@ -860,6 +950,26 @@
|
|||||||
"end"
|
"end"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d8923fae",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q5()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "0ee77abe",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"<div class=\"alert alert-block alert-info\">\n",
|
||||||
|
"<b>Note:</b> If for some reason a cell keeps running forever, we can stop it with Kernel > Interrupt or Kernel > Restart (see tabs above).\n",
|
||||||
|
"</div>"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "a5d3730b",
|
"id": "a5d3730b",
|
||||||
@ -873,15 +983,15 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Julia 1.9.0",
|
"display_name": "Julia 1.10.0",
|
||||||
"language": "julia",
|
"language": "julia",
|
||||||
"name": "julia-1.9"
|
"name": "julia-1.10"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"file_extension": ".jl",
|
"file_extension": ".jl",
|
||||||
"mimetype": "application/julia",
|
"mimetype": "application/julia",
|
||||||
"name": "julia",
|
"name": "julia",
|
||||||
"version": "1.9.0"
|
"version": "1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@ -147,6 +147,44 @@
|
|||||||
"foo()"
|
"foo()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "d18e679d",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### A very easy first exercise\n",
|
||||||
|
"\n",
|
||||||
|
"Run the following cell. It contains definitions used later in the notebook."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "81678b3d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"function why_q1()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" In the first line, we assign a variable to a value. In the second line, we assign another variable to the same value. Thus, we have 2 variables associated with the same value. In line 3, we associate y to a new value (re-assignment). Thus, we have 2 variables associated with 2 different values. Variable x is still associated with its original value. Thus, the value at the final line is x=1.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"function why_q2()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" It will be 1 for very similar reasons as in the previous questions: we are reassigning a local variable, not the global variable defined outside the function.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"function why_q3()\n",
|
||||||
|
" msg = \"\"\"\n",
|
||||||
|
" It will be 6. In the returned function f2, x is equal to 2. Thus, when calling f2(3) we compute 2*3.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" println(msg)\n",
|
||||||
|
"end\n",
|
||||||
|
"println(\"🥳 Well done! \")"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "92112bd1",
|
"id": "92112bd1",
|
||||||
@ -467,6 +505,24 @@
|
|||||||
"x"
|
"x"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "a2f94960",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Run next cell to get an explanation of this question."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "fc562337",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q1()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "4d2cb752",
|
"id": "4d2cb752",
|
||||||
@ -586,6 +642,24 @@
|
|||||||
"x"
|
"x"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "f69108c2",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Run next cell to get an explanation of this question."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "05c62aa3",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q2()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "4fc5eb9b",
|
"id": "4fc5eb9b",
|
||||||
@ -1068,6 +1142,24 @@
|
|||||||
"x"
|
"x"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "062ff145",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Run next cell to get an explanation of this question."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6bf7818e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"why_q3()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "bc8e9bcf",
|
"id": "bc8e9bcf",
|
||||||
@ -1649,15 +1741,15 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Julia 1.9.0",
|
"display_name": "Julia 1.10.0",
|
||||||
"language": "julia",
|
"language": "julia",
|
||||||
"name": "julia-1.9"
|
"name": "julia-1.10"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"file_extension": ".jl",
|
"file_extension": ".jl",
|
||||||
"mimetype": "application/julia",
|
"mimetype": "application/julia",
|
||||||
"name": "julia",
|
"name": "julia",
|
||||||
"version": "1.9.0"
|
"version": "1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
1848
notebooks/julia_mpi.ipynb
Normal file
@ -219,10 +219,10 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"<div class=\"alert alert-block alert-info\">\n",
|
"<div class=\"alert alert-block alert-info\">\n",
|
||||||
"<b>Note:</b> The matrix-matrix multiplication naively implemented with 3 nested loops as above is known to be very inefficient (memory bound). Libraries such as BLAS provide much more efficient implementations, which are the ones used in practice (e.g., by the `*` operator in Julia). We consider, our hand-written implementation as a simple way of expressing the algorithm we are interested in.\n",
|
"<b>Note:</b> The matrix-matrix multiplication naively implemented with 3 nested loops as above is known to be very inefficient (memory bound). Libraries such as BLAS provide much more efficient implementations, which are the ones used in practice (e.g., by the `*` operator in Julia). We consider our hand-written implementation as a simple way of expressing the algorithm we are interested in.\n",
|
||||||
"</div>\n",
|
"</div>\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Run the following cell to compare the performance of our hand-written function with respect to the built in function `mul!`\n"
|
"Run the following cell to compare the performance of our hand-written function with respect to the built in function `mul!`.\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1060,107 +1060,6 @@
|
|||||||
"println(\"Efficiency = \", 100*(T1/TP)/P, \"%\")"
|
"println(\"Efficiency = \", 100*(T1/TP)/P, \"%\")"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"id": "fa8d7f40",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"### Exercise 2"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"id": "0e7c607e",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"The implementation of algorithm 1 is very impractical. One needs as many processors as entries in the result matrix C. For 1000 times 1000 matrix one would need a supercomputer with one million processes! We can easily fix this problem by using less processors and spawning the computation of an entry in any of the available processes.\n",
|
|
||||||
"See the following code:"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "023b20d1",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"function matmul_dist_1_v2!(C, A, B)\n",
|
|
||||||
" m = size(C,1)\n",
|
|
||||||
" n = size(C,2)\n",
|
|
||||||
" l = size(A,2)\n",
|
|
||||||
" @assert size(A,1) == m\n",
|
|
||||||
" @assert size(B,2) == n\n",
|
|
||||||
" @assert size(B,1) == l\n",
|
|
||||||
" z = zero(eltype(C))\n",
|
|
||||||
" @sync for j in 1:n\n",
|
|
||||||
" for i in 1:m\n",
|
|
||||||
" Ai = A[i,:]\n",
|
|
||||||
" Bj = B[:,j]\n",
|
|
||||||
" ftr = @spawnat :any begin\n",
|
|
||||||
" Cij = z\n",
|
|
||||||
" for k in 1:l\n",
|
|
||||||
" @inbounds Cij += Ai[k]*Bj[k]\n",
|
|
||||||
" end\n",
|
|
||||||
" Cij\n",
|
|
||||||
" end\n",
|
|
||||||
" @async C[i,j] = fetch(ftr)\n",
|
|
||||||
" end\n",
|
|
||||||
" end\n",
|
|
||||||
" C\n",
|
|
||||||
"end"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"id": "52005ca1",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"With this new implementation, we can multiply matrices of arbitrary size with a fixed number of workers. Test it:"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "c1d3595b",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"using Test\n",
|
|
||||||
"N = 50\n",
|
|
||||||
"A = rand(N,N)\n",
|
|
||||||
"B = rand(N,N)\n",
|
|
||||||
"C = similar(A)\n",
|
|
||||||
"@test matmul_dist_1_v2!(C,A,B) ≈ A*B"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"id": "ab609c18",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"Run the next cell to check the performance of this implementation. Note that we are far away from the optimal speed up. Why? To answer this question compute the theoretical communication over computation ratio for this implementation and reason about the obtained result. Hint: the number of times a worker is spawned in this implementation is N^2/P on average."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "d7d31710",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"N = 100\n",
|
|
||||||
"A = rand(N,N)\n",
|
|
||||||
"B = rand(N,N)\n",
|
|
||||||
"C = similar(A)\n",
|
|
||||||
"P = nworkers()\n",
|
|
||||||
"T1 = @belapsed matmul_seq!(C,A,B)\n",
|
|
||||||
"C = similar(A)\n",
|
|
||||||
"TP = @belapsed matmul_dist_1_v2!(C,A,B)\n",
|
|
||||||
"println(\"Speedup = \", T1/TP)\n",
|
|
||||||
"println(\"Optimal speedup = \", P)\n",
|
|
||||||
"println(\"Efficiency = \", 100*(T1/TP)/P, \"%\")"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "8e171362",
|
"id": "8e171362",
|
||||||
@ -1175,15 +1074,15 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Julia 1.9.0",
|
"display_name": "Julia 1.10.0",
|
||||||
"language": "julia",
|
"language": "julia",
|
||||||
"name": "julia-1.9"
|
"name": "julia-1.10"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"file_extension": ".jl",
|
"file_extension": ".jl",
|
||||||
"mimetype": "application/julia",
|
"mimetype": "application/julia",
|
||||||
"name": "julia",
|
"name": "julia",
|
||||||
"version": "1.9.0"
|
"version": "1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||