Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix win installer
[simgrid.git] / teshsuite / smpi / compute3.c
1 /* Copyright (c) 2009-2012. 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 /* This example should be instructive to learn about SMPI_SAMPLE_LOCAL and 
8    SMPI_SAMPLE_GLOBAL macros for execution sampling */
9
10 #include <stdio.h>
11 #include <mpi.h>
12
13 int main(int argc, char *argv[])
14 {
15   int i,j;
16   double d;
17   MPI_Init(&argc, &argv);
18   d = 2.0;
19   for (i=0;i<5;i++) {   
20      SMPI_SAMPLE_GLOBAL(3,-1)  { // I want no more than 3 benchs (thres<0)
21         fprintf(stderr,"[rank:%d] Run the first computation. It's globally benched, and I want no more than 3 benchmarks (thres<0)\n", smpi_process_index());
22     
23         for (j=0;j<100*1000*1000;j++) { // 100 kflop
24            if (d < 100000) {
25               d = d * d;
26            } else {
27               d = 2;
28            }
29         }     
30      }
31   }
32
33   for (i=0;i<5;i++) {   
34      SMPI_SAMPLE_LOCAL(0, 0.1) { // I want the standard error to go below 0.1 second. Two tests at least will be run (count is not >0)
35         fprintf(stderr,"[rank:%d] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0)\n", smpi_process_index());
36         for (j=0;j<100*1000*1000;j++) { // 100 kflop
37            if (d < 100000) {
38               d = d * d;
39            } else {
40               d = 2;
41            }
42         }
43      }
44   }
45    
46   fprintf(stderr,"[%d] The result of the computation is: %f\n", smpi_process_index(), d);
47
48   MPI_Finalize();
49   return 0;
50 }