diff --git a/docs/make.jl b/docs/make.jl
index e0d7c89..0c2d22e 100644
--- a/docs/make.jl
+++ b/docs/make.jl
@@ -122,10 +122,9 @@ makedocs(;
canonical="https://fverdugo.github.io/XM_40017",
edit_link="main",),
pages=["Home" => "index.md","Getting started"=>"getting_started_with_julia.md", "Notebooks"=>[
- "Is Julia fast?" => "julia_intro.md",
"Julia Basics" => "julia_basics.md",
- "Julia Asynchronous" => "julia_async.md",
- "Julia Distributed" => "julia_distributed.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"
]],
diff --git a/docs/src/getting_started_with_julia.md b/docs/src/getting_started_with_julia.md
index a6fbc49..f0886bc 100644
--- a/docs/src/getting_started_with_julia.md
+++ b/docs/src/getting_started_with_julia.md
@@ -15,6 +15,10 @@ The programming of this course will be done using the [Julia programming languag
Courses related with high-performance computing (HPC) often use languages such as C, C++, or Fortran. We use Julia instead to make the course accessible to a wider set of students, including the ones that have no experience with
C/C++ or Fortran, but are willing to learn parallel programming. Julia is a relatively new programming language specifically designed for scientific computing. It combines a high-level syntax close to interpreted languages like Python with the performance of compiled languages like C, C++, or Fortran. Thus, Julia will allow us to write efficient parallel algorithms with a syntax that is convenient in a teaching setting. In addition, Julia provides easy access to different programming models to write distributed algorithms, which will be useful to learn and experiment with them.
+!!! tip
+ You can run the code [in this link](https://github.com/JuliaAcademy/JuliaTutorials/blob/724e15a350d150a9773afe51a3830709dbed422f/introductory-tutorials/intro-to-julia/09.%20Julia%20is%20fast.ipynb) to learn how Julia compares to other languages (C and Python) in terms of performance.
+
+
## Installing Julia
This is a tutorial-like page. Follow these steps before you continue reading the document.
diff --git a/docs/src/notebooks/julia_basics.ipynb b/docs/src/notebooks/julia_basics.ipynb
index fe79f25..8c21976 100644
--- a/docs/src/notebooks/julia_basics.ipynb
+++ b/docs/src/notebooks/julia_basics.ipynb
@@ -1556,15 +1556,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_intro.ipynb b/docs/src/notebooks/julia_intro.ipynb
index 5265aba..4034f11 100644
--- a/docs/src/notebooks/julia_intro.ipynb
+++ b/docs/src/notebooks/julia_intro.ipynb
@@ -1,31 +1,12 @@
{
"cells": [
- {
- "attachments": {},
- "cell_type": "markdown",
- "id": "acfe5cc9",
- "metadata": {},
- "source": [
- "\n",
- "
\n",
- "

\n",
- "
\n",
- "\n"
- ]
- },
{
"cell_type": "markdown",
"id": "ae2a0512",
"metadata": {},
"source": [
- "### Seminars Computational Science\n",
- "### Julia tutorial\n",
"\n",
- "# Why is Julia fast?\n",
- "\n",
- "by Francesc Verdugo (VU Amsterdam)\n",
- "\n",
- "2022-11-24"
+ "# Is Julia fast?"
]
},
{
@@ -35,9 +16,9 @@
"source": [
"## Contents\n",
"\n",
- "We will learn\n",
+ "With this notebook, you will learn\n",
"\n",
- "- Basic julia concepts:\n",
+ "- Two basic julia concepts related performance:\n",
" - type-inference\n",
" - JIT compilation\n",
"- Some Julia syntax\n",
@@ -46,26 +27,50 @@
},
{
"cell_type": "markdown",
- "id": "bc1d9ce2",
+ "id": "beef4d5e",
"metadata": {},
"source": [
- "## Using Jupyter notebooks in Julia"
+ "## Using Jupyter notebooks in Julia\n",
+ "\n",
+ "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.\n",
+ "\n",
+ "\n",
+ "Tip: Did you know that Jupyter stands for Julia, Python and R?\n",
+ "
\n",
+ "\n",
+ "### How to start a Jupyter nootebook in Julia\n",
+ "\n",
+ "To run a Julia Jupyther notebook, open a Julia REPL and type\n",
+ "\n",
+ "```julia\n",
+ "julia> ]\n",
+ "pkg> add IJulia\n",
+ "julia> using IJulia\n",
+ "julia> notebook()\n",
+ "```\n",
+ "A new browser window will open. Navigate to the corresponding notebook and open it.\n",
+ "\n",
+ "\n",
+ "Warning: Make sure that the notebook is using the same Julia version as the one you used to launch `IJulia`. If it is not the same, go to Kernel > Change Kernel and choose the right version.\n",
+ "
\n",
+ "\n",
+ "\n"
]
},
{
"cell_type": "markdown",
- "id": "ff199820",
+ "id": "7cdd5195",
"metadata": {},
"source": [
"### Running a cell\n",
"\n",
- "Click on a cell and press `Shift` + `Enter`"
+ "To run a cell, click on a cell and press `Shift` + `Enter`. You can also use the \"Run\" button in the toolbar above."
]
},
{
"cell_type": "code",
"execution_count": null,
- "id": "a8e4fba2",
+ "id": "ec0f9041",
"metadata": {},
"outputs": [],
"source": [
@@ -75,16 +80,37 @@
},
{
"cell_type": "markdown",
- "id": "0e035ee9",
+ "id": "a8474251",
"metadata": {},
"source": [
- "### Cell order is important"
+ "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."
]
},
{
"cell_type": "code",
"execution_count": null,
- "id": "187db91d",
+ "id": "fb3eaec4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "1+3\n",
+ "4*5;"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0823876a",
+ "metadata": {},
+ "source": [
+ "### Cell order is important\n",
+ "\n",
+ "Running the two cells below in reverse order won't work (try it). "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "bc1da6cb",
"metadata": {},
"outputs": [],
"source": [
@@ -94,7 +120,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "a29023dc",
+ "id": "ddea57d8",
"metadata": {},
"outputs": [],
"source": [
@@ -103,32 +129,44 @@
},
{
"cell_type": "markdown",
- "id": "0b788d3b",
+ "id": "629189d9",
"metadata": {},
"source": [
- "### Package and help modes"
+ "### REPL modes\n",
+ "\n",
+ "This is particular to Julia notebooks. You can use package, help, and shell mode just like in the Julia REPL."
]
},
{
"cell_type": "code",
"execution_count": null,
- "id": "23e1803d",
+ "id": "defa851f",
"metadata": {},
"outputs": [],
"source": [
- "] add BenchmarkTools DataFrames PyCall Conda Test"
+ "] add MPI"
]
},
{
"cell_type": "code",
"execution_count": null,
- "id": "4353e6ec",
+ "id": "1e6fbe66",
"metadata": {},
"outputs": [],
"source": [
"? print"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "123c0f6a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "; ls"
+ ]
+ },
{
"cell_type": "markdown",
"id": "44c03fde",
@@ -137,6 +175,15 @@
"## How fast is Julia code?"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "f1e716db",
+ "metadata": {},
+ "source": [
+ "NB. Most of the examples below are taken from the lecture by S.G. Johnson at MIT. See here:\n",
+ "https://github.com/mitmath/18S096/blob/master/lectures/lecture1/Boxes-and-registers.ipynb"
+ ]
+ },
{
"cell_type": "markdown",
"id": "6c088d9e",
@@ -156,10 +203,7 @@
"id": "34e3c7dd",
"metadata": {},
"source": [
- "### Hand-written sum function\n",
- "\n",
- "### Exercise\n",
- "Write a function that computes the sum of all elements in array `a`. You can view the solution at the bottom of the notebook."
+ "### Hand-written sum function"
]
},
{
@@ -171,9 +215,12 @@
},
"outputs": [],
"source": [
- "# ✍️ Exercise 1\n",
"function sum_hand(a)\n",
- " # TODO\n",
+ " s = zero(eltype(a))\n",
+ " for ai in a\n",
+ " s += ai\n",
+ " end\n",
+ " s\n",
"end"
]
},
@@ -182,8 +229,9 @@
"id": "0494a1b3",
"metadata": {},
"source": [
- "### Test-driven development\n",
- "Next, you can test your solution. You can use the Julia macro `@test` which is provided in the `Test` package."
+ "### Test it\n",
+ "\n",
+ "The Julia macro `@test` which is provided in the `Test` package is useful to write (unit) tests in Julia."
]
},
{
@@ -222,7 +270,8 @@
"metadata": {},
"source": [
"## Benchmarking\n",
- "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`. "
+ "\n",
+ "In Julia, the most straight-forward way of measuring the computation time of a piece of code is with the macro `@time`. "
]
},
{
@@ -245,15 +294,20 @@
"@time sum_hand(a)"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "443ac8da",
+ "metadata": {},
+ "source": [
+ "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."
+ ]
+ },
{
"cell_type": "markdown",
"id": "c664522e",
"metadata": {},
"source": [
- "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. \n",
- "\n",
- "\n",
- "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."
]
},
{
@@ -676,15 +730,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,