Some improvements in the first notebooks

This commit is contained in:
Francesc Verdugo
2024-08-19 15:58:09 +02:00
parent 047d6feadb
commit 5abdc088d2
5 changed files with 307 additions and 203 deletions

View File

@@ -60,7 +60,32 @@
" end |> println\n",
"end\n",
"q_1_check(answer) = answer_checker(answer,\"a\")\n",
"q_2_check(answer) = answer_checker(answer,\"b\")"
"q_2_check(answer) = answer_checker(answer,\"b\")\n",
"function why_q1()\n",
" msg = \"\"\"\n",
" We send the matrix (16 entries) and then we receive back the result (1 extra integer). Thus, the total number of transferred integers in 17.\n",
" \"\"\"\n",
" display(msg)\n",
"end\n",
"function why_q2()\n",
" msg = \"\"\"\n",
" Even though we only use a single entry of the matrix in the remote worker, the entire matrix is captured and sent to the worker. Thus, we will transfer 17 integers like in Question 1.\n",
" \"\"\"\n",
" display(msg)\n",
"end\n",
"function why_q3()\n",
" msg = \"\"\"\n",
" The value of x will still be zero since the worker receives a copy of the matrix and it modifies this copy, not the original one.\n",
" \"\"\"\n",
" display(msg)\n",
"end\n",
"function why_q4()\n",
" msg = \"\"\"\n",
" In this case, the code a[2]=2 is executed in the main process. Since the matrix is already in the main process, it is not needed to create and send a copy of it. Thus, the code modifies the original matrix and the value of x will be 2.\n",
" \"\"\"\n",
" display(msg)\n",
"end\n",
"println(\"🥳 Well done! \")"
]
},
{
@@ -791,7 +816,7 @@
"source": [
"\n",
"<div class=\"alert alert-block alert-success\">\n",
"<b>Question:</b> How many integers are transferred between master and worker? Including both directions. \n",
"<b>Question (NB3-Q1):</b> How many integers are transferred between master and worker? Including both directions. \n",
"</div>\n",
"\n",
"\n",
@@ -819,13 +844,23 @@
"q_1_check(answer)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c4d4900",
"metadata": {},
"outputs": [],
"source": [
"why_q1()"
]
},
{
"cell_type": "markdown",
"id": "dbe373d1",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-success\">\n",
"<b>Question:</b> How many integers are transferred between master and worker? Including both directions. \n",
"<b>Question (NB3-Q2):</b> How many integers are transferred between master and worker? Including both directions. \n",
"</div>\n",
"\n",
"\n",
@@ -853,6 +888,16 @@
"q_2_check(answer)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e7c25fc4",
"metadata": {},
"outputs": [],
"source": [
"why_q2()"
]
},
{
"cell_type": "markdown",
"id": "c561a73d",
@@ -860,7 +905,7 @@
"source": [
"\n",
"<div class=\"alert alert-block alert-success\">\n",
"<b>Question:</b> Which value will be the value of `x` ? \n",
"<b>Question (NB3-Q3):</b> Which value will be the value of `x` ? \n",
"</div>\n"
]
},
@@ -878,13 +923,23 @@
"x"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7b25a83f",
"metadata": {},
"outputs": [],
"source": [
"why_q3()"
]
},
{
"cell_type": "markdown",
"id": "835080aa",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-success\">\n",
"<b>Question:</b> Which value will be the value of `x` ? \n",
"<b>Question (NB3-Q4):</b> Which value will be the value of `x` ? \n",
"</div>\n",
"\n",
"Which value will be the value of `x` ?"
@@ -904,6 +959,16 @@
"x"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "96b84cb5",
"metadata": {},
"outputs": [],
"source": [
"why_q4()"
]
},
{
"cell_type": "markdown",
"id": "9e985c61",