Profiler.cc (7056:b66b558578bd) Profiler.cc (7454:3a3e8e8cce1b)
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;

--- 32 unchanged lines hidden (view full) ---

41
42 ----------------------------------------------------------------------
43*/
44
45// Allows use of times() library call, which determines virtual runtime
46#include <sys/resource.h>
47#include <sys/times.h>
48
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;

--- 32 unchanged lines hidden (view full) ---

41
42 ----------------------------------------------------------------------
43*/
44
45// Allows use of times() library call, which determines virtual runtime
46#include <sys/resource.h>
47#include <sys/times.h>
48
49#include <algorithm>
50
51#include "base/stl_helpers.hh"
49#include "base/str.hh"
50#include "mem/gems_common/Map.hh"
51#include "mem/gems_common/PrioHeap.hh"
52#include "mem/protocol/CacheMsg.hh"
53#include "mem/protocol/MachineType.hh"
54#include "mem/protocol/Protocol.hh"
55#include "mem/ruby/common/Debug.hh"
56#include "mem/ruby/network/Network.hh"
57#include "mem/ruby/profiler/AddressProfiler.hh"
58#include "mem/ruby/profiler/Profiler.hh"
59#include "mem/ruby/system/System.hh"
60#include "mem/ruby/system/System.hh"
61
62using namespace std;
52#include "base/str.hh"
53#include "mem/gems_common/Map.hh"
54#include "mem/gems_common/PrioHeap.hh"
55#include "mem/protocol/CacheMsg.hh"
56#include "mem/protocol/MachineType.hh"
57#include "mem/protocol/Protocol.hh"
58#include "mem/ruby/common/Debug.hh"
59#include "mem/ruby/network/Network.hh"
60#include "mem/ruby/profiler/AddressProfiler.hh"
61#include "mem/ruby/profiler/Profiler.hh"
62#include "mem/ruby/system/System.hh"
63#include "mem/ruby/system/System.hh"
64
65using namespace std;
66using m5::stl_helpers::operator<<;
63
64extern ostream* debug_cout_ptr;
65
66static double process_memory_total();
67static double process_memory_resident();
68
69Profiler::Profiler(const Params *p)
70 : SimObject(p)

--- 35 unchanged lines hidden (view full) ---

106 delete m_requestProfileMap_ptr;
107}
108
109void
110Profiler::wakeup()
111{
112 // FIXME - avoid the repeated code
113
67
68extern ostream* debug_cout_ptr;
69
70static double process_memory_total();
71static double process_memory_resident();
72
73Profiler::Profiler(const Params *p)
74 : SimObject(p)

--- 35 unchanged lines hidden (view full) ---

110 delete m_requestProfileMap_ptr;
111}
112
113void
114Profiler::wakeup()
115{
116 // FIXME - avoid the repeated code
117
114 Vector<integer_t> perProcCycleCount;
115 perProcCycleCount.setSize(m_num_of_sequencers);
118 vector<integer_t> perProcCycleCount(m_num_of_sequencers);
116
117 for (int i = 0; i < m_num_of_sequencers; i++) {
118 perProcCycleCount[i] =
119 g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1;
120 // The +1 allows us to avoid division by zero
121 }
122
123 ostream &out = *m_periodic_output_file_ptr;

--- 106 unchanged lines hidden (view full) ---

230 out << "mbytes_total: " << process_memory_total() << endl;
231 if (process_memory_total() > 0) {
232 out << "resident_ratio: "
233 << process_memory_resident()/process_memory_total() << endl;
234 }
235 out << endl;
236 }
237
119
120 for (int i = 0; i < m_num_of_sequencers; i++) {
121 perProcCycleCount[i] =
122 g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1;
123 // The +1 allows us to avoid division by zero
124 }
125
126 ostream &out = *m_periodic_output_file_ptr;

--- 106 unchanged lines hidden (view full) ---

