main
test-branch
| Rev | Line | |
|---|
| [1975893] | 1 | /* Coverage test example: This example is only used for software
|
|---|
| 2 | testing coverage, it may not be understandable for human beings. */
|
|---|
| 3 | #include <mpi.h>
|
|---|
| 4 | #include <stdio.h>
|
|---|
| 5 | #include <civl-mpi.cvh>
|
|---|
| 6 |
|
|---|
| 7 | $input int in;
|
|---|
| 8 | int size, rank, x;
|
|---|
| 9 | int root = 0;
|
|---|
| 10 |
|
|---|
| 11 | void recv(int iter) {
|
|---|
| 12 | for(int i = 1; i < size; i++)
|
|---|
| 13 | MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|---|
| 14 | $mpi_coassert(MPI_COMM_WORLD, root == in);
|
|---|
| 15 | printf("rank:%d in=%d\n", rank, in);
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | void send(int msg) {
|
|---|
| 19 | MPI_Send(&msg, 1, MPI_INT, root, 0, MPI_COMM_WORLD);
|
|---|
| 20 | printf("Proc:%d sends %d\n", rank, msg);
|
|---|
| 21 | $mpi_coassert(MPI_COMM_WORLD, $true);
|
|---|
| 22 | printf("rank:%d in=%d\n", rank, in);
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | int main(int argc, char * argv[]) {
|
|---|
| 26 | MPI_Init(&argc, &argv);
|
|---|
| 27 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 28 | MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|---|
| 29 | for(int i = 0; i < 2; i++)
|
|---|
| 30 | if(!rank)
|
|---|
| 31 | recv(i);
|
|---|
| 32 | else
|
|---|
| 33 | send(i);
|
|---|
| 34 | MPI_Finalize();
|
|---|
| 35 | return 0;
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.