You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/dynamic-receiving-with-mpi-probe-and-mpi-status/index.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,13 +65,11 @@ if (world_rank == 0) {
65
65
As we can see, process zero randomly sends up to `MAX_NUMBERS` integers to process one. Process one then calls `MPI_Recv` for a total of `MAX_NUMBERS` integers. Although process one is passing `MAX_NUMBERS` as the argument to `MPI_Recv`, process one will receive **at most** this amount of numbers. In the code, process one calls `MPI_Get_count` with `MPI_INT` as the datatype to find out how many integers were actually received. Along with printing off the size of the received message, process one also prints off the source and tag of the message by accessing the `MPI_SOURCE` and `MPI_TAG` elements of the status structure.
66
66
67
67
As a clarification, the return value from `MPI_Get_count` is relative to the datatype which is passed. If the user were to use `MPI_CHAR` as the datatype, the returned amount would be four times as large (assuming an integer is four bytes and a char is one byte).
68
-
If you run the check_status program, the output should look similar to this.
68
+
If you run the check_status program from the *tutorials* directory of the [repo]({{ site.github.code }}), the output should look similar to this.
69
69
70
70
```
71
-
>>> make
72
-
mpicc -o check_status check_status.c
73
-
mpicc -o probe probe.c
74
-
>>> ./run.perl check_status
71
+
>>> cd tutorials
72
+
>>> ./run.py check_status
75
73
mpirun -n 2 ./check_status
76
74
0 sent 92 numbers to 1
77
75
1 received 92 numbers from 0. Message source = 0, tag = 0
@@ -92,7 +90,7 @@ MPI_Probe(
92
90
93
91
`MPI_Probe` looks quite similar to `MPI_Recv`. In fact, you can think of `MPI_Probe` as an `MPI_Recv` that does everything but receive the message. Similar to `MPI_Recv`, `MPI_Probe` will block for a message with a matching tag and sender. When the message is available, it will fill the status structure with information. The user can then use `MPI_Recv` to receive the actual message.
94
92
95
-
The <a href="http://www.mpitutorial.com/lessons/mpi_probe_status.tgz">provided code</a> has an example of this in probe.c. Here's what the main source code looks like.
93
+
The [lesson code]({{ site.github.code }}/tutorials/dynamic-receiving-with-mpi-probe-and-mpi-status/code) has an example of this in [probe.c]({{ site.github.code }}/tutorials/dynamic-receiving-with-mpi-probe-and-mpi-status/code/probe.c). Here's what the main source code looks like.
96
94
97
95
```cpp
98
96
int number_amount;
@@ -130,7 +128,7 @@ if (world_rank == 0) {
130
128
Similar to the last example, process zero picks a random amount of numbers to send to process one. What is different in this example is that process one now calls `MPI_Probe` to find out how many elements process zero is trying to send (using `MPI_Get_count`). Process one then allocates a buffer of the proper size and receives the numbers. Running the code will look similar to this.
0 commit comments