More changes in jacobi and MPI notebooks

This commit is contained in:
Francesc Verdugo
2024-09-11 10:45:42 +02:00
parent c35f674bd5
commit bbb749ddc0
3 changed files with 178 additions and 107 deletions

View File

@@ -75,6 +75,7 @@
"- MPI is not a Julia implementation of the MPI standard\n",
"- It is just a wrapper to the C interface of MPI.\n",
"- You need a C MPI installation in your system (MPI.jl downloads one for you when needed).\n",
"- On a cluster (e.g. DAS-5), you want you use the MPI installation already available in the system.\n",
"\n",
"\n",
"### Why MPI.jl?\n",
@@ -211,7 +212,7 @@
"MPI.Finalize()\n",
"```\n",
"\n",
"In some process `rand(1:10)` might be 2 and the program will stop without reaching `MPI.Finalize()` leading to an incorrect program."
"This is incorrect. In some process `rand(1:10)` might be 2 and the program will stop without reaching `MPI.Finalize()` leading to an incorrect program."
]
},
{
@@ -367,7 +368,7 @@
"id": "f1a502a3",
"metadata": {},
"source": [
"Note that this note notebook is running on a single process. So using MPI will only make sense later when we add more processes."
"Note that this note notebook is running on a single process. So using MPI will only make actual sense later when we add more processes."
]
},
{
@@ -626,13 +627,13 @@
"source": [
"## Point-to-point communication\n",
"\n",
"Now we are up and running, and ready to start learning MPI communication primitives. In this notebook we will cover so-called point-to-point communication directives. In a later notebook we will also learn about collective primitives.\n",
"Now we are up and running, and ready to start learning MPI communication primitives. In this notebook we will cover so-called point-to-point communication. In a later notebook we will also learn about collective primitives.\n",
"\n",
"MPI provides point-to-point communication directives for arbitrary communication between processes. Point-to-point communications are two-sided: there is a sender and a receiver. Here, we will discuss different types of directives:\n",
"\n",
"- `MPI_Send`, and `MPI_Recv` (*blocking directives*)\n",
"- `MPI_Isend`, and `MPI_Irecv` (*non-blocking directives*)\n",
"- `MPI_Bsend`, `MPI_Ssend`, and `MPI_Rsend` (*advanced communication modes*)"
"- `MPI_Send`, and `MPI_Recv`: *complete (blocking) directives*\n",
"- `MPI_Isend`, and `MPI_Irecv`: *incomplete (non-blocking) directives*\n",
"- `MPI_Bsend`, `MPI_Ssend`, and `MPI_Rsend`: *advanced communication modes*"
]
},
{
@@ -640,7 +641,7 @@
"id": "0e515109",
"metadata": {},
"source": [
"In all cases, these functions are used to send a message from a ranks and receive it in another rank. See next picture."
"In all cases, these functions are used to send a message from a rank and receive it in another rank. See next picture."
]
},
{
@@ -979,7 +980,7 @@
"\n",
"\n",
"\n",
"`MPI_Send` is also often called a blocking send, but this is very misleading. `MPI_Send` might or not wait for a matching `MPI_Recv`. Assuming that `MPI_Send` will block waiting for a matching receive is erroneous. I.e., we cannot assume that `MPI_Send` has synchronization side effects with the receiver process. However, assuming that `MPI_Send` will not block is also erroneous. Look into the following example (which in fact is an incorrect MPI program). In contrast, `MPI_Send` guarantees that the send buffer can be reused when function returns (complete operation)."
"`MPI_Send` is *informally* called a blocking send, but this is not accurate. `MPI_Send` might or not wait for a matching `MPI_Recv`. Assuming that `MPI_Send` will block waiting for a matching receive is erroneous. I.e., we cannot assume that `MPI_Send` has synchronization side effects with the receiver process. However, assuming that `MPI_Send` will not block is also erroneous. Look into the following example (which in fact is an incorrect MPI program). `MPI_Send` only guarantees that the send buffer can be reused when function returns (complete operation)."
]
},
{
@@ -1042,7 +1043,7 @@
"1. One might want to minimize synchronization time. This is often achieved by copying the outgoing message in an internal buffer and returning from the `MPI_Send` as soon as possible, without waiting for a matching `MPI_Recv`.\n",
"2. One might want to avoid data copies (e.g. for large messages). In this case, one needs to wait for a matching receive and return from the `MPI_Send` when the data has been sent.\n",
"\n",
"Thus, there is a trade-off between memory copied (buffering) and synchronization (wait) time. One cannot minimize both at the same time."
"Thus, there is a trade-off between memory copied (buffering) and synchronization (wait) time. One cannot minimize both at the same time unfortunately."
]
},
{
@@ -1497,7 +1498,7 @@
"function matmul_mpi_3!(C,A,B)\n",
"```\n",
"\n",
"Assume that the input matrices `A` and `B` are given only on rank 0, the other ranks get dummy matrices with zero rows and zero columns to save memory. You need to communicate the required parts to other ranks. For simplicity you can assume that `A` and `B` are square matrices and that the number of rows is a multiple of the number of processes (on rank 0). The result `C` should be overwritten only on rank 0. You can use the following cell to implement and check your result. Copy the code below to a file called `ex1.jl`. Modify the file (e.g. with vscode). Run it from the Julia REPL using the `run` function as explained in the [Getting Started tutorial](https://www.francescverdugo.com/XM_40017/dev/getting_started_with_julia/#Running-MPI-code)."
"Assume that the input matrices `A` and `B` are given only on rank 0, the other ranks get dummy empty matrices to save memory. You need to communicate the required parts to other ranks. For simplicity you can assume that `A` and `B` are square matrices and that the number of rows is a multiple of the number of processes (on rank 0). The result `C` should be overwritten only on rank 0. You can use the following cell to implement and check your result. Copy the code below to a file called `ex1.jl`. Modify the file (e.g. with vscode). Run it from the Julia REPL using the `run` function as explained in the [Getting Started tutorial](https://www.francescverdugo.com/XM_40017/dev/getting_started_with_julia/#Running-MPI-code). Don't try to implement complex MPI code in a Jupyter notebook."
]
},
{