233 out << "mbytes_total: " << process_memory_total() << endl;
234 if (process_memory_total() > 0) {
235 out << "resident_ratio: "
236 << process_memory_resident()/process_memory_total() << endl;
237 }
238 out << endl;
239 }
240
238 Vector<integer_t> perProcCycleCount;
239 perProcCycleCount.setSize(m_num_of_sequencers);
241 vector<integer_t> perProcCycleCount(m_num_of_sequencers);
240
241 for (int i = 0; i < m_num_of_sequencers; i++) {
242 perProcCycleCount[i] =
243 g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1;
244 // The +1 allows us to avoid division by zero
245 }
246
247 out << "ruby_cycles_executed: " << perProcCycleCount << endl;

--- 100 unchanged lines hidden (view full) ---

348 }
349 }
350
351 if (!short_stats) {
352 out << "Request vs. RubySystem State Profile" << endl;
353 out << "--------------------------------" << endl;
354 out << endl;
355
242
243 for (int i = 0; i < m_num_of_sequencers; i++) {
244 perProcCycleCount[i] =
245 g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1;
246 // The +1 allows us to avoid division by zero
247 }
248
249 out << "ruby_cycles_executed: " << perProcCycleCount << endl;

--- 100 unchanged lines hidden (view full) ---

350 }
351 }
352
353 if (!short_stats) {
354 out << "Request vs. RubySystem State Profile" << endl;
355 out << "--------------------------------" << endl;
356 out << endl;
357
356 Vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys();
357 requestProfileKeys.sortVector();
358 vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys();
359 sort(requestProfileKeys.begin(), requestProfileKeys.end());
358
359 for (int i = 0; i < requestProfileKeys.size(); i++) {
360 int temp_int =
361 m_requestProfileMap_ptr->lookup(requestProfileKeys[i]);
362 double percent = (100.0 * double(temp_int)) / double(m_requests);
363 vector<string> items;
364 tokenize(items, requestProfileKeys[i], ':');
365 vector<string>::iterator i = items.begin();

--- 52 unchanged lines hidden (view full) ---

418 out << "block_outputs: " << usage.ru_oublock << endl;
419}
420
421void
422Profiler::clearStats()
423{
424 m_ruby_start = g_eventQueue_ptr->getTime();
425
360
361 for (int i = 0; i < requestProfileKeys.size(); i++) {
362 int temp_int =
363 m_requestProfileMap_ptr->lookup(requestProfileKeys[i]);
364 double percent = (100.0 * double(temp_int)) / double(m_requests);
365 vector<string> items;
366 tokenize(items, requestProfileKeys[i], ':');
367 vector<string>::iterator i = items.begin();

--- 52 unchanged lines hidden (view full) ---

420 out << "block_outputs: " << usage.ru_oublock << endl;
421}
422
423void
424Profiler::clearStats()
425{
426 m_ruby_start = g_eventQueue_ptr->getTime();
427
426 m_cycles_executed_at_start.setSize(m_num_of_sequencers);
428 m_cycles_executed_at_start.resize(m_num_of_sequencers);
427 for (int i = 0; i < m_num_of_sequencers; i++) {
428 if (g_system_ptr == NULL) {
429 m_cycles_executed_at_start[i] = 0;
430 } else {
431 m_cycles_executed_at_start[i] = g_system_ptr->getCycleCount(i);
432 }
433 }
434
429 for (int i = 0; i < m_num_of_sequencers; i++) {
430 if (g_system_ptr == NULL) {
431 m_cycles_executed_at_start[i] = 0;
432 } else {
433 m_cycles_executed_at_start[i] = g_system_ptr->getCycleCount(i);
434 }
435 }
436
435 m_busyControllerCount.setSize(MachineType_NUM); // all machines
437 m_busyControllerCount.resize(MachineType_NUM); // all machines
436 for (int i = 0; i < MachineType_NUM; i++) {
437 int size = MachineType_base_count((MachineType)i);
438 for (int i = 0; i < MachineType_NUM; i++) {
439 int size = MachineType_base_count((MachineType)i);
438 m_busyControllerCount[i].setSize(size);
440 m_busyControllerCount[i].resize(size);
439 for (int j = 0; j < size; j++) {
440 m_busyControllerCount[i][j] = 0;
441 }
442 }
443 m_busyBankCount = 0;
444
445 m_delayedCyclesHistogram.clear();
446 m_delayedCyclesNonPFHistogram.clear();
447 int size = RubySystem::getNetwork()->getNumberOfVirtualNetworks();
441 for (int j = 0; j < size; j++) {
442 m_busyControllerCount[i][j] = 0;
443 }
444 }
445 m_busyBankCount = 0;
446
447 m_delayedCyclesHistogram.clear();
448 m_delayedCyclesNonPFHistogram.clear();
449 int size = RubySystem::getNetwork()->getNumberOfVirtualNetworks();
448 m_delayedCyclesVCHistograms.setSize(size);
450 m_delayedCyclesVCHistograms.resize(size);
449 for (int i = 0; i < size; i++) {
450 m_delayedCyclesVCHistograms[i].clear();
451 }
452
451 for (int i = 0; i < size; i++) {
452 m_delayedCyclesVCHistograms[i].clear();
453 }
454
453 m_missLatencyHistograms.setSize(RubyRequestType_NUM);
455 m_missLatencyHistograms.resize(RubyRequestType_NUM);
454 for (int i = 0; i < m_missLatencyHistograms.size(); i++) {
455 m_missLatencyHistograms[i].clear(200);
456 }
456 for (int i = 0; i < m_missLatencyHistograms.size(); i++) {
457 m_missLatencyHistograms[i].clear(200);
458 }
457 m_machLatencyHistograms.setSize(GenericMachineType_NUM+1);
459 m_machLatencyHistograms.resize(GenericMachineType_NUM+1);
458 for (int i = 0; i < m_machLatencyHistograms.size(); i++) {
459 m_machLatencyHistograms[i].clear(200);
460 }
461 m_allMissLatencyHistogram.clear(200);
462
460 for (int i = 0; i < m_machLatencyHistograms.size(); i++) {
461 m_machLatencyHistograms[i].clear(200);
462 }
463 m_allMissLatencyHistogram.clear(200);
464
463 m_SWPrefetchLatencyHistograms.setSize(CacheRequestType_NUM);
465 m_SWPrefetchLatencyHistograms.resize(CacheRequestType_NUM);
464 for (int i = 0; i < m_SWPrefetchLatencyHistograms.size(); i++) {
465 m_SWPrefetchLatencyHistograms[i].clear(200);
466 }
466 for (int i = 0; i < m_SWPrefetchLatencyHistograms.size(); i++) {
467 m_SWPrefetchLatencyHistograms[i].clear(200);
468 }
467 m_SWPrefetchMachLatencyHistograms.setSize(GenericMachineType_NUM+1);
469 m_SWPrefetchMachLatencyHistograms.resize(GenericMachineType_NUM+1);
468 for (int i = 0; i < m_SWPrefetchMachLatencyHistograms.size(); i++) {
469 m_SWPrefetchMachLatencyHistograms[i].clear(200);
470 }
471 m_allSWPrefetchLatencyHistogram.clear(200);
472
473 m_sequencer_requests.clear();
474 m_read_sharing_histogram.clear();
475 m_write_sharing_histogram.clear();

--- 223 unchanged lines hidden ---
470 for (int i = 0; i < m_SWPrefetchMachLatencyHistograms.size(); i++) {
471 m_SWPrefetchMachLatencyHistograms[i].clear(200);
472 }
473 m_allSWPrefetchLatencyHistogram.clear(200);
474
475 m_sequencer_requests.clear();
476 m_read_sharing_histogram.clear();
477 m_write_sharing_histogram.clear();

--- 223 unchanged lines hidden ---