This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11 #include <stdio.h>
12 #include "mpi.h"
13
14 int main( int argc, char *argv[] )
15 {
16 int rank, size;
17 int send_value[10],recv_value[10];
18 int i;
19 MPI_Status status;
20 MPI_Request send_request;
21 MPI_Request recv_request;
22
23 MPI_Init( &argc, &argv );
24
25 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
26 MPI_Comm_size( MPI_COMM_WORLD, &size );
27
28 for(i=0; i < 10; i++) {
29 send_value[i] = i;
30 printf("\n%d:%d",i,send_value[i]);
31 }
32
33
34
35
36
37 recv_value[9] = 100;
38
39 if (size != 2) {
40 fprintf (stderr, "Error: Need 2 processes\n");
41 MPI_Finalize ();
42 }
43
44
45
46
47
48
49 MPI_Isend (&send_value, 9, MPI_INT,
50 (rank + 1) % size, 4711, MPI_COMM_WORLD, &send_request);
51 MPI_Irecv (&recv_value, 10, MPI_INT,
52 (rank + size - 1) % size, 4711, MPI_COMM_WORLD, &recv_request);
53
54 MPI_Wait (&send_request, &status);
55 MPI_Wait (&recv_request, &status);
56
57
58
59
60 printf("\nError in strict mode: buf[9]:%d", recv_value[9]);
61
62 MPI_Finalize ();
63 return 0;
64 }
65