{
"cells": [
{
"cell_type": "markdown",
"id": "287c5272",
"metadata": {},
"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\")"
]
},
{
"cell_type": "markdown",
"id": "2133c064",
"metadata": {},
"source": [
"# Distributed computing in Julia\n",
"\n",
"by Francesc Verdugo (VU Amsterdam)\n",
"\n",
"Version fall 2022"
]
},
{
"cell_type": "markdown",
"id": "a7b64d5a",
"metadata": {},
"source": [
"## Contents\n",
"\n",
"In this notebook, we will learn the basics of distributed computing in Julia. In particular, we will focus on the Distributed module available in the Julia standard library. The main topics we are going to cover are:\n",
"\n",
"- How to create Julia processes\n",
"- How to execute code remotely\n",
"- How to send and receive data\n",
"\n",
"With this knowledge you will be able to implement simple and complex parallel algorithms in Julia."
]
},
{
"cell_type": "markdown",
"id": "01af032c",
"metadata": {},
"source": [
"## How to create Julia processes\n",
"\n",
"First of all, we need several processes in order to run parallel algorithms *in parallel*. In this section, we discuss different ways to create new processes in Julia."
]
},
{
"cell_type": "markdown",
"id": "036a25d7",
"metadata": {},
"source": [
"### Adding processes locally\n",
"\n",
" The simplest way of creating processes for parallel computing is to add them locally in the current Julia session. This is done by using the following commands.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6fed889",
"metadata": {},
"outputs": [],
"source": [
"using Distributed"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d16faba9",
"metadata": {},
"outputs": [],
"source": [
"addprocs(3)"
]
},
{
"cell_type": "markdown",
"id": "f07ac76c",
"metadata": {},
"source": [
"Last cell created 3 new Julia processes. By default, they run locally in the same computer as the current Julia session, using multiple cores if possible. However, it is also possible to start the new processes in other machines as long as they are interconnected (more details on this later).\n",
"\n",
"\n",
"