Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
test --cfg=smpi/shared-malloc:local
[simgrid.git] / teshsuite / smpi / pt2pt-dsend / pt2pt-dsend.c
1 /* Copyright (c) 2011-2019. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 /* This program simply does a very small exchange to test whether using SIMIX dsend to model the eager mode works */
8 #include <stdint.h>
9 #include <stdio.h>
10 #include <mpi.h>
11
12 XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
13
14 int main()
15 {
16   int rank;
17   int32_t data=11;
18
19   MPI_Init(NULL, NULL);
20   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
21   MPI_Request r;
22   if (rank==1) {
23     data=22;
24     MPI_Send(&data,1,MPI_INT32_T,(rank+1)%2,666,MPI_COMM_WORLD);
25   } else {
26     MPI_Recv(&data,1,MPI_INT32_T,MPI_ANY_SOURCE,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   if (rank==1) {
33     data=22;
34     MPI_Isend(&data,1,MPI_INT32_T,(rank+1)%2,666,MPI_COMM_WORLD, &r);
35     MPI_Wait(&r, MPI_STATUS_IGNORE);
36   } else {
37     MPI_Irecv(&data,1,MPI_INT32_T,MPI_ANY_SOURCE,666,MPI_COMM_WORLD,&r);
38     MPI_Wait(&r, MPI_STATUS_IGNORE);
39     if (data !=22) {
40       printf("rank %d: Damn, data does not match (got %d)\n",rank, data);
41     }
42   }
43
44   XBT_INFO("rank %d: data exchanged", rank);
45   MPI_Finalize();
46   return 0;
47 }