Deleted Added
sdiff udiff text old ( 6148:71a683318799 ) new ( 6153:0011560d49b0 )
full compact
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;

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

59#include "PrioHeap.hh"
60#include "CacheMsg.hh"
61#include "Driver.hh"
62#include "Protocol.hh"
63#include "util.hh"
64#include "Map.hh"
65#include "Debug.hh"
66#include "MachineType.hh"
67
68// Allows use of times() library call, which determines virtual runtime
69#include <sys/times.h>
70
71extern std::ostream * debug_cout_ptr;
72
73static double process_memory_total();
74static double process_memory_resident();
75
76Profiler::Profiler()
77 : m_conflicting_histogram(-1)
78{
79 m_requestProfileMap_ptr = new Map<string, int>;
80 m_L1D_cache_profiler_ptr = new CacheProfiler("L1D_cache");
81 m_L1I_cache_profiler_ptr = new CacheProfiler("L1I_cache");
82
83 m_L2_cache_profiler_ptr = new CacheProfiler("L2_cache");
84
85 m_address_profiler_ptr = new AddressProfiler;
86 m_inst_profiler_ptr = NULL;
87 if (PROFILE_ALL_INSTRUCTIONS) {
88 m_inst_profiler_ptr = new AddressProfiler;
89 }
90
91 m_conflicting_map_ptr = new Map<Address, Time>;
92
93 m_real_time_start_time = time(NULL); // Not reset in clearStats()
94 m_stats_period = 1000000; // Default
95 m_periodic_output_file_ptr = &cerr;
96
97 // for MemoryControl:
98 m_memReq = 0;
99 m_memBankBusy = 0;
100 m_memBusBusy = 0;
101 m_memReadWriteBusy = 0;
102 m_memDataBusBusy = 0;
103 m_memTfawBusy = 0;
104 m_memRefresh = 0;

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

124{
125 if (m_periodic_output_file_ptr != &cerr) {
126 delete m_periodic_output_file_ptr;
127 }
128 delete m_address_profiler_ptr;
129 delete m_L1D_cache_profiler_ptr;
130 delete m_L1I_cache_profiler_ptr;
131 delete m_L2_cache_profiler_ptr;
132 delete m_requestProfileMap_ptr;
133 delete m_conflicting_map_ptr;
134}
135
136void Profiler::wakeup()
137{
138 // FIXME - avoid the repeated code
139

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

146 for(int i=0; i < RubyConfig::numberOfProcessors(); i++) {
147 perProcInstructionCount[i] = g_system_ptr->getDriver()->getInstructionCount(i) - m_instructions_executed_at_start[i] + 1;
148 perProcCycleCount[i] = g_system_ptr->getDriver()->getCycleCount(i) - m_cycles_executed_at_start[i] + 1;
149 // The +1 allows us to avoid division by zero
150 }
151
152 integer_t total_misses = m_perProcTotalMisses.sum();
153 integer_t instruction_executed = perProcInstructionCount.sum();
154 integer_t cycles_executed = perProcCycleCount.sum();
155 integer_t transactions_started = m_perProcStartTransaction.sum();
156 integer_t transactions_ended = m_perProcEndTransaction.sum();
157
158 (*m_periodic_output_file_ptr) << "ruby_cycles: " << g_eventQueue_ptr->getTime()-m_ruby_start << endl;
159 (*m_periodic_output_file_ptr) << "total_misses: " << total_misses << " " << m_perProcTotalMisses << endl;
160 (*m_periodic_output_file_ptr) << "instruction_executed: " << instruction_executed << " " << perProcInstructionCount << endl;
161 (*m_periodic_output_file_ptr) << "cycles_executed: " << cycles_executed << " " << perProcCycleCount << endl;
162 (*m_periodic_output_file_ptr) << "transactions_started: " << transactions_started << " " << m_perProcStartTransaction << endl;
163 (*m_periodic_output_file_ptr) << "transactions_ended: " << transactions_ended << " " << m_perProcEndTransaction << endl;
164 (*m_periodic_output_file_ptr) << "L1TBE_usage: " << m_L1tbeProfile << endl;
165 (*m_periodic_output_file_ptr) << "L2TBE_usage: " << m_L2tbeProfile << endl;
166 (*m_periodic_output_file_ptr) << "mbytes_resident: " << process_memory_resident() << endl;
167 (*m_periodic_output_file_ptr) << "mbytes_total: " << process_memory_total() << endl;
168 if (process_memory_total() > 0) {
169 (*m_periodic_output_file_ptr) << "resident_ratio: " << process_memory_resident()/process_memory_total() << endl;

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

304 perProcMissesPerTrans[i] = m_perProcTotalMisses[i] / double(trans);
305 }
306 }
307
308 integer_t total_misses = m_perProcTotalMisses.sum();
309 integer_t user_misses = m_perProcUserMisses.sum();
310 integer_t supervisor_misses = m_perProcSupervisorMisses.sum();
311 integer_t instruction_executed = perProcInstructionCount.sum();
312 integer_t cycles_executed = perProcCycleCount.sum();
313 integer_t transactions_started = m_perProcStartTransaction.sum();
314 integer_t transactions_ended = m_perProcEndTransaction.sum();
315
316 double instructions_per_transaction = (transactions_ended != 0) ? double(instruction_executed) / double(transactions_ended) : 0;
317 double cycles_per_transaction = (transactions_ended != 0) ? (RubyConfig::numberOfProcessors() * double(ruby_cycles)) / double(transactions_ended) : 0;
318 double misses_per_transaction = (transactions_ended != 0) ? double(total_misses) / double(transactions_ended) : 0;
319
320 out << "Total_misses: " << total_misses << endl;
321 out << "total_misses: " << total_misses << " " << m_perProcTotalMisses << endl;
322 out << "user_misses: " << user_misses << " " << m_perProcUserMisses << endl;
323 out << "supervisor_misses: " << supervisor_misses << " " << m_perProcSupervisorMisses << endl;
324 out << endl;
325 out << "instruction_executed: " << instruction_executed << " " << perProcInstructionCount << endl;
326 out << "cycles_executed: " << cycles_executed << " " << perProcCycleCount << endl;
327 out << "cycles_per_instruction: " << (RubyConfig::numberOfProcessors()*double(ruby_cycles))/double(instruction_executed) << " " << perProcCPI << endl;
328 out << "misses_per_thousand_instructions: " << 1000.0 * (double(total_misses) / double(instruction_executed)) << " " << perProcMissesPerInsn << endl;
329 out << endl;
330 out << "transactions_started: " << transactions_started << " " << m_perProcStartTransaction << endl;
331 out << "transactions_ended: " << transactions_ended << " " << m_perProcEndTransaction << endl;
332 out << "instructions_per_transaction: " << instructions_per_transaction << " " << perProcInsnPerTrans << endl;
333 out << "cycles_per_transaction: " << cycles_per_transaction << " " << perProcCyclesPerTrans << endl;
334 out << "misses_per_transaction: " << misses_per_transaction << " " << perProcMissesPerTrans << endl;

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

474 out << "outstanding_requests: "; m_outstanding_requests.printPercent(out); out << endl;
475 if (m_outstanding_persistent_requests.size() > 0) {
476 out << "outstanding_persistent_requests: "; m_outstanding_persistent_requests.printPercent(out); out << endl;
477 }
478 out << endl;
479 }
480 }
481
482 if (!short_stats) {
483 out << "Request vs. RubySystem State Profile" << endl;
484 out << "--------------------------------" << endl;
485 out << endl;
486
487 Vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys();
488 requestProfileKeys.sortVector();
489

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

649 m_conflicting_histogram.clear();
650
651 m_outstanding_requests.clear();
652 m_outstanding_persistent_requests.clear();
653
654 m_L1D_cache_profiler_ptr->clearStats();
655 m_L1I_cache_profiler_ptr->clearStats();
656 m_L2_cache_profiler_ptr->clearStats();
657
658 // for MemoryControl:
659 m_memReq = 0;
660 m_memBankBusy = 0;
661 m_memBusBusy = 0;
662 m_memTfawBusy = 0;
663 m_memReadWriteBusy = 0;
664 m_memDataBusBusy = 0;
665 m_memRefresh = 0;

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

944 m_gets_mask_prediction.add(pred_set.count());
945}
946
947void Profiler::profileTrainingMask(const Set& pred_set)
948{
949 m_explicit_training_mask.add(pred_set.count());
950}
951
952// For MemoryControl:
953void Profiler::profileMemReq(int bank) {
954 m_memReq++;
955 m_memBankCount[bank]++;
956}
957
958void Profiler::profileMemBankBusy() { m_memBankBusy++; }
959void Profiler::profileMemBusBusy() { m_memBusBusy++; }
960void Profiler::profileMemReadWriteBusy() { m_memReadWriteBusy++; }
961void Profiler::profileMemDataBusBusy() { m_memDataBusBusy++; }
962void Profiler::profileMemTfawBusy() { m_memTfawBusy++; }
963void Profiler::profileMemRefresh() { m_memRefresh++; }
964void Profiler::profileMemRead() { m_memRead++; }
965void Profiler::profileMemWrite() { m_memWrite++; }
966void Profiler::profileMemWaitCycles(int cycles) { m_memWaitCycles += cycles; }
967void Profiler::profileMemInputQ(int cycles) { m_memInputQ += cycles; }
968void Profiler::profileMemBankQ(int cycles) { m_memBankQ += cycles; }
969void Profiler::profileMemArbWait(int cycles) { m_memArbWait += cycles; }
970void Profiler::profileMemRandBusy() { m_memRandBusy++; }
971void Profiler::profileMemNotOld() { m_memNotOld++; }
972
973int64 Profiler::getTotalInstructionsExecuted() const
974{
975 int64 sum = 1; // Starting at 1 allows us to avoid division by zero
976 for(int i=0; i < RubyConfig::numberOfProcessors(); i++) {
977 sum += (g_system_ptr->getDriver()->getInstructionCount(i) - m_instructions_executed_at_start[i]);
978 }
979 return sum;
980}

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

1018 case CacheRequestType_NULL:
1019 return GenericRequestType_NULL;
1020 break;
1021 default:
1022 ERROR_MSG("Unexpected cache request type");
1023 }
1024}
1025