Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'clean_events' of github.com:Takishipp/simgrid into clean_events
[simgrid.git] / examples / smpi / mc / only_send_deterministic.c
1 /* ../../../smpi_script/bin/smpirun -hostfile hostfile_send_deterministic -platform ../../platforms/cluster.xml -np 3 --cfg=smpi/send-is-detached-thresh:0 gdb\ --args\ ./send_deterministic */
2
3 /* Copyright (c) 2009-2015. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include <stdio.h>
10 #include <mpi.h>
11 #include <simgrid/modelchecker.h>
12
13 int main(int argc, char **argv)
14 {
15   int recv_buff;
16   int size;
17   int rank;
18   MPI_Status status;
19
20   /* Initialize MPI */
21   int err = MPI_Init(&argc, &argv);
22   if (err != MPI_SUCCESS) {
23     printf("MPI initialization failed!\n");
24     exit(1);
25   }
26
27   MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
28   MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
29   if (size < 2) {
30     printf("run this program with at least 2 processes \n");
31     MPI_Finalize();
32     exit(0);
33   }
34
35   if (rank == 0) {
36     //printf("MPI_ISend / MPI_IRecv Test \n");
37
38     for (int i = 0; i < size - 1; i++) {
39       MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
40       //printf("Message received from %d\n", recv_buff);
41     }
42   }else{
43     MPI_Send(&rank, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
44     //printf("Sent %d to rank 0\n", rank);
45   }
46
47   MPI_Finalize();
48
49   return 0;
50 }