diff --git a/Day_4/Day_4.jl b/Day_4/Day_4.jl index cf2ad3e..f75a5e0 100644 --- a/Day_4/Day_4.jl +++ b/Day_4/Day_4.jl @@ -44,7 +44,7 @@ Now, run the following: add IJulia -After the installation is done, you can verify that the package is installed by running the following (still in the packagae manager prompt): +After the installation is done, you can verify that the package is installed by running the following (still in the package manager prompt): status @@ -52,7 +52,7 @@ Then you should see `IJulia` listed. Now, you can exit Julia. You have now the Julia kernel for Jupyter. -If you don't already have JupyterLab (recommended) or Jupyter isntalled, install JupyterLab. +If you don't already have JupyterLab (recommended) or Jupyter installed, install JupyterLab. Launch JupyterLab or Jupyter. You should see the Julia kernel listed now! 🎉 """ @@ -64,7 +64,7 @@ If you are working on a big project, then splitting code up into different files Because you should avoid using global variables in Julia and instead only call functions, you will not achieve the maximum performance using a notebook because of its workflow that does not support working only with functions. See the section about performance in this notebook. -Julia has a very good integration in VS Code. VS Codium is the free open source version of VS Code without proprietary code and telemetary. Both will do the job. Just start one of them after installation, go the extensions tab on the sidebar, type in Julia and install the Julia extension. +Julia has a very good integration in VS Code. VS Codium is the free open source version of VS Code without proprietary code and telemetry. Both will do the job. Just start one of them after installation, go the extensions tab on the sidebar, type in Julia and install the Julia extension. Now, you can edit Julia files with autocomplition, real-time feedback, formatting (you might need to set up formatting on save) and other features that you can find about in the documentation of the extension: @@ -138,7 +138,7 @@ The REPL does support tab autocompletion. Just press tab one time to autocomplet It REPL also supports history. If you press arrow up or down, you can navigate the execution history. You can also press `CTRL+R` to see the a list of all last commands. You can search in this history and then press enter. -If you want syntax highlighting in your REPL, add the package `OhMyREPL` to your **global** environment and let this package be imported always on startup as descriped in the documentation: +If you want syntax highlighting in your REPL, add the package `OhMyREPL` to your **global** environment and let this package be imported always on startup as described in the documentation: https://kristofferc.github.io/OhMyREPL.jl/latest/installation/ """ @@ -183,7 +183,7 @@ You can use run Julia code on the GPU, on multiple CPU threads (multithreading) In this course, only multithreading will be presented. -The easiest way to use multithreading in Julia is by letting a `for` loop run on multiple threads. This can be achieved by only addy the macro `@threads` before the `for` loop. +The easiest way to use multithreading in Julia is by letting a `for` loop run on multiple threads. This can be achieved by only adding the macro `@threads` before the `for` loop. Before trying to use multithreading, make sure that you launch Julia with multiple threads. To do so, run the following to launch Julia: @@ -191,7 +191,7 @@ Before trying to use multithreading, make sure that you launch Julia with multip You can append `--project=.` and other arguments to it. -`-t` is an alias to `--threads`. `auto` automatically determins how many threads your PC supports. You can also replace `auto` by the number of threads that you want to use. This number can not be bigger than the number of threads that your computer supports. +`-t` is an alias to `--threads`. `auto` automatically determines how many threads your PC supports. You can also replace `auto` by the number of threads that you want to use. This number can not be bigger than the number of threads that your computer supports. """ # ╔═╡ 2cf5f891-8d8f-477d-8ef1-9b4b9480d477 @@ -223,7 +223,7 @@ end @btime multithreaded_for_loop(N) # ╔═╡ 3fcdf8ff-224c-4616-acd6-d8062f3a7af0 -# Demonstration of shuffeling +# Demonstration of shuffling shuffle(1:10) # ╔═╡ f141dbb4-bdc5-4f16-8d97-fc0a3d5981f2 @@ -341,7 +341,7 @@ end typemax(Int64) # ╔═╡ ebd3a9d9-7a12-4001-9b53-913f664fb1c8 -# Lets try shuffeling again +# Lets try shuffling again function shuffle_safe_thread_sum(N) sums = zeros(Int64, N) @@ -353,22 +353,23 @@ function shuffle_safe_thread_sum(N) end # ╔═╡ ddd2409e-de34-4eb9-a0b7-e10cc6c0ce9f -# This is worse than the version without shuffeling. +# This is worse than the version without shuffling. # In this case, shuffling is too expensive compared with its benefit # Especially for multithreading, there is no silver bullet. # Always benchmark! This is the only method to make sure that an "optimization" indeed an optimization is @btime shuffle_safe_thread_sum(N2) # ╔═╡ 24ad64f9-b0a4-48ac-b6dc-06a5d1c7b072 -function shuffeling_cost(N) +# Function to determine the shuffling cost +function shuffling_cost(N) shuffle(1:N) return end # ╔═╡ fe0b18c0-cbf0-421d-b6a0-987321a0b09d -# The shuffeling itself is too expensive compared to the calculation in the loop -@btime shuffeling_cost(N2) +# The shuffling itself is too expensive compared to the calculation in the loop +@btime shuffling_cost(N2) # ╔═╡ 09f71a9e-6798-492f-98df-45087d0c4c8b md"""