]> https://gitweb.dealii.org/ - dealii.git/commit
Fix some #ifdef logic in the Timer class. 4868/head
authorDavid Wells <wellsd2@rpi.edu>
Wed, 16 Aug 2017 02:18:12 +0000 (22:18 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Wed, 16 Aug 2017 02:48:22 +0000 (22:48 -0400)
commitc0a95eeb70223a5f24c88c49e88c8c12b7d5dfb9
treeb2468f6c4738402fb4d27d7209618715dfe27148
parent5544aa88375a36d4d0b042d1ac115f1e532babb3
Fix some #ifdef logic in the Timer class.

This fixes a bug due to rewritting an else statement where the 'else' was in an
'ifdef' and the body of the else statement (one line) was outside of it. This
caused, after a rewrite, the body of the former else statement to be executed
twice.

Before 9ef67983fd the end of this function was:

#ifdef DEAL_II_WITH_MPI
      if (sync_wall_time && Utilities::MPI::job_supports_mpi())
        {
          this->mpi_data
            = Utilities::MPI::min_max_avg (last_lap_time, mpi_communicator);
          last_lap_time = this->mpi_data.max;
          cumulative_wall_time += last_lap_time;
        }
      else
#endif
        cumulative_wall_time += last_lap_time;
    }
  return cumulative_time;

where the 'else' statement was run unconditionally if MPI was not present. The
previous (prior to this patch) version was:

#ifdef DEAL_II_WITH_MPI
      this->mpi_data = Utilities::MPI::min_max_avg (last_lap_time,
                                                    mpi_communicator);
      if (sync_wall_time && Utilities::MPI::job_supports_mpi())
        {
          last_lap_time = this->mpi_data.max;
          last_lap_cpu_time = Utilities::MPI::min_max_avg (last_lap_cpu_time,
                                                           mpi_communicator).max;
        }
      cumulative_wall_time += last_lap_time;
      cumulative_time += last_lap_cpu_time;
      this->mpi_total_data = Utilities::MPI::min_max_avg (cumulative_wall_time,
                                                          mpi_communicator);
#endif
      cumulative_wall_time += last_lap_time;
      cumulative_time += last_lap_cpu_time;
    }
  return cumulative_time;

which will, if MPI is available, double count both the cumulative wall time and
cummulative time.
source/base/timer.cc
tests/base/timer_06.cc [new file with mode: 0644]
tests/base/timer_06.output [new file with mode: 0644]

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.