diff -r 7100059f7bfd -r 3d43bcfdf7e7 src/base/output.cc --- a/src/base/output.cc Mon May 14 20:31:33 2012 -0500 +++ b/src/base/output.cc Fri May 18 17:37:25 2012 +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); diff -r 7100059f7bfd -r 3d43bcfdf7e7 src/base/statistics.hh --- a/src/base/statistics.hh Mon May 14 20:31:33 2012 -0500 +++ b/src/base/statistics.hh Fri May 18 17:37:25 2012 +0430 @@ -69,6 +69,7 @@ #include "base/refcnt.hh" #include "base/str.hh" #include "base/types.hh" +#include "base/callback.hh" class Callback; @@ -3135,6 +3136,15 @@ */ void registerResetCallback(Callback *cb); +inline CallbackQueue & +getDumpQueue() +{ + static CallbackQueue dumpQueue; + return dumpQueue; +} + +void registerDumpCallback(Callback *cb); + std::list &statsList(); } // namespace Stats diff -r 7100059f7bfd -r 3d43bcfdf7e7 src/base/statistics.cc --- a/src/base/statistics.cc Mon May 14 20:31:33 2012 -0500 +++ b/src/base/statistics.cc Fri May 18 17:37:25 2012 +0430 @@ -458,6 +458,12 @@ _enabled = true; } +void +registerDumpCallback(Callback *cb) +{ + getDumpQueue().add(cb); +} + } // namespace Stats void diff -r 7100059f7bfd -r 3d43bcfdf7e7 src/base/stats/text.cc --- a/src/base/stats/text.cc Mon May 14 20:31:33 2012 -0500 +++ b/src/base/stats/text.cc Fri May 18 17:37:25 2012 +0430 @@ -51,6 +51,9 @@ #include "base/cast.hh" #include "base/misc.hh" #include "base/str.hh" +#include "../statistics.hh" + +using namespace Stats; using namespace std; @@ -147,6 +150,7 @@ { ccprintf(*stream, "\n---------- End Simulation Statistics ----------\n"); stream->flush(); + getDumpQueue().process(); } bool diff -r 7100059f7bfd -r 3d43bcfdf7e7 src/mem/ruby/profiler/Profiler.cc --- a/src/mem/ruby/profiler/Profiler.cc Mon May 14 20:31:33 2012 -0500 +++ b/src/mem/ruby/profiler/Profiler.cc Fri May 18 17:37:25 2012 +0430 @@ -72,7 +72,7 @@ m_inst_profiler_ptr = NULL; m_address_profiler_ptr = NULL; - m_real_time_start_time = time(NULL); // Not reset in clearStats() + m_real_time_start_time = time(NULL); m_stats_period = 1000000; // Default m_periodic_output_file_ptr = &cerr; @@ -447,7 +447,7 @@ Profiler::clearStats() { 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) { diff -r 7100059f7bfd -r 3d43bcfdf7e7 src/mem/ruby/system/System.hh --- a/src/mem/ruby/system/System.hh Mon May 14 20:31:33 2012 -0500 +++ b/src/mem/ruby/system/System.hh Fri May 18 17:37:25 2012 +0430 @@ -179,20 +179,28 @@ 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; } virtual void process(); }; - #endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ diff -r 7100059f7bfd -r 3d43bcfdf7e7 src/mem/ruby/system/System.cc --- a/src/mem/ruby/system/System.cc Mon May 14 20:31:33 2012 -0500 +++ b/src/mem/ruby/system/System.cc Fri May 18 17:37:25 2012 +0430 @@ -40,6 +40,9 @@ #include "mem/ruby/system/System.hh" #include "sim/eventq.hh" #include "sim/simulate.hh" +#include "../../../base/statistics.hh" + +using namespace Stats; using namespace std; @@ -86,11 +89,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,12 +476,15 @@ 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); RubySystem::printConfig(*os);