From a6b8b7e051878d5d981a527f1b43d3b71d74667c Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Thu, 10 Aug 2023 15:17:45 +0200 Subject: [PATCH] Some cleanup and restructuring --- docs/make.jl | 21 +-- docs/src/index.md | 16 +-- docs/src/notebook-output/julia_async.html | 69 +++++++-- docs/src/notebook-output/julia_basics.html | 67 ++++++++- .../notebook-output/julia_distributed.html | 88 +++++++----- docs/src/notebook-output/julia_intro.html | 135 +++++++++++++----- docs/src/notebook-output/matrix_matrix.html | 72 ++++++---- docs/src/notebooks/julia_async.ipynb | 75 +++++++--- docs/src/notebooks/julia_basics.ipynb | 59 ++++++-- docs/src/notebooks/julia_distributed.ipynb | 86 ++++++----- docs/src/notebooks/matrix_matrix.ipynb | 71 ++++----- 11 files changed, 518 insertions(+), 241 deletions(-) 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 {
@@ -15416,8 +15414,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -15429,7 +15426,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
In [ ]:
-
@time compute_π(100_000_000)
+
t = @elapsed compute_π(100_000_000)
 
@@ -15437,6 +15434,25 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
+ +
+
@@ -15491,7 +15516,15 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -15520,7 +15553,15 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -15568,7 +15609,15 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
diff --git a/docs/src/notebook-output/julia_basics.html b/docs/src/notebook-output/julia_basics.html index 78e8917..2145075 100644 --- a/docs/src/notebook-output/julia_basics.html +++ b/docs/src/notebook-output/julia_basics.html @@ -14600,9 +14600,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -15188,7 +15186,9 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -15250,7 +15250,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -15263,7 +15263,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
In [ ]:
-
result = add(1,3)
+
add(1,3)
 
@@ -15329,6 +15329,57 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
+ +
+ +
+ + +
+ +
diff --git a/docs/src/notebook-output/julia_distributed.html b/docs/src/notebook-output/julia_distributed.html index e10cbba..9509928 100644 --- a/docs/src/notebook-output/julia_distributed.html +++ b/docs/src/notebook-output/julia_distributed.html @@ -14600,36 +14600,10 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
-
- -
@@ -14661,6 +14633,45 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output { + +
+ +
+ +
-
- -
- @@ -14687,7 +14685,37 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
+
+ +
+ + +
+
+ @@ -14730,7 +14758,8 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -14742,7 +14771,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
In [ ]:
-
] add BenchmarkTools DataFrames PyCall Conda Test
+
] add MPI
 
