Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
469066b74741ced2ce10b03b27f219c1d23198ae
[simgrid.git] / teshsuite / bug-17132 / bug-17132.c
1 /* Copyright (c) 2014. 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 /* Bug report: https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 */
8  
9 #include "xbt/log.h"
10 #include <stdio.h>
11 #include <mpi.h>
12
13 XBT_LOG_NEW_DEFAULT_CATEGORY(MM_mpi, "Messages for this SMPI test");
14
15 int main(int argc, char ** argv)
16 {
17   size_t err;
18   size_t M = 8*1024;
19   size_t N = 32*1024;
20
21   MPI_Init(&argc, &argv);
22
23   int rank;
24   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
25
26   double *a = malloc(sizeof(double) * M);
27   double *b = malloc(sizeof(double) * N);
28
29   // A broadcast
30   err = MPI_Bcast(a, M, MPI_DOUBLE, 0, MPI_COMM_WORLD);
31   if (err != MPI_SUCCESS) {
32     perror("Error Bcast A\n"); MPI_Finalize(); exit(-1);
33   }
34
35 //  Uncommenting this barrier fixes it!
36 //  MPI_Barrier(MPI_COMM_WORLD);
37
38   // Another broadcast
39   err = MPI_Bcast(b, N, MPI_DOUBLE, 0, MPI_COMM_WORLD );
40   if (err != MPI_SUCCESS) {
41     perror("Error Bcast B\n"); MPI_Finalize(); exit(-1);
42   }
43
44   // Commenting out this barrier fixes it!!
45   MPI_Barrier(MPI_COMM_WORLD);
46
47   if(rank==0) {
48     printf("Walltime = %g\n",MPI_Wtime());
49   }
50
51   MPI_Finalize();
52   free(a);
53   free(b);
54   return 0;
55 }