From 9b563c984eac64e104e788e54d864ad18cedc7d0 Mon Sep 17 00:00:00 2001 From: Gelieza K Date: Mon, 31 Jul 2023 18:09:28 +0200 Subject: [PATCH] Add answers to MC questions --- docs/src/notebooks/matrix_matrix.ipynb | 221 +++++++++++++++++++++---- 1 file changed, 190 insertions(+), 31 deletions(-) diff --git a/docs/src/notebooks/matrix_matrix.ipynb b/docs/src/notebooks/matrix_matrix.ipynb index 02422c9..bcbfd11 100644 --- a/docs/src/notebooks/matrix_matrix.ipynb +++ b/docs/src/notebooks/matrix_matrix.ipynb @@ -12,20 +12,94 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "b4d5f1a1", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n", + "\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Parsers ─ v2.7.2\n", + "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\gelie\\Home\\TeachingInnovationProject\\XM_40017\\docs\\src\\notebooks\\Project.toml`\n", + " \u001b[90m[6e4b80f9] \u001b[39m\u001b[92m+ BenchmarkTools v1.3.2\u001b[39m\n", + "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\gelie\\Home\\TeachingInnovationProject\\XM_40017\\docs\\src\\notebooks\\Manifest.toml`\n", + " \u001b[90m[6e4b80f9] \u001b[39m\u001b[92m+ BenchmarkTools v1.3.2\u001b[39m\n", + " \u001b[90m[682c06a0] \u001b[39m\u001b[92m+ JSON v0.21.4\u001b[39m\n", + " \u001b[90m[69de0a69] \u001b[39m\u001b[92m+ Parsers v2.7.2\u001b[39m\n", + " \u001b[90m[aea7be01] \u001b[39m\u001b[92m+ PrecompileTools v1.1.2\u001b[39m\n", + " \u001b[90m[21216c6a] \u001b[39m\u001b[92m+ Preferences v1.4.0\u001b[39m\n", + " \u001b[90m[0dad84c5] \u001b[39m\u001b[92m+ ArgTools v1.1.1\u001b[39m\n", + " \u001b[90m[56f22d72] \u001b[39m\u001b[92m+ Artifacts\u001b[39m\n", + " \u001b[90m[2a0f44e3] \u001b[39m\u001b[92m+ Base64\u001b[39m\n", + " \u001b[90m[ade2ca70] \u001b[39m\u001b[92m+ Dates\u001b[39m\n", + " \u001b[90m[f43a241f] \u001b[39m\u001b[92m+ Downloads v1.6.0\u001b[39m\n", + " \u001b[90m[7b1f6079] \u001b[39m\u001b[92m+ FileWatching\u001b[39m\n", + " \u001b[90m[b77e0a4c] \u001b[39m\u001b[92m+ InteractiveUtils\u001b[39m\n", + " \u001b[90m[b27032c2] \u001b[39m\u001b[92m+ LibCURL v0.6.3\u001b[39m\n", + " \u001b[90m[76f85450] \u001b[39m\u001b[92m+ LibGit2\u001b[39m\n", + " \u001b[90m[8f399da3] \u001b[39m\u001b[92m+ Libdl\u001b[39m\n", + " \u001b[90m[37e2e46d] \u001b[39m\u001b[92m+ LinearAlgebra\u001b[39m\n", + " \u001b[90m[56ddb016] \u001b[39m\u001b[92m+ Logging\u001b[39m\n", + " \u001b[90m[d6f4376e] \u001b[39m\u001b[92m+ Markdown\u001b[39m\n", + " \u001b[90m[a63ad114] \u001b[39m\u001b[92m+ Mmap\u001b[39m\n", + " \u001b[90m[ca575930] \u001b[39m\u001b[92m+ NetworkOptions v1.2.0\u001b[39m\n", + " \u001b[90m[44cfe95a] \u001b[39m\u001b[92m+ Pkg v1.9.0\u001b[39m\n", + " \u001b[90m[de0858da] \u001b[39m\u001b[92m+ Printf\u001b[39m\n", + " \u001b[90m[9abbd945] \u001b[39m\u001b[92m+ Profile\u001b[39m\n", + " \u001b[90m[3fa0cd96] \u001b[39m\u001b[92m+ REPL\u001b[39m\n", + " \u001b[90m[9a3f8284] \u001b[39m\u001b[92m+ Random\u001b[39m\n", + " \u001b[90m[ea8e919c] \u001b[39m\u001b[92m+ SHA v0.7.0\u001b[39m\n", + " \u001b[90m[9e88b42a] \u001b[39m\u001b[92m+ Serialization\u001b[39m\n", + " \u001b[90m[6462fe0b] \u001b[39m\u001b[92m+ Sockets\u001b[39m\n", + " \u001b[90m[2f01184e] \u001b[39m\u001b[92m+ SparseArrays\u001b[39m\n", + " \u001b[90m[10745b16] \u001b[39m\u001b[92m+ Statistics v1.9.0\u001b[39m\n", + " \u001b[90m[fa267f1f] \u001b[39m\u001b[92m+ TOML v1.0.3\u001b[39m\n", + " \u001b[90m[a4e569a6] \u001b[39m\u001b[92m+ Tar v1.10.0\u001b[39m\n", + " \u001b[90m[cf7118a7] \u001b[39m\u001b[92m+ UUIDs\u001b[39m\n", + " \u001b[90m[4ec0a83e] \u001b[39m\u001b[92m+ Unicode\u001b[39m\n", + " \u001b[90m[e66e0078] \u001b[39m\u001b[92m+ CompilerSupportLibraries_jll v1.0.2+0\u001b[39m\n", + " \u001b[90m[deac9b47] \u001b[39m\u001b[92m+ LibCURL_jll v7.84.0+0\u001b[39m\n", + " \u001b[90m[29816b5a] \u001b[39m\u001b[92m+ LibSSH2_jll v1.10.2+0\u001b[39m\n", + " \u001b[90m[c8ffd9c3] \u001b[39m\u001b[92m+ MbedTLS_jll v2.28.2+0\u001b[39m\n", + " \u001b[90m[14a3606d] \u001b[39m\u001b[92m+ MozillaCACerts_jll v2022.10.11\u001b[39m\n", + " \u001b[90m[4536629a] \u001b[39m\u001b[92m+ OpenBLAS_jll v0.3.21+4\u001b[39m\n", + " \u001b[90m[bea87d4a] \u001b[39m\u001b[92m+ SuiteSparse_jll v5.10.1+6\u001b[39m\n", + " \u001b[90m[83775a58] \u001b[39m\u001b[92m+ Zlib_jll v1.2.13+0\u001b[39m\n", + " \u001b[90m[8e850b90] \u001b[39m\u001b[92m+ libblastrampoline_jll v5.8.0+0\u001b[39m\n", + " \u001b[90m[8e850ede] \u001b[39m\u001b[92m+ nghttp2_jll v1.48.0+0\u001b[39m\n", + " \u001b[90m[3f19e933] \u001b[39m\u001b[92m+ p7zip_jll v17.4.0+0\u001b[39m\n", + "\u001b[32m\u001b[1mPrecompiling\u001b[22m\u001b[39m project...\n", + "\u001b[33m ✓ \u001b[39m\u001b[90mParsers\u001b[39m\n", + "\u001b[33m ✓ \u001b[39m\u001b[90mJSON\u001b[39m\n", + "\u001b[32m ✓ \u001b[39mBenchmarkTools\n", + " 3 dependencies successfully precompiled in 22 seconds. 8 already precompiled.\n", + " \u001b[33m2\u001b[39m dependencies precompiled but different versions are currently loaded. Restart julia to access the new versions\n" + ] + } + ], "source": [ "] add BenchmarkTools" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "2f8ba040", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "alg_3_complex_check (generic function with 1 method)" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "using Distributed\n", "using BenchmarkTools\n", @@ -41,7 +115,12 @@ " end |> println\n", "end\n", "alg_1_deps_check(answer) = answer_checker(answer,\"b\")\n", - "alg_2_deps_check(answer) = answer_checker(answer,\"d\")" + "alg_1_comm_overhead_check(answer) = answer_checker(answer, \"c\")\n", + "alg_1_comp_check(answer) = answer_checker(answer, \"a\")\n", + "alg_2_complex_check(answer) = answer_checker(answer, \"b\")\n", + "alg_2_deps_check(answer) = answer_checker(answer,\"d\")\n", + "alg_3_deps_check(answer) = answer_checker(answer, \"c\")\n", + "alg_3_complex_check(answer) = answer_checker(answer, \"d\")" ] }, { @@ -316,10 +395,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "a8b7d1e1", "metadata": {}, - "outputs": [], + "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", "alg_1_deps_check(answer)" @@ -497,17 +584,31 @@ "\n", "
\n", "Question: How many scalars are communicated from and to a worker? Assume that matrices A, B, and C are N by N matrices.\n", - "
\n" + "\n", + "\n", + " a) 3N\n", + " b) 2N + 2\n", + " c) 2N + 1\n", + " d) N² + 1" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "e78cbc7b", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It's not correct. Keep trying! 💪\n" + ] + } + ], "source": [ - "# TODO multiple choice" + "answer = \"x\" # replace x with a, b, c, or d \n", + "alg_1_comm_overhead_check(answer)" ] }, { @@ -517,17 +618,30 @@ "source": [ "
\n", "Question: How many operations are done in a worker? \n", - "
" + "\n", + "\n", + " a) O(N)\n", + " b) O(N²)\n", + " c) O(N³)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "fcc9b903", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It's not correct. Keep trying! 💪\n" + ] + } + ], "source": [ - "# TODO multiple choice" + "answer = \"x\" # replace x with a, b, or c\n", + "alg_1_comp_check(answer)" ] }, { @@ -599,12 +713,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "cdb46cd8", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It's not correct. Keep trying! 💪\n" + ] + } + ], "source": [ - "answer = \"x\" \n", + "answer = \"x\" # replace x with a, b, c, or d \n", "alg_2_deps_check(answer)" ] }, @@ -759,12 +881,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "1bf8feff", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🥳 Well done! \n" + ] + } + ], "source": [ - "answer = \"x\"\n", + "answer = \"x\" # replace x with a, b, c, or d \n", "alg_2_complex_check(answer)" ] }, @@ -816,17 +946,32 @@ "source": [ "
\n", "Question: Which are the data dependencies of the computations done by the worker in charge of computing the range of rows C[rows,:] ? \n", - "
\n" + "\n", + "\n", + "\n", + " a) A[rows,:] and B[:,rows] \n", + " b) the whole matrix A and B[:,rows]\n", + " c) A[rows,:] and the whole matrix B\n", + " d) the whole matrices A and B" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "2825385a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It's not correct. Keep trying! 💪\n" + ] + } + ], "source": [ - "# TODO multiple choice and checker" + "answer = \"x\" # replace x with a, b, c, or d \n", + "alg_3_deps_check(answer)" ] }, { @@ -877,17 +1022,31 @@ "\n", "
\n", "Question: Which is the complexity of the communication and computations done by a worker in algorithm 3?\n", - "
" + "\n", + "\n", + " a) O(N²) communication and O(N³) computation\n", + " b) O(N²) communication and O(N³/P) computation\n", + " c) O(N²) communication and O(N²) computation\n", + " d) O(N²/P) communication and O(N³/P) computation" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "id": "50b8bf53", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It's not correct. Keep trying! 💪\n" + ] + } + ], "source": [ - "# TODO multiple choice and checker function" + "answer = \"x\" # replace x with a, b, c, or d \n", + "alg_3_complex_check(answer)" ] }, { @@ -1137,7 +1296,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.9.0", + "display_name": "Julia 1.9.1", "language": "julia", "name": "julia-1.9" }, @@ -1145,7 +1304,7 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.9.0" + "version": "1.9.1" } }, "nbformat": 4,