Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use binary dir for bindir, and cd to home dir.
[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 XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
12
13 int main(int argc, char *argv[]) {
14   int rank;
15   int data=11;
16    
17
18   MPI_Init(&argc, &argv);
19   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
20    
21   if (rank==1) {
22     data=22;
23     MPI_Send(&data,1,MPI_INT,(rank+1)%2,666,MPI_COMM_WORLD);
24 //   smpi_sleep(1000);
25   } else {
26     MPI_Recv(&data,1,MPI_INT,-1,666,MPI_COMM_WORLD,NULL);
27     if (data !=22) {
28       printf("rank %d: Damn, data does not match (got %d)\n",rank, data);
29     }
30   }
31
32   XBT_INFO("rank %d: data exchanged", rank);
33   MPI_Finalize();
34   return 0;
35 }