Profiler.cc (9117:49116b947194) | Profiler.cc (9171:ae88ecf37145) |
---|---|
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 53 unchanged lines hidden (view full) --- 62 63using namespace std; 64using m5::stl_helpers::operator<<; 65 66static double process_memory_total(); 67static double process_memory_resident(); 68 69Profiler::Profiler(const Params *p) | 1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 53 unchanged lines hidden (view full) --- 62 63using namespace std; 64using m5::stl_helpers::operator<<; 65 66static double process_memory_total(); 67static double process_memory_resident(); 68 69Profiler::Profiler(const Params *p) |
70 : SimObject(p) | 70 : SimObject(p), m_event(this) |
71{ 72 m_inst_profiler_ptr = NULL; 73 m_address_profiler_ptr = NULL; 74 75 m_real_time_start_time = time(NULL); // Not reset in clearStats() 76 m_stats_period = 1000000; // Default 77 m_periodic_output_file_ptr = &cerr; 78 --- 29 unchanged lines hidden (view full) --- 108Profiler::wakeup() 109{ 110 // FIXME - avoid the repeated code 111 112 vector<integer_t> perProcCycleCount(m_num_of_sequencers); 113 114 for (int i = 0; i < m_num_of_sequencers; i++) { 115 perProcCycleCount[i] = | 71{ 72 m_inst_profiler_ptr = NULL; 73 m_address_profiler_ptr = NULL; 74 75 m_real_time_start_time = time(NULL); // Not reset in clearStats() 76 m_stats_period = 1000000; // Default 77 m_periodic_output_file_ptr = &cerr; 78 --- 29 unchanged lines hidden (view full) --- 108Profiler::wakeup() 109{ 110 // FIXME - avoid the repeated code 111 112 vector<integer_t> perProcCycleCount(m_num_of_sequencers); 113 114 for (int i = 0; i < m_num_of_sequencers; i++) { 115 perProcCycleCount[i] = |
116 g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1; | 116 g_system_ptr->getTime() - m_cycles_executed_at_start[i] + 1; |
117 // The +1 allows us to avoid division by zero 118 } 119 120 ostream &out = *m_periodic_output_file_ptr; 121 | 117 // The +1 allows us to avoid division by zero 118 } 119 120 ostream &out = *m_periodic_output_file_ptr; 121 |
122 out << "ruby_cycles: " << g_eventQueue_ptr->getTime()-m_ruby_start << endl | 122 out << "ruby_cycles: " << g_system_ptr->getTime()-m_ruby_start << endl |
123 << "mbytes_resident: " << process_memory_resident() << endl 124 << "mbytes_total: " << process_memory_total() << endl; 125 126 if (process_memory_total() > 0) { 127 out << "resident_ratio: " 128 << process_memory_resident() / process_memory_total() << endl; 129 } 130 131 out << "miss_latency: " << m_allMissLatencyHistogram << endl; 132 133 out << endl; 134 135 if (m_all_instructions) { 136 m_inst_profiler_ptr->printStats(out); 137 } 138 139 //g_system_ptr->getNetwork()->printStats(out); | 123 << "mbytes_resident: " << process_memory_resident() << endl 124 << "mbytes_total: " << process_memory_total() << endl; 125 126 if (process_memory_total() > 0) { 127 out << "resident_ratio: " 128 << process_memory_resident() / process_memory_total() << endl; 129 } 130 131 out << "miss_latency: " << m_allMissLatencyHistogram << endl; 132 133 out << endl; 134 135 if (m_all_instructions) { 136 m_inst_profiler_ptr->printStats(out); 137 } 138 139 //g_system_ptr->getNetwork()->printStats(out); |
140 g_eventQueue_ptr->scheduleEvent(this, m_stats_period); | 140 schedule(m_event, curTick() + m_stats_period * g_system_ptr->getClock()); |
141} 142 143void 144Profiler::setPeriodicStatsFile(const string& filename) 145{ 146 cout << "Recording periodic statistics to file '" << filename << "' every " 147 << m_stats_period << " Ruby cycles" << endl; 148 149 if (m_periodic_output_file_ptr != &cerr) { 150 delete m_periodic_output_file_ptr; 151 } 152 153 m_periodic_output_file_ptr = new ofstream(filename.c_str()); | 141} 142 143void 144Profiler::setPeriodicStatsFile(const string& filename) 145{ 146 cout << "Recording periodic statistics to file '" << filename << "' every " 147 << m_stats_period << " Ruby cycles" << endl; 148 149 if (m_periodic_output_file_ptr != &cerr) { 150 delete m_periodic_output_file_ptr; 151 } 152 153 m_periodic_output_file_ptr = new ofstream(filename.c_str()); |
154 g_eventQueue_ptr->scheduleEvent(this, 1); | 154 schedule(m_event, curTick() + g_system_ptr->getClock()); |
155} 156 157void 158Profiler::setPeriodicStatsInterval(integer_t period) 159{ 160 cout << "Recording periodic statistics every " << m_stats_period 161 << " Ruby cycles" << endl; 162 163 m_stats_period = period; | 155} 156 157void 158Profiler::setPeriodicStatsInterval(integer_t period) 159{ 160 cout << "Recording periodic statistics every " << m_stats_period 161 << " Ruby cycles" << endl; 162 163 m_stats_period = period; |
164 g_eventQueue_ptr->scheduleEvent(this, 1); | 164 schedule(m_event, curTick() + g_system_ptr->getClock()); |
165} 166 167void 168Profiler::print(ostream& out) const 169{ 170 out << "[Profiler]"; 171} 172 --- 7 unchanged lines hidden (view full) --- 180 out << "Profiler Stats" << endl; 181 out << "--------------" << endl; 182 183 time_t real_time_current = time(NULL); 184 double seconds = difftime(real_time_current, m_real_time_start_time); 185 double minutes = seconds / 60.0; 186 double hours = minutes / 60.0; 187 double days = hours / 24.0; | 165} 166 167void 168Profiler::print(ostream& out) const 169{ 170 out << "[Profiler]"; 171} 172 --- 7 unchanged lines hidden (view full) --- 180 out << "Profiler Stats" << endl; 181 out << "--------------" << endl; 182 183 time_t real_time_current = time(NULL); 184 double seconds = difftime(real_time_current, m_real_time_start_time); 185 double minutes = seconds / 60.0; 186 double hours = minutes / 60.0; 187 double days = hours / 24.0; |
188 Time ruby_cycles = g_eventQueue_ptr->getTime()-m_ruby_start; | 188 Time ruby_cycles = g_system_ptr->getTime()-m_ruby_start; |
189 190 if (!short_stats) { 191 out << "Elapsed_time_in_seconds: " << seconds << endl; 192 out << "Elapsed_time_in_minutes: " << minutes << endl; 193 out << "Elapsed_time_in_hours: " << hours << endl; 194 out << "Elapsed_time_in_days: " << days << endl; 195 out << endl; 196 } --- 6 unchanged lines hidden (view full) --- 203 hours = minutes / 60.0; 204 days = hours / 24.0; 205 out << "Virtual_time_in_seconds: " << seconds << endl; 206 out << "Virtual_time_in_minutes: " << minutes << endl; 207 out << "Virtual_time_in_hours: " << hours << endl; 208 out << "Virtual_time_in_days: " << days << endl; 209 out << endl; 210 | 189 190 if (!short_stats) { 191 out << "Elapsed_time_in_seconds: " << seconds << endl; 192 out << "Elapsed_time_in_minutes: " << minutes << endl; 193 out << "Elapsed_time_in_hours: " << hours << endl; 194 out << "Elapsed_time_in_days: " << days << endl; 195 out << endl; 196 } --- 6 unchanged lines hidden (view full) --- 203 hours = minutes / 60.0; 204 days = hours / 24.0; 205 out << "Virtual_time_in_seconds: " << seconds << endl; 206 out << "Virtual_time_in_minutes: " << minutes << endl; 207 out << "Virtual_time_in_hours: " << hours << endl; 208 out << "Virtual_time_in_days: " << days << endl; 209 out << endl; 210 |
211 out << "Ruby_current_time: " << g_eventQueue_ptr->getTime() << endl; | 211 out << "Ruby_current_time: " << g_system_ptr->getTime() << endl; |
212 out << "Ruby_start_time: " << m_ruby_start << endl; 213 out << "Ruby_cycles: " << ruby_cycles << endl; 214 out << endl; 215 216 if (!short_stats) { 217 out << "mbytes_resident: " << process_memory_resident() << endl; 218 out << "mbytes_total: " << process_memory_total() << endl; 219 if (process_memory_total() > 0) { 220 out << "resident_ratio: " 221 << process_memory_resident()/process_memory_total() << endl; 222 } 223 out << endl; 224 } 225 226 vector<integer_t> perProcCycleCount(m_num_of_sequencers); 227 228 for (int i = 0; i < m_num_of_sequencers; i++) { 229 perProcCycleCount[i] = | 212 out << "Ruby_start_time: " << m_ruby_start << endl; 213 out << "Ruby_cycles: " << ruby_cycles << endl; 214 out << endl; 215 216 if (!short_stats) { 217 out << "mbytes_resident: " << process_memory_resident() << endl; 218 out << "mbytes_total: " << process_memory_total() << endl; 219 if (process_memory_total() > 0) { 220 out << "resident_ratio: " 221 << process_memory_resident()/process_memory_total() << endl; 222 } 223 out << endl; 224 } 225 226 vector<integer_t> perProcCycleCount(m_num_of_sequencers); 227 228 for (int i = 0; i < m_num_of_sequencers; i++) { 229 perProcCycleCount[i] = |
230 g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1; | 230 g_system_ptr->getTime() - m_cycles_executed_at_start[i] + 1; |
231 // The +1 allows us to avoid division by zero 232 } 233 234 out << "ruby_cycles_executed: " << perProcCycleCount << endl; 235 236 out << endl; 237 238 if (!short_stats) { --- 193 unchanged lines hidden (view full) --- 432 out << "swaps: " << usage.ru_nswap << endl; 433 out << "block_inputs: " << usage.ru_inblock << endl; 434 out << "block_outputs: " << usage.ru_oublock << endl; 435} 436 437void 438Profiler::clearStats() 439{ | 231 // The +1 allows us to avoid division by zero 232 } 233 234 out << "ruby_cycles_executed: " << perProcCycleCount << endl; 235 236 out << endl; 237 238 if (!short_stats) { --- 193 unchanged lines hidden (view full) --- 432 out << "swaps: " << usage.ru_nswap << endl; 433 out << "block_inputs: " << usage.ru_inblock << endl; 434 out << "block_outputs: " << usage.ru_oublock << endl; 435} 436 437void 438Profiler::clearStats() 439{ |
440 m_ruby_start = g_eventQueue_ptr->getTime(); | 440 m_ruby_start = g_system_ptr->getTime(); |
441 442 m_cycles_executed_at_start.resize(m_num_of_sequencers); 443 for (int i = 0; i < m_num_of_sequencers; i++) { 444 if (g_system_ptr == NULL) { 445 m_cycles_executed_at_start[i] = 0; 446 } else { | 441 442 m_cycles_executed_at_start.resize(m_num_of_sequencers); 443 for (int i = 0; i < m_num_of_sequencers; i++) { 444 if (g_system_ptr == NULL) { 445 m_cycles_executed_at_start[i] = 0; 446 } else { |
447 m_cycles_executed_at_start[i] = g_system_ptr->getCycleCount(i); | 447 m_cycles_executed_at_start[i] = g_system_ptr->getTime(); |
448 } 449 } 450 451 m_busyControllerCount.resize(MachineType_NUM); // all machines 452 for (int i = 0; i < MachineType_NUM; i++) { 453 int size = MachineType_base_count((MachineType)i); 454 m_busyControllerCount[i].resize(size); 455 for (int j = 0; j < size; j++) { --- 63 unchanged lines hidden (view full) --- 519 m_outstanding_requests.clear(); 520 m_outstanding_persistent_requests.clear(); 521 522 // Flush the prefetches through the system - used so that there 523 // are no outstanding requests after stats are cleared 524 //g_eventQueue_ptr->triggerAllEvents(); 525 526 // update the start time | 448 } 449 } 450 451 m_busyControllerCount.resize(MachineType_NUM); // all machines 452 for (int i = 0; i < MachineType_NUM; i++) { 453 int size = MachineType_base_count((MachineType)i); 454 m_busyControllerCount[i].resize(size); 455 for (int j = 0; j < size; j++) { --- 63 unchanged lines hidden (view full) --- 519 m_outstanding_requests.clear(); 520 m_outstanding_persistent_requests.clear(); 521 522 // Flush the prefetches through the system - used so that there 523 // are no outstanding requests after stats are cleared 524 //g_eventQueue_ptr->triggerAllEvents(); 525 526 // update the start time |
527 m_ruby_start = g_eventQueue_ptr->getTime(); | 527 m_ruby_start = g_system_ptr->getTime(); |
528} 529 530void 531Profiler::addAddressTraceSample(const RubyRequest& msg, NodeID id) 532{ 533 if (msg.getType() != RubyRequestType_IFETCH) { 534 // Note: The following line should be commented out if you 535 // want to use the special profiling that is part of the GS320 --- 182 unchanged lines hidden (view full) --- 718} 719 720void 721Profiler::rubyWatch(int id) 722{ 723 uint64 tr = 0; 724 Address watch_address = Address(tr); 725 | 528} 529 530void 531Profiler::addAddressTraceSample(const RubyRequest& msg, NodeID id) 532{ 533 if (msg.getType() != RubyRequestType_IFETCH) { 534 // Note: The following line should be commented out if you 535 // want to use the special profiling that is part of the GS320 --- 182 unchanged lines hidden (view full) --- 718} 719 720void 721Profiler::rubyWatch(int id) 722{ 723 uint64 tr = 0; 724 Address watch_address = Address(tr); 725 |
726 DPRINTFN("%7s %3s RUBY WATCH %d\n", g_eventQueue_ptr->getTime(), id, | 726 DPRINTFN("%7s %3s RUBY WATCH %d\n", g_system_ptr->getTime(), id, |
727 watch_address); 728 729 // don't care about success or failure 730 m_watch_address_set.insert(watch_address); 731} 732 733bool 734Profiler::watchAddress(Address addr) 735{ 736 return m_watch_address_set.count(addr) > 0; 737} 738 739Profiler * 740RubyProfilerParams::create() 741{ 742 return new Profiler(this); 743} | 727 watch_address); 728 729 // don't care about success or failure 730 m_watch_address_set.insert(watch_address); 731} 732 733bool 734Profiler::watchAddress(Address addr) 735{ 736 return m_watch_address_set.count(addr) > 0; 737} 738 739Profiler * 740RubyProfilerParams::create() 741{ 742 return new Profiler(this); 743} |