Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move surf testsuite to teshsuite
[simgrid.git] / teshsuite / smpi / compute2.c
1 /* Copyright (c) 2009-2010, 2012-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 #include <stdio.h>
8 #include <mpi.h>
9
10 int main(int argc, char *argv[])
11 {
12   int i, n;
13   double d;
14   MPI_Init(&argc, &argv);
15   n = argc > 1 ? atoi(argv[1]) : 0;
16   d = 2.0;
17   /* Run it only once across the whole set of processes */
18   SMPI_SAMPLE_GLOBAL(1, -1) {
19     for (i = 0; i < n; i++) {
20       if (d < 10000) {
21         d = d * d;
22       } else {
23         d = 2;
24       }
25     }
26     printf("%d %f\n", i, d);
27   }
28   MPI_Finalize();
29   return 0;
30 }