@@ -14766,6 +14795,22 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
+
+ +
+
+
+ @@ -14797,8 +14855,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -14810,9 +14867,12 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
In [ ]:
-
# ✍️ 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 {
@@ -14888,7 +14948,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
@@ -14933,7 +14993,18 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output { +
+ +
+ diff --git a/docs/src/notebooks/julia_async.ipynb b/docs/src/notebooks/julia_async.ipynb index 38a0fbe..b57f58b 100644 --- a/docs/src/notebooks/julia_async.ipynb +++ b/docs/src/notebooks/julia_async.ipynb @@ -8,14 +8,9 @@ "\n", "\n", "### Programming large-scale parallel systems\n", - "### Lectures on Julia for HPC\n", "\n", "\n", - "# Asynchronous programming in Julia\n", - "\n", - "by Francesc Verdugo (VU Amsterdam)\n", - "\n", - "Version fall 2022" + "# Asynchronous programming in Julia\n" ] }, { @@ -583,14 +578,10 @@ }, { "cell_type": "markdown", - "id": "2a23b1c3", + "id": "81de1c86", "metadata": {}, "source": [ - "## Questions\n", - "\n", - "How long the next cells will take each?\n", - "\n", - "### Q1 (Asynchronous.ipynb)" + "## Questions" ] }, { @@ -600,7 +591,22 @@ "metadata": {}, "outputs": [], "source": [ - "@time compute_π(100_000_000)" + "t = @elapsed compute_π(100_000_000)" + ] + }, + { + "cell_type": "markdown", + "id": "2a23b1c3", + "metadata": {}, + "source": [ + "
\n", + "Question (Q1): How long will the compute time of next cell be? \n", + "
\n", + "\n", + " a) 10*t\n", + " b) t\n", + " c) 0.1*t\n", + " d) near 0*t \n" ] }, { @@ -620,7 +626,15 @@ "id": "5f19d38c", "metadata": {}, "source": [ - "### Q2 (Asynchronous.ipynb)" + "
\n", + "Question (Q2): How long will the compute time of next cell be? \n", + "
\n", + "\n", + " a) 10*t\n", + " b) t\n", + " c) 0.1*t\n", + " d) near 0*t \n", + "\n" ] }, { @@ -640,7 +654,14 @@ "id": "5041c355", "metadata": {}, "source": [ - "### Q3 (Asynchronous.ipynb)" + "
\n", + "Question (Q3): How long will the compute time of next cell be? \n", + "
\n", + "\n", + " a) 10*t\n", + " b) t\n", + " c) 0.1*t\n", + " d) near 0*t \n" ] }, { @@ -660,7 +681,14 @@ "id": "841b690e", "metadata": {}, "source": [ - "### Q4 (Asynchronous.ipynb)" + "
\n", + "Question (Q4): How long will the compute time of the 2nd cell be? \n", + "
\n", + "\n", + " a) infinity\n", + " b) 1 second\n", + " c) near 0 seconds\n", + " d) 3 seconds" ] }, { @@ -693,7 +721,14 @@ "id": "df663f11", "metadata": {}, "source": [ - "### Q5 (Asynchronous.ipynb)" + "
\n", + "Question (Q5): How long will the compute time of the 2nd cell be? \n", + "
\n", + "\n", + " a) infinity\n", + " b) 1 second\n", + " c) near 0 seconds\n", + " d) 3 seconds" ] }, { @@ -723,15 +758,15 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.8.5", + "display_name": "Julia 1.9.0", "language": "julia", - "name": "julia-1.8" + "name": "julia-1.9" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.8.5" + "version": "1.9.0" } }, "nbformat": 4, diff --git a/docs/src/notebooks/julia_basics.ipynb b/docs/src/notebooks/julia_basics.ipynb index 8c21976..42f1016 100644 --- a/docs/src/notebooks/julia_basics.ipynb +++ b/docs/src/notebooks/julia_basics.ipynb @@ -8,14 +8,9 @@ "\n", "\n", "### Programming large-scale parallel systems\n", - "### Lectures on Julia for HPC\n", "\n", "\n", - "# Basics of Julia\n", - "\n", - "by Francesc Verdugo (VU Amsterdam)\n", - "\n", - "Version fall 2022" + "# Julia basics" ] }, { @@ -437,9 +432,11 @@ "id": "d36ba0ae", "metadata": {}, "source": [ - "### Question 1\n", "\n", - "Which will be the value of `x` in the last line ?" + "
\n", + "Question: Which will be the value of `x` in the last line ? (Think your answer before executing next cell to find out the result) \n", + "
\n", + "\n" ] }, { @@ -486,7 +483,7 @@ "id": "de95c63c", "metadata": {}, "source": [ - "Once defined, a function can be called using bracket notation." + "Once defined, a function can be called using bracket notation as you would expect." ] }, { @@ -496,7 +493,7 @@ "metadata": {}, "outputs": [], "source": [ - "result = add(1,3)" + "add(1,3)" ] }, { @@ -539,6 +536,41 @@ "a .* b" ] }, + { + "cell_type": "markdown", + "id": "58a4e395", + "metadata": {}, + "source": [ + "
\n", + "Question: Which will be the value of `x` in the last line ?\n", + "
\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4952cce7", + "metadata": {}, + "outputs": [], + "source": [ + "function q(x)\n", + " x = 2\n", + " x\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a1134379", + "metadata": {}, + "outputs": [], + "source": [ + "x = 1\n", + "y = q(x)\n", + "x" + ] + }, { "cell_type": "markdown", "id": "d20bc3a4", @@ -947,9 +979,10 @@ "id": "94599fa3", "metadata": {}, "source": [ - "### Question 2\n", - "\n", - "Which will be the value of `x` below?" + "
\n", + "Question: Which will be the value of `x` below? \n", + "
\n", + "\n" ] }, { diff --git a/docs/src/notebooks/julia_distributed.ipynb b/docs/src/notebooks/julia_distributed.ipynb index 60648aa..00defa3 100644 --- a/docs/src/notebooks/julia_distributed.ipynb +++ b/docs/src/notebooks/julia_distributed.ipynb @@ -7,28 +7,7 @@ "source": [ "\n", "\n", - "### Programming large-scale parallel systems\n", - "### Lectures on Julia for HPC" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "aebf6482", - "metadata": {}, - "outputs": [], - "source": [ - "using Printf\n", - "\n", - "function answer_checker(answer,solution)\n", - " if answer == solution\n", - " \"🥳 Well done! \"\n", - " else\n", - " \"It's not correct. Keep trying! 💪\"\n", - " end |> println\n", - "end\n", - "q_1_check(answer) = answer_checker(answer,\"a\")\n", - "q_2_check(answer) = answer_checker(answer,\"b\")" + "### Programming large-scale parallel systems\n" ] }, { @@ -36,11 +15,7 @@ "id": "2133c064", "metadata": {}, "source": [ - "# Distributed computing in Julia\n", - "\n", - "by Francesc Verdugo (VU Amsterdam)\n", - "\n", - "Version fall 2022" + "# Distributed computing in Julia\n" ] }, { @@ -59,6 +34,35 @@ "With this knowledge you will be able to implement simple and complex parallel algorithms in Julia." ] }, + { + "cell_type": "markdown", + "id": "b9a04db7", + "metadata": {}, + "source": [ + "
\n", + "Note: Do not forget to execute the next cell before starting this notebook! \n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aebf6482", + "metadata": {}, + "outputs": [], + "source": [ + "using Printf\n", + "function answer_checker(answer,solution)\n", + " if answer == solution\n", + " \"🥳 Well done! \"\n", + " else\n", + " \"It's not correct. Keep trying! 💪\"\n", + " end |> println\n", + "end\n", + "q_1_check(answer) = answer_checker(answer,\"a\")\n", + "q_2_check(answer) = answer_checker(answer,\"b\")" + ] + }, { "cell_type": "markdown", "id": "01af032c", @@ -763,9 +767,12 @@ "id": "fd22b74b", "metadata": {}, "source": [ - "### Q1 (Distributed.ipynb)\n", "\n", - "How many integers are transferred between master and worker? Including both directions.\n", + "
\n", + "Question (Q1): How many integers are transferred between master and worker? Including both directions. \n", + "
\n", + "\n", + "\n", "\n", "```julia\n", "a = rand(Int,4,4)\n", @@ -795,9 +802,11 @@ "id": "dbe373d1", "metadata": {}, "source": [ - "### Q2 (Distributed.ipynb)\n", + "
\n", + "Question (Q2): How many integers are transferred between master and worker? Including both directions. \n", + "
\n", + "\n", "\n", - "How many integers are transferred between master and worker? Including both directions.\n", "\n", "```julia\n", "a = rand(Int,4,4)\n", @@ -827,9 +836,10 @@ "id": "c561a73d", "metadata": {}, "source": [ - "### Q3 (Distributed.ipynb)\n", "\n", - "Which value will be the value of `x` ?" + "
\n", + "Question (Q3): Which value will be the value of `x` ? \n", + "
\n" ] }, { @@ -851,7 +861,9 @@ "id": "835080aa", "metadata": {}, "source": [ - "### Q4 (Distributed.ipynb)\n", + "
\n", + "Question (Q4): Which value will be the value of `x` ? \n", + "
\n", "\n", "Which value will be the value of `x` ?" ] @@ -1295,15 +1307,15 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.8.5", + "display_name": "Julia 1.9.0", "language": "julia", - "name": "julia-1.8" + "name": "julia-1.9" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.8.5" + "version": "1.9.0" } }, "nbformat": 4, diff --git a/docs/src/notebooks/matrix_matrix.ipynb b/docs/src/notebooks/matrix_matrix.ipynb index f855159..39ae4fb 100644 --- a/docs/src/notebooks/matrix_matrix.ipynb +++ b/docs/src/notebooks/matrix_matrix.ipynb @@ -1,5 +1,37 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "2a976c0f", + "metadata": {}, + "source": [ + "\n", + "\n", + "### Programming large-scale parallel systems" + ] + }, + { + "cell_type": "markdown", + "id": "038e5442", + "metadata": {}, + "source": [ + "# Matrix-matrix multiplication" + ] + }, + { + "cell_type": "markdown", + "id": "f70e2f35", + "metadata": {}, + "source": [ + "## Contents\n", + "\n", + "In this notebook, we will:\n", + "\n", + "- Parallelize a simple algorithm\n", + "- Study the performance of different parallelization strategies\n", + "- Implement them using Julia" + ] + }, { "cell_type": "markdown", "id": "480af594", @@ -49,28 +81,6 @@ "alg_3_complex_check(answer) = answer_checker(answer, \"d\")" ] }, - { - "cell_type": "markdown", - "id": "038e5442", - "metadata": {}, - "source": [ - "# Distributed matrix-matrix multiplication" - ] - }, - { - "cell_type": "markdown", - "id": "f70e2f35", - "metadata": {}, - "source": [ - "## Contents\n", - "\n", - "In this notebook, we will:\n", - "\n", - "- Parallelize a simple algorithm\n", - "- Study the performance of different parallelization strategies\n", - "- Implement them using Julia" - ] - }, { "cell_type": "markdown", "id": "96d2693d", @@ -82,7 +92,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "88bc2633", "metadata": {}, @@ -118,7 +127,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "5828e243", "metadata": {}, @@ -247,7 +255,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "6a706283", "metadata": {}, @@ -278,7 +285,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "acfb354b", "metadata": {}, @@ -329,7 +335,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "70087bce", "metadata": {}, @@ -556,7 +561,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "62e5c637", "metadata": {}, @@ -616,7 +620,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "fb6b572b", "metadata": {}, @@ -775,7 +778,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "f1b8c712", "metadata": {}, @@ -835,7 +837,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "id": "c14ebcb3", "metadata": {}, @@ -927,7 +928,7 @@ "id": "a628a1df", "metadata": {}, "source": [ - "### Implementation of algorithm 3\n", + "### Exercise 1\n", "\n", "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.\n" ] @@ -1012,7 +1013,7 @@ "id": "fa8d7f40", "metadata": {}, "source": [ - "### A more practical version of algorithm 1" + "### Exercise 2" ] }, { @@ -1119,7 +1120,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.9.1", + "display_name": "Julia 1.9.0", "language": "julia", "name": "julia-1.9" }, @@ -1127,7 +1128,7 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.9.1" + "version": "1.9.0" } }, "nbformat": 4,