mirror of
https://github.com/fverdugo/XM_40017.git
synced 2025-11-08 22:24:25 +01:00
Add questions to TSP and PDEs notebooks
This commit is contained in:
parent
685d3db6a5
commit
b628e017c1
@ -206,7 +206,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "992301dd",
|
||||
"id": "fbb3d1eb",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"You can verify that the algorithm computes the upper triangular matrix correctly for the example in the introduction by running the following code cell. "
|
||||
@ -492,6 +492,26 @@
|
||||
"b = ones(n)\n",
|
||||
"gaussian_elimination!(C)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f60d9ea0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# License\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"This notebook is part of the course [Programming Large Scale Parallel Systems](https://www.francescverdugo.com/XM_40017) at Vrije Universiteit Amsterdam and may be used under a [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) license."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "8ab22f67",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
@ -422,7 +422,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 1,
|
||||
"id": "a66cbf9a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@ -433,10 +433,24 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 2,
|
||||
"id": "e0d63c6b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"3-element Vector{Int64}:\n",
|
||||
" 2\n",
|
||||
" 3\n",
|
||||
" 4"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"if procs() == workers()\n",
|
||||
" nw = 3\n",
|
||||
@ -455,7 +469,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 9,
|
||||
"id": "d39c7bb2",
|
||||
"metadata": {
|
||||
"code_folding": []
|
||||
@ -516,7 +530,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 7,
|
||||
"id": "f1a8db8f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@ -546,12 +560,23 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 8,
|
||||
"id": "68851107",
|
||||
"metadata": {
|
||||
"code_folding": []
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" From worker 2:\t(rank, u) = (0, [-1.0, -0.75390625, -0.548828125, -0.3427734375, -0.224609375, -0.06640625])\n",
|
||||
" From worker 3:\t(rank, u) = (1, [-0.1796875, -0.09765625, -0.0439453125, 0.0439453125, 0.09765625, 0.1796875])\n",
|
||||
" From worker 4:\t(rank, u) = (2, [0.06640625, 0.224609375, 0.3427734375, 0.548828125, 0.75390625, 1.0])\n",
|
||||
" From worker 2:\tresults ≈ jacobi(n, niters) = true\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"@everywhere workers() begin\n",
|
||||
" # Call jacobi in parallel\n",
|
||||
@ -614,10 +639,10 @@
|
||||
"<b>Question:</b> At the end of function jacobi_mpi ...\n",
|
||||
"</div>\n",
|
||||
"\n",
|
||||
" a) each rank holds the complete solution.\n",
|
||||
" b) only the root process holds the solution. \n",
|
||||
" c) the values of the ghost cells of u are not consistent with the neighbors\n",
|
||||
" d) the ghost cells of u contain the initial values -1 and 1 in all ranks"
|
||||
" a) each process holds the complete solution.\n",
|
||||
" b) the complete solution is gathered in the root process. \n",
|
||||
" c) each process contains the solution for the local partition. \n",
|
||||
" d) the ghost cells of u contain the initial values -1 and 1 in all processes."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
4398
notebooks/pdes.ipynb
4398
notebooks/pdes.ipynb
File diff suppressed because one or more lines are too long
@ -38,10 +38,21 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 1,
|
||||
"id": "7e93809a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"tsp_check_4 (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"using Printf\n",
|
||||
"function answer_checker(answer,solution)\n",
|
||||
@ -53,7 +64,8 @@
|
||||
"end\n",
|
||||
"tsp_check_1(answer) = answer_checker(answer, 16)\n",
|
||||
"tsp_check_2(answer) = answer_checker(answer, 2)\n",
|
||||
"tsp_check_3(answer) = answer_checker(answer, \"d\")"
|
||||
"tsp_check_3(answer) = answer_checker(answer, \"d\")\n",
|
||||
"tsp_check_4(answer) = answer_checker(answer, \"a\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -810,6 +822,40 @@
|
||||
"This avoids the performance issues of the previous approach: the workers are not idle since they get new work every time they finish a job. To avoid the search overhead, it is also important that the workers communicate the minimum distance each time they update their local minimum distance. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "81219a27",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"alert alert-block alert-success\">\n",
|
||||
" <b>Question:</b> To find the right <i> maxhops </i> level is a tradeoff between...\n",
|
||||
"</div>\n",
|
||||
" \n",
|
||||
" a) Communication overhead (large maxhops) and load imbalance (small maxhops). \n",
|
||||
" b) Search overhead (large maxhops) and load imbalance (small maxhops). \n",
|
||||
" c) the number of workers (large maxhops) and the job size (small maxhops). \n",
|
||||
" d) buffer for the job queue (large maxhops) and idle time of the coordinator process (small maxhops)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "0cf1ec88",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"It's not correct. Keep trying! 💪\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"answer=\"x\" #Replace x with a,b,c, or d\n",
|
||||
"tsp_check_4(answer)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5e4fdbe1",
|
||||
@ -1157,12 +1203,16 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "edbea7ac",
|
||||
"cell_type": "markdown",
|
||||
"id": "c789dc7a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
"source": [
|
||||
"# License\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"This notebook is part of the course [Programming Large Scale Parallel Systems](https://www.francescverdugo.com/XM_40017) at Vrije Universiteit Amsterdam and may be used under a [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) license."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user