Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill all trailling whitespaces
[simgrid.git] / teshsuite / smpi / 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 M = 8*1024;
18   size_t N = 32*1024;
19
20   MPI_Init(&argc, &argv);
21
22   int rank;
23   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
24
25   double *a = malloc(sizeof(double) * M);
26   double *b = malloc(sizeof(double) * N);
27
28   // A broadcast
29   size_t err = MPI_Bcast(a, M, MPI_DOUBLE, 0, MPI_COMM_WORLD);
30   if (err != MPI_SUCCESS) {
31     perror("Error Bcast A\n");
32     MPI_Finalize();
33     exit(-1);
34   }
35
36 //  Uncommenting this barrier fixes it!
37 //  MPI_Barrier(MPI_COMM_WORLD);
38
39   // Another broadcast
40   err = MPI_Bcast(b, N, MPI_DOUBLE, 0, MPI_COMM_WORLD );
41   if (err != MPI_SUCCESS) {
42     perror("Error Bcast B\n");
43     MPI_Finalize();
44     exit(-1);
45   }
46
47   // Commenting out this barrier fixes it!!
48   MPI_Barrier(MPI_COMM_WORLD);
49
50   if(rank==0) {
51     printf("Walltime = %g\n",MPI_Wtime());
52   }
53
54   MPI_Finalize();
55   free(a);
56   free(b);
57   return 0;
58 }