Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
511cf32a04e86a2e4ba1d7854b43580b52e02999
[simgrid.git] / examples / smpi / dsend.c
1 /* Copyright (c) 2011. The SimGrid Team. All rights reserved.               */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 /* This program simply does a very small exchange to test whether using SIMIX dsend to model the eager mode works */
7
8 #include <stdio.h>
9 #include <mpi.h>
10
11 int main(int argc, char *argv[]) {
12   int rank;
13   int data=11;
14    
15   MPI_Init(&argc, &argv);
16   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
17    
18   if (rank==1) {
19           data=22;
20           MPI_Send(&data,1,MPI_INT,(rank+1)%2,666,MPI_COMM_WORLD);
21   } else {
22           MPI_Recv(&data,1,MPI_INT,-1,666,MPI_COMM_WORLD,NULL);
23           if (data !=22) {
24                   printf("rank %d: Damn, data does not match (got %d)\n",rank, data);
25           }
26   }
27         
28   printf("rank %d: data exchanged\n", rank);
29   MPI_Finalize();
30   return 0;
31 }