title: MPI global execution time
body: <p>I'm working on a little application that multiples an array with a Matrix. It works without any problem. I'm loking for measure the execution time of the application. I can find the individual time of execution of each processes (its starting and ending) but I need the global time.</p>
  
  <p>This is my code:</p>
  
  <pre><code>int main(int argc, char **argv){
      int rang, procesus;
      MPI_Status statut;
      double start, end, max_end = 0, min_start = 10000;
  
      MPI_Init(&amp;argc, &amp;argv);
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;rang);
      MPI_Comm_size(MPI_COMM_WORLD, &amp;procesus);
      MPI_Barrier(MPI_COMM_WORLD);
  
      start = MPI_Wtime();
      printf("Starting time of process n. %d %f\n",rang, start);
      if(rang==0){
          //Master work
      }else{
          //slaves work
      }
      MPI_Barrier(MPI_COMM_WORLD);
      end = MPI_Wtime();
      printf("Ending time of process n.%d %f\n\n\n",rang, end);
  
      MPI_Finalize();
  //Out of the Parallelized task
  
      if(min_start &gt; start){
          min_start = start;
          printf("New minumum starting time %f\n", min_start);
      }
  
      if(max_end &lt; end){
          max_end = end;
          printf("New maximum ending time %f\n", max_end);
      }
  
      if(rang == 0){
          printf("Start %f\n", min_start);
          printf("End %f\n", max_end);
      }
      return 0;
  }
  </code></pre>
  
  <p>I use the varables min_start and max_end as "global" variables to try to catch the max and min temps of all the processes, but I always get the starting and ending tme of the last process to execute, the ending time is ok, but the starting time is wrong cause the last process was ot the first to start. What am I doing wrong? Can I use a really global variable in MPI for all the processes, and if I can how?</p>
  
  <p>That's what I have as output</p>
  
  <pre><code>Starting time of process n.2. 0.101562
  Ending time of process n.2. 0.105469
  New minumum starting time 0.101562
  New maximum ending time 0.105469
  
  Starting time of process n.3. 0.058594
  Ending time of process n.3. 0.062500
  New minumum starting time 0.058594
  New maximum ending time 0.062500
  
  Starting time of process n. 4. 0.007812
  Ending time of process n. 4. 0.011719
  New minumum starting time 0.007812
  New maximum ending time 0.011719
  
  Starting time of process n.1. 0.148438
  Ending time of process n.1. 0.152344
  New minumum starting time 0.148438
  New maximum ending time 0.152344
  
  Starting time of process n.0. 0.207031 
  Ending time of process n.0. 0.210938
  New minumum starting time 0.207031
  New maximum ending time 0.210938
  
  Start 0.207031
  End 0.210938
  </code></pre>