diff --git a/docs/make.jl b/docs/make.jl index 0c2d22e..4461ca4 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -102,14 +102,14 @@ end # Loop over notebooks and generate html and markdown notebook_files = glob("*.ipynb", "docs/src/notebooks/") -#for filepath in notebook_files -# convert_embedded_img_to_base64(filepath) -# create_md_nb_file(filepath) -# filename_with_ext = splitpath(filepath)[end] -# filename = splitext(filename_with_ext)[1] -# convert_notebook_to_html(filepath, output_name = filename) -# modify_notebook_html("docs/src/notebook-output/$(filename).html") -#end +for filepath in notebook_files + convert_embedded_img_to_base64(filepath) + create_md_nb_file(filepath) + filename_with_ext = splitpath(filepath)[end] + filename = splitext(filename_with_ext)[1] + convert_notebook_to_html(filepath, output_name = filename) + modify_notebook_html("docs/src/notebook-output/$(filename).html") +end makedocs(; modules=[XM_40017], @@ -125,8 +125,9 @@ makedocs(; "Julia Basics" => "julia_basics.md", "Tasks and channels" => "julia_async.md", "Remote calls and remote channels" => "julia_distributed.md", - "Matrix Multiplication"=>["Matrix Multiplication" => "matrix_matrix.md", "Solutions" => "sol_matrix_matrix.md"], - "Jacobi/SOR" => "julia_jacobi.md" + "Matrix Multiplication"=>"matrix_matrix.md", + "Jacobi/SOR" => "julia_jacobi.md", + "Solutions" => "sol_matrix_matrix.md" ]], ) diff --git a/docs/src/index.md b/docs/src/index.md index c5da625..3c827e0 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -8,8 +8,9 @@ Welcome to the interactive lecture notes of the [Programming Large-Scale Paralle ## What This page contains part of the course material of the Programming Large-Scale Parallel Systems course at VU Amsterdam. -Further information about this course is found in the study guide -([click here](https://studiegids.vu.nl/EN/courses/2023-2024/XM_40017#/)) and our Canvas page (for registered students). This material consists of several lecture notes in jupyter notebook format, which will help you to learn how to design, analyze, and program parallel algorithms on multi-node computing systems. +In this page, we provide several lecture notes in jupyter notebook format, which will help you to learn how to design, analyze, and program parallel algorithms on multi-node computing systems. +Further information about the course is found in the study guide +([click here](https://studiegids.vu.nl/EN/courses/2023-2024/XM_40017#/)) and our Canvas page (for registered students). !!! note This page contains only part of the course material. The rest is available on Canvas. In particular, **the lecture notes in this public webpage do not fully cover all topics in the final exam**. @@ -30,17 +31,6 @@ To run a notebook locally follow these steps: - Install Julia (if not done already). More information in [Getting started](@ref). - Download the notebook. - Launch Julia. More information in [Getting started](@ref). -``` - _ _ _(_)_ | Documentation: https://docs.julialang.org - (_) | (_) (_) | - _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. - | | | | | | |/ _` | | - | | |_| | | | (_| | | Version 1.9.0 (2023-05-07) - _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release -|__/ | - -julia> -``` - Execute these commands in the Julia command line: ``` diff --git a/docs/src/notebook-output/julia_async.html b/docs/src/notebook-output/julia_async.html index c032037..746f8a2 100644 --- a/docs/src/notebook-output/julia_async.html +++ b/docs/src/notebook-output/julia_async.html @@ -14600,9 +14600,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@time compute_π(100_000_000)
+t = @elapsed compute_π(100_000_000)
a) 10*t
+b) t
+c) 0.1*t
+d) near 0*t
+
+
+a) 10*t
+b) t
+c) 0.1*t
+d) near 0*t
+
+
+
a) 10*t
+b) t
+c) 0.1*t
+d) near 0*t
+
+
a) infinity
+b) 1 second
+c) near 0 seconds
+d) 3 seconds
+
+
a) infinity
+b) 1 second
+c) near 0 seconds
+d) 3 seconds
+
+
Which will be the value of x in the last line ?
Once defined, a function can be called using bracket notation.
+Once defined, a function can be called using bracket notation as you would expect.
result = add(1,3)
+add(1,3)
function q(x)
+ x = 2
+ x
+end
+x = 1
+y = q(x)
+x
+Which will be the value of x below?
using Printf
-
-function answer_checker(answer,solution)
- if answer == solution
- "🥳 Well done! "
- else
- "It's not correct. Keep trying! 💪"
- end |> println
-end
-q_1_check(answer) = answer_checker(answer,"a")
-q_2_check(answer) = answer_checker(answer,"b")
-using Printf
+function answer_checker(answer,solution)
+ if answer == solution
+ "🥳 Well done! "
+ else
+ "It's not correct. Keep trying! 💪"
+ end |> println
+end
+q_1_check(answer) = answer_checker(answer,"a")
+q_2_check(answer) = answer_checker(answer,"b")
+How many integers are transferred between master and worker? Including both directions.
+a = rand(Int,4,4)
proc = 4
@fetchfrom proc sum(a^2)
@@ -15663,7 +15676,9 @@ d) 65
How many integers are transferred between master and worker? Including both directions.
+a = rand(Int,4,4)
proc = 4
@fetchfrom proc sum(a[2,2]^2)
@@ -15701,7 +15716,9 @@ d) 32
Which value will be the value of x ?
Which value will be the value of x ?
Which value will be the value of x ?
We will learn
+With this notebook, you will learn
We are going to use Jupyter notebooks in this and other lectures. You provably have worked with notebooks (in Python). If not, here are the basic concepts you need to know to follow the lessons.
+To run a Julia Jupyther notebook, open a Julia REPL and type
+julia> ]
+pkg> add IJulia
+julia> using IJulia
+julia> notebook()
+A new browser window will open. Navigate to the corresponding notebook and open it.
+As you can see from the output of previous cell, the value of the last line is displayed. We can suppress the output with a semicolon. Try it. Execute next cell.
+ +1+3
+4*5;
+Running the two cells below in reverse order won't work (try it).
+] add BenchmarkTools DataFrames PyCall Conda Test
+] add MPI
; ls
+NB. Most of the examples below are taken from the lecture by S.G. Johnson at MIT. See here: +https://github.com/mitmath/18S096/blob/master/lectures/lecture1/Boxes-and-registers.ipynb
+# ✍️ Exercise 1
-function sum_hand(a)
- # TODO
+function sum_hand(a)
+ s = zero(eltype(a))
+ for ai in a
+ s += ai
+ end
+ s
end
@@ -14828,7 +14888,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
In order to track the performance of your code, it is useful to time the execution of single functions. In Julia, the most conventional way of measuring the computation time is the macro @time.
In Julia, the most straight-forward way of measuring the computation time of a piece of code is with the macro @time.
Note that @time also measures the compile time of a function if it's the first call to that function. So make sure to run @time twice on a freshly compiled function in order to get a more meaningful result.
Now in order to benchmark our code, we need to run it several times. To do this we can call our code in a for-loop and gather the runtimes using the Julia macro @elapsed. This measures the runtime of an expression in seconds, just as the @time macro, only @elapsed discards the result of the computation and returns the elapsed time instead.
A part of getting rid of compilation time, one typically wants to measure the runtime several times and compute sole. To do this we can call our code in a for-loop and gather the runtimes using the Julia macro @elapsed. This measures the runtime of an expression in seconds, just as the @time macro, only @elapsed discards the result of the computation and returns the elapsed time instead.
In this notebook, we will:
+In this notebook, we will:
-Implement algorithm 3 in the function below. For simplicity, assume that the number of rows of C is a multiple of the number of workers.
+Implement algorithm 3 in the function below. For simplicity, assume that the number of rows of C is a multiple of the number of workers.