]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make the Timer class work even if we have configured for MPI but haven't initialized...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 28 Sep 2011 02:36:28 +0000 (02:36 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 28 Sep 2011 02:36:28 +0000 (02:36 +0000)
git-svn-id: https://svn.dealii.org/trunk@24453 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/timer.cc

index c10a3792422b90f36141633514f5e9195c7aec87..d366f954dc78e6af85674ce06be859994729f163 100644 (file)
@@ -118,8 +118,7 @@ double Timer::stop ()
       double time = wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec
                              - start_wall_time;
 
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-      if (sync_wall_time)
+      if (sync_wall_time && Utilities::System::job_supports_mpi())
        {
          this->mpi_data
            = Utilities::MPI::min_max_avg (time, mpi_communicator);
@@ -128,9 +127,6 @@ double Timer::stop ()
        }
       else
        cumulative_wall_time += time;
-#else
-      cumulative_wall_time += time;
-#endif
     }
   return cumulative_time;
 }
@@ -150,18 +146,27 @@ double Timer::operator() () const
       const double dtime_children =
        usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec;
 
+      const double running_time = dtime - start_time + dtime_children
+                                 - start_time_children + cumulative_time;
+      
+      if (Utilities::System::job_supports_mpi())
                                   // in case of MPI, need to get the time
                                   // passed by summing the time over all
                                   // processes in the network. works also
                                   // in case we just want to have the time
                                   // of a single thread, since then the
                                   // communicator is MPI_COMM_SELF
-      return Utilities::MPI::sum (dtime - start_time + dtime_children
-                                 - start_time_children + cumulative_time,
-                                 mpi_communicator);
+       return Utilities::MPI::sum (running_time, mpi_communicator);
+      else
+       return running_time;
     }
   else
-    return Utilities::MPI::sum (cumulative_time, mpi_communicator);
+    {
+      if (Utilities::System::job_supports_mpi())
+       return Utilities::MPI::sum (cumulative_time, mpi_communicator);
+      else
+       return cumulative_time;
+    }
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.