Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / examples / smpi / compute3.c
1 /* Copyright (c) 2009, 2010. 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 #include <stdio.h>
8 #include <mpi.h>
9
10 int main(int argc, char *argv[])
11 {
12   int i;
13   double d;
14   MPI_Init(&argc, &argv);
15   d = 2.0;
16 /*  SMPI_DO_ONCE */  {
17     for (i = 0; i < atoi(argv[1]); i++) {
18       if (d < 10000) {
19         d = d * d;
20       } else {
21         d = 2;
22       }
23     }
24     printf("%d %f\n", i, d);
25   }
26 /*  SMPI_DO_ONCE */  {
27     for (i = 0; i < 2 * atoi(argv[1]); i++) {
28       if (d < 10000) {
29         d = d * d;
30       } else {
31         d = 2;
32       }
33     }
34     printf("%d %f\n", i, d);
35   }
36   MPI_Finalize();
37   return 0;
38 }