Skip to content

Commit cffd4aa

Browse files
committed
finished the mpi probe tutorial
1 parent 74b1b38 commit cffd4aa

File tree

2 files changed

+6
-8
lines changed
  • tutorials

2 files changed

+6
-8
lines changed

tutorials/dynamic-receiving-with-mpi-probe-and-mpi-status/index.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ if (world_rank == 0) {
6565
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.
6666

6767
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.
6969

7070
```
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
7573
mpirun -n 2 ./check_status
7674
0 sent 92 numbers to 1
7775
1 received 92 numbers from 0. Message source = 0, tag = 0
@@ -92,7 +90,7 @@ MPI_Probe(
9290
9391
`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.
9492
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.
9694
9795
```cpp
9896
int number_amount;
@@ -130,7 +128,7 @@ if (world_rank == 0) {
130128
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.
131129

132130
```
133-
>>> ./run.perl probe
131+
>>> ./run.py probe
134132
mpirun -n 2 ./probe
135133
0 sent 93 numbers to 1
136134
1 dynamically received 93 numbers from 0

tutorials/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# From mpi-send-and-receive tutorial
1313
'send_recv': ('mpi-send-and-receive', 2),
1414
'ping_pong': ('mpi-send-and-receive', 2),
15-
'ring': ('mpi-send-and-receive', 5)
15+
'ring': ('mpi-send-and-receive', 5),
1616

1717
# From the dynamic-receiving-with-mpi-probe-and-mpi-status tutorial
1818
'check_status': ('dynamic-receiving-with-mpi-probe-and-mpi-status', 2),

0 commit comments

Comments
 (0)