Changeset 6fee21 for src/base/timer.cpp


Ignore:
Timestamp:
May 2, 2012, 1:36:51 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
49f8653
Parents:
759a6a
Message:

Timer::PrintGlobal is now less vulnerable to different processes having different sets of timing entities.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1781 5161e1c8-67bf-11de-9fd5-51895aff932f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/base/timer.cpp

    r759a6a r6fee21  
    177177  comm.PrintStringOnce("Running times (global):");
    178178
    179   for (iter=Timer::td.begin(); iter!=Timer::td.end(); ++iter) {
    180     std::strcpy(name, iter->first.c_str());
    181     MPI_Bcast(name, 80, MPI_CHAR, 0, MPI_COMM_WORLD);
    182     MPI_Gather(&Timer::td[name].duration, 1, MPI_DOUBLE, times, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
    183     MPI_Gather(&Timer::td[name].total, 1, MPI_INT, calls, 1, MPI_INT, 0, MPI_COMM_WORLD);
    184 
    185     if (rank == 0) {
    186       int min_calls, max_calls;
    187       vmg_float avg_calls;
    188       vmg_float min_duration, max_duration, avg_duration;
    189       int rank_min_calls, rank_max_calls, rank_min_duration, rank_max_duration;
    190 
    191       min_duration = min(times, size, rank_min_duration);
    192       max_duration = max(times, size, rank_max_duration);
    193       avg_duration = avg(times, size);
    194       min_calls = min(calls, size, rank_min_calls);
    195       max_calls = max(calls, size, rank_max_calls);
    196       avg_calls = avg(calls, size);
    197 
    198       comm.PrintStringOnce("  %s: %e s (%d)", iter->first.c_str(), iter->second.duration, iter->second.total);
    199       comm.PrintStringOnce("    Min: %e s @ %d", min_duration, rank_min_duration);
    200       comm.PrintStringOnce("    Max: %e s @ %d", max_duration, rank_max_duration);
    201       comm.PrintStringOnce("    Avg: %e s", avg_duration);
    202       comm.PrintStringOnce("    Min calls: %d @ %d", min_calls, rank_min_calls);
    203       comm.PrintStringOnce("    Max calls: %d @ %d", max_calls, rank_max_calls);
    204       comm.PrintStringOnce("    Avg calls: %f", avg_calls);
     179  int timer_size = Timer::td.size();
     180  MPI_Bcast(timer_size, 1, MPI_INT, 0, MPI_COMM_WORLD);
     181
     182  if (rank == 0) {
     183      for (iter=Timer::td.begin(); iter!=Timer::td.end(); ++iter) {
     184        std::strcpy(name, iter->first.c_str());
     185        MPI_Bcast(name, 80, MPI_CHAR, 0, MPI_COMM_WORLD);
     186        MPI_Gather(&Timer::td[name].duration, 1, MPI_DOUBLE, times, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
     187        MPI_Gather(&Timer::td[name].total, 1, MPI_INT, calls, 1, MPI_INT, 0, MPI_COMM_WORLD);
     188
     189        int min_calls, max_calls;
     190        vmg_float avg_calls;
     191        vmg_float min_duration, max_duration, avg_duration;
     192        int rank_min_calls, rank_max_calls, rank_min_duration, rank_max_duration;
     193
     194        min_duration = min(times, size, rank_min_duration);
     195        max_duration = max(times, size, rank_max_duration);
     196        avg_duration = avg(times, size);
     197        min_calls = min(calls, size, rank_min_calls);
     198        max_calls = max(calls, size, rank_max_calls);
     199        avg_calls = avg(calls, size);
     200
     201        comm.PrintStringOnce("  %s: %e s (%d)", iter->first.c_str(), iter->second.duration, iter->second.total);
     202        comm.PrintStringOnce("    Min: %e s @ %d", min_duration, rank_min_duration);
     203        comm.PrintStringOnce("    Max: %e s @ %d", max_duration, rank_max_duration);
     204        comm.PrintStringOnce("    Avg: %e s", avg_duration);
     205        comm.PrintStringOnce("    Min calls: %d @ %d", min_calls, rank_min_calls);
     206        comm.PrintStringOnce("    Max calls: %d @ %d", max_calls, rank_max_calls);
     207        comm.PrintStringOnce("    Avg calls: %f", avg_calls);
     208    }
     209  }else {
     210    for (int i=0; i<timer_size; ++i) {
     211      MPI_Bcast(name, 80, MPI_CHAR, 0, MPI_COMM_WORLD);
     212      MPI_Gather(&Timer::td[name].duration, 1, MPI_DOUBLE, times, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
     213      MPI_Gather(&Timer::td[name].total, 1, MPI_INT, calls, 1, MPI_INT, 0, MPI_COMM_WORLD);
    205214    }
    206215  }
Note: See TracChangeset for help on using the changeset viewer.