main
test-branch
| Line | |
|---|
| 1 | /* This program illustrates assertion checking related
|
|---|
| 2 | * to message data.
|
|---|
| 3 | */
|
|---|
| 4 | #include <stdio.h>
|
|---|
| 5 | #include <mpi.h>
|
|---|
| 6 | #include <assert.h>
|
|---|
| 7 |
|
|---|
| 8 | int main( int argc, char **argv) {
|
|---|
| 9 | int rank, nprocs;
|
|---|
| 10 |
|
|---|
| 11 | MPI_Init(&argc, &argv);
|
|---|
| 12 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 13 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
|---|
| 14 | if (rank == 0) {
|
|---|
| 15 | MPI_Status status;
|
|---|
| 16 |
|
|---|
| 17 | for (int i = 1; i < nprocs; i++)
|
|---|
| 18 | MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD,
|
|---|
| 19 | &status);
|
|---|
| 20 | assert(status.MPI_SOURCE == 1);
|
|---|
| 21 | }
|
|---|
| 22 | else
|
|---|
| 23 | MPI_Send(NULL, 0, MPI_INT, 0, 0, MPI_COMM_WORLD);
|
|---|
| 24 |
|
|---|
| 25 | MPI_Finalize();
|
|---|
| 26 | return 0;
|
|---|
| 27 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.