diff -ru a/src/base/output.cc b/src/base/output.cc --- a/src/base/output.cc 2012-05-13 10:03:36.000000000 +0430 +++ b/src/base/output.cc 2012-05-16 22:00:06.463197683 +0430 @@ -86,6 +86,9 @@ files[filename] = file; return file; } else { + map_t::iterator it = files.find(filename); + if(it != files.end()) + return it->second; ofstream *file = new ofstream(filename.c_str(), mode); if (!file->is_open()) fatal("Cannot open file %s", filename); Only in b/src/base: output.cc~ diff -ru a/src/base/statistics.hh b/src/base/statistics.hh --- a/src/base/statistics.hh 2012-05-13 10:03:36.000000000 +0430 +++ b/src/base/statistics.hh 2012-05-16 21:59:06.338899550 +0430 @@ -70,6 +70,8 @@ #include "base/str.hh" #include "base/types.hh" +#include "base/callback.hh" + class Callback; /** The current simulated tick. */ @@ -3137,6 +3139,15 @@ std::list &statsList(); +inline CallbackQueue & +getDumpQueue() +{ + static CallbackQueue dumpQueue; + return dumpQueue; +} + +void registerDumpCallback(Callback *cb); + } // namespace Stats #endif // __BASE_STATISTICS_HH__ Only in b/src/base: statistics.hh~ diff -ru a/src/base/statistics.cc b/src/base/statistics.cc --- a/src/base/statistics.cc 2012-05-13 10:03:36.000000000 +0430 +++ b/src/base/statistics.cc 2012-05-16 22:08:39.689742649 +0430 @@ -457,6 +457,12 @@ _enabled = true; } + +void +registerDumpCallback(Callback *cb) +{ + getDumpQueue().add(cb); +} } // namespace Stats Only in b/src/base: statistics.cc~ diff -ru a/src/base/stats/text.cc b/src/base/stats/text.cc --- a/src/base/stats/text.cc 2012-05-13 10:03:36.000000000 +0430 +++ b/src/base/stats/text.cc 2012-05-16 22:13:26.747166083 +0430 @@ -52,6 +52,10 @@ #include "base/misc.hh" #include "base/str.hh" +#include "../statistics.hh" + +using namespace Stats; + using namespace std; #ifndef NAN @@ -147,6 +151,7 @@ { ccprintf(*stream, "\n---------- End Simulation Statistics ----------\n"); stream->flush(); + getDumpQueue().process(); } bool Only in b/src/base/stats: text.cc~ diff -ru a/src/mem/ruby/profiler/Profiler.cc b/src/mem/ruby/profiler/Profiler.cc --- a/src/mem/ruby/profiler/Profiler.cc 2012-05-13 10:03:42.000000000 +0430 +++ b/src/mem/ruby/profiler/Profiler.cc 2012-05-16 22:05:52.400913111 +0430 @@ -448,6 +448,8 @@ { m_ruby_start = g_eventQueue_ptr->getTime(); + m_real_time_start_time = time(NULL); + m_cycles_executed_at_start.resize(m_num_of_sequencers); for (int i = 0; i < m_num_of_sequencers; i++) { if (g_system_ptr == NULL) { Only in b/src/mem/ruby/profiler: Profiler.cc~ diff -ru a/src/mem/ruby/system/System.hh b/src/mem/ruby/system/System.hh --- a/src/mem/ruby/system/System.hh 2012-05-13 10:03:42.000000000 +0430 +++ b/src/mem/ruby/system/System.hh 2012-05-16 22:04:43.600571952 +0430 @@ -179,15 +179,24 @@ return out; } -class RubyExitCallback : public Callback +class ResetRubyStatsCallback : public Callback +{ + + public: + virtual ~ResetRubyStatsCallback() {} + + virtual void process(); +}; + +class DumpRubystatsCallback : public Callback { private: std::string stats_filename; public: - virtual ~RubyExitCallback() {} + virtual ~DumpRubystatsCallback() {} - RubyExitCallback(const std::string& _stats_filename) + DumpRubystatsCallback(const std::string& _stats_filename) { stats_filename = _stats_filename; } Only in b/src/mem/ruby/system: System.hh~ diff -ru a/src/mem/ruby/system/System.cc b/src/mem/ruby/system/System.cc --- a/src/mem/ruby/system/System.cc 2012-05-13 10:03:42.000000000 +0430 +++ b/src/mem/ruby/system/System.cc 2012-05-16 22:12:07.122771254 +0430 @@ -41,6 +41,10 @@ #include "sim/eventq.hh" #include "sim/simulate.hh" +#include "../../../base/statistics.hh" + +using namespace Stats; + using namespace std; int RubySystem::m_random_seed; @@ -86,11 +90,12 @@ m_mem_vec_ptr->resize(m_memory_size_bytes); } - // - // Print ruby configuration and stats at exit - // - RubyExitCallback* rubyExitCB = new RubyExitCallback(p->stats_filename); - registerExitCallback(rubyExitCB); + ResetRubyStatsCallback* resetRubyStatsCB = new ResetRubyStatsCallback(); + Stats::registerResetCallback(resetRubyStatsCB); + + DumpRubystatsCallback* dumpRubyStatsCB = new DumpRubystatsCallback(p->stats_filename); + Stats::registerDumpCallback(dumpRubyStatsCB); + m_warmup_enabled = false; m_cooldown_enabled = false; } @@ -472,14 +477,17 @@ return new RubySystem(this); } -/** - * virtual process function that is invoked when the callback - * queue is executed. - */ void -RubyExitCallback::process() +ResetRubyStatsCallback::process() +{ + RubySystem::m_profiler_ptr->clearStats(); + RubySystem::getNetwork()->clearStats(); +} + +void +DumpRubystatsCallback::process() { - std::ostream *os = simout.create(stats_filename); + std::ostream *os = simout.create(stats_filename); RubySystem::printConfig(*os); *os << endl; RubySystem::printStats(*os); Only in b/src/mem/ruby/system: System.cc~