Profiler.cc revision 6896
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org */ 286145Snate@binkert.org 296145Snate@binkert.org/* 306145Snate@binkert.org This file has been modified by Kevin Moore and Dan Nussbaum of the 316145Snate@binkert.org Scalable Systems Research Group at Sun Microsystems Laboratories 326145Snate@binkert.org (http://research.sun.com/scalable/) to support the Adaptive 336145Snate@binkert.org Transactional Memory Test Platform (ATMTP). 346145Snate@binkert.org 356145Snate@binkert.org Please send email to atmtp-interest@sun.com with feedback, questions, or 366145Snate@binkert.org to request future announcements about ATMTP. 376145Snate@binkert.org 386145Snate@binkert.org ---------------------------------------------------------------------- 396145Snate@binkert.org 406145Snate@binkert.org File modification date: 2008-02-23 416145Snate@binkert.org 426145Snate@binkert.org ---------------------------------------------------------------------- 436145Snate@binkert.org*/ 446145Snate@binkert.org 456145Snate@binkert.org/* 466284Snate@binkert.org * Profiler.cc 476145Snate@binkert.org * 486284Snate@binkert.org * Description: See Profiler.hh 496145Snate@binkert.org * 506145Snate@binkert.org * $Id$ 516145Snate@binkert.org * 526145Snate@binkert.org */ 536145Snate@binkert.org 546154Snate@binkert.org#include "mem/ruby/profiler/Profiler.hh" 556154Snate@binkert.org#include "mem/ruby/profiler/AddressProfiler.hh" 566154Snate@binkert.org#include "mem/ruby/system/System.hh" 576154Snate@binkert.org#include "mem/ruby/network/Network.hh" 586154Snate@binkert.org#include "mem/gems_common/PrioHeap.hh" 596154Snate@binkert.org#include "mem/protocol/CacheMsg.hh" 606154Snate@binkert.org#include "mem/protocol/Protocol.hh" 616154Snate@binkert.org#include "mem/gems_common/util.hh" 626154Snate@binkert.org#include "mem/gems_common/Map.hh" 636154Snate@binkert.org#include "mem/ruby/common/Debug.hh" 646154Snate@binkert.org#include "mem/protocol/MachineType.hh" 656145Snate@binkert.org 666876Ssteve.reinhardt@amd.com#include "mem/ruby/system/System.hh" 676876Ssteve.reinhardt@amd.com 686145Snate@binkert.org// Allows use of times() library call, which determines virtual runtime 696145Snate@binkert.org#include <sys/times.h> 706145Snate@binkert.org 716145Snate@binkert.orgextern std::ostream * debug_cout_ptr; 726145Snate@binkert.org 736145Snate@binkert.orgstatic double process_memory_total(); 746145Snate@binkert.orgstatic double process_memory_resident(); 756145Snate@binkert.org 766876Ssteve.reinhardt@amd.comProfiler::Profiler(const Params *p) 776876Ssteve.reinhardt@amd.com : SimObject(p) 786145Snate@binkert.org{ 796145Snate@binkert.org m_requestProfileMap_ptr = new Map<string, int>; 806145Snate@binkert.org 816285Snate@binkert.org m_inst_profiler_ptr = NULL; 826285Snate@binkert.org m_address_profiler_ptr = NULL; 836285Snate@binkert.org 846145Snate@binkert.org m_real_time_start_time = time(NULL); // Not reset in clearStats() 856145Snate@binkert.org m_stats_period = 1000000; // Default 866145Snate@binkert.org m_periodic_output_file_ptr = &cerr; 876145Snate@binkert.org 886876Ssteve.reinhardt@amd.com m_hot_lines = p->hot_lines; 896876Ssteve.reinhardt@amd.com m_all_instructions = p->all_instructions; 906876Ssteve.reinhardt@amd.com 916896SBrad.Beckmann@amd.com m_num_of_sequencers = p->num_of_sequencers; 926896SBrad.Beckmann@amd.com 936889SBrad.Beckmann@amd.com // 946889SBrad.Beckmann@amd.com // Initialize the memory controller profiler structs 956889SBrad.Beckmann@amd.com // 966889SBrad.Beckmann@amd.com m_mc_profilers.setSize(p->mem_cntrl_count); 976889SBrad.Beckmann@amd.com for (int mem_cntrl = 0; mem_cntrl < p->mem_cntrl_count; mem_cntrl++) { 986889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl] = new memory_control_profiler; 996889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memReq = 0; 1006889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankBusy = 0; 1016889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBusBusy = 0; 1026889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memReadWriteBusy = 0; 1036889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memDataBusBusy = 0; 1046889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memTfawBusy = 0; 1056889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRefresh = 0; 1066889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRead = 0; 1076889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memWrite = 0; 1086889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memWaitCycles = 0; 1096889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memInputQ = 0; 1106889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankQ = 0; 1116889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memArbWait = 0; 1126889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRandBusy = 0; 1136889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memNotOld = 0; 1146145Snate@binkert.org 1156889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_banks_per_rank = p->banks_per_rank; 1166889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_ranks_per_dimm = p->ranks_per_dimm; 1176889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_dimms_per_channel = 1186889SBrad.Beckmann@amd.com p->dimms_per_channel; 1196145Snate@binkert.org 1206889SBrad.Beckmann@amd.com int totalBanks = p->banks_per_rank * 1216889SBrad.Beckmann@amd.com p->ranks_per_dimm * 1226889SBrad.Beckmann@amd.com p->dimms_per_channel; 1236285Snate@binkert.org 1246889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankCount.setSize(totalBanks); 1256889SBrad.Beckmann@amd.com } 1266285Snate@binkert.org 1276285Snate@binkert.org m_hot_lines = false; 1286285Snate@binkert.org m_all_instructions = false; 1296285Snate@binkert.org 1306896SBrad.Beckmann@amd.com m_address_profiler_ptr = new AddressProfiler(m_num_of_sequencers); 1316285Snate@binkert.org m_address_profiler_ptr -> setHotLines(m_hot_lines); 1326285Snate@binkert.org m_address_profiler_ptr -> setAllInstructions(m_all_instructions); 1336285Snate@binkert.org 1346285Snate@binkert.org if (m_all_instructions) { 1356896SBrad.Beckmann@amd.com m_inst_profiler_ptr = new AddressProfiler(m_num_of_sequencers); 1366285Snate@binkert.org m_inst_profiler_ptr -> setHotLines(m_hot_lines); 1376285Snate@binkert.org m_inst_profiler_ptr -> setAllInstructions(m_all_instructions); 1386285Snate@binkert.org } 1396285Snate@binkert.org} 1406285Snate@binkert.org 1416889SBrad.Beckmann@amd.comProfiler::~Profiler() 1426889SBrad.Beckmann@amd.com{ 1436889SBrad.Beckmann@amd.com if (m_periodic_output_file_ptr != &cerr) { 1446889SBrad.Beckmann@amd.com delete m_periodic_output_file_ptr; 1456889SBrad.Beckmann@amd.com } 1466889SBrad.Beckmann@amd.com 1476889SBrad.Beckmann@amd.com for (int mem_cntrl = 0; 1486889SBrad.Beckmann@amd.com mem_cntrl < m_mc_profilers.size(); 1496889SBrad.Beckmann@amd.com mem_cntrl++) { 1506889SBrad.Beckmann@amd.com delete m_mc_profilers[mem_cntrl]; 1516889SBrad.Beckmann@amd.com } 1526889SBrad.Beckmann@amd.com 1536889SBrad.Beckmann@amd.com delete m_requestProfileMap_ptr; 1546889SBrad.Beckmann@amd.com} 1556889SBrad.Beckmann@amd.com 1566145Snate@binkert.orgvoid Profiler::wakeup() 1576145Snate@binkert.org{ 1586145Snate@binkert.org // FIXME - avoid the repeated code 1596145Snate@binkert.org 1606145Snate@binkert.org Vector<integer_t> perProcCycleCount; 1616896SBrad.Beckmann@amd.com perProcCycleCount.setSize(m_num_of_sequencers); 1626145Snate@binkert.org 1636896SBrad.Beckmann@amd.com for(int i=0; i < m_num_of_sequencers; i++) { 1646285Snate@binkert.org perProcCycleCount[i] = g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1; 1656145Snate@binkert.org // The +1 allows us to avoid division by zero 1666145Snate@binkert.org } 1676145Snate@binkert.org 1686145Snate@binkert.org integer_t total_misses = m_perProcTotalMisses.sum(); 1696285Snate@binkert.org integer_t simics_cycles_executed = perProcCycleCount.sum(); 1706145Snate@binkert.org integer_t transactions_started = m_perProcStartTransaction.sum(); 1716145Snate@binkert.org integer_t transactions_ended = m_perProcEndTransaction.sum(); 1726145Snate@binkert.org 1736889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "ruby_cycles: " 1746889SBrad.Beckmann@amd.com << g_eventQueue_ptr->getTime()-m_ruby_start 1756889SBrad.Beckmann@amd.com << endl; 1766889SBrad.Beckmann@amd.com 1776889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "total_misses: " 1786889SBrad.Beckmann@amd.com << total_misses 1796889SBrad.Beckmann@amd.com << " " 1806889SBrad.Beckmann@amd.com << m_perProcTotalMisses 1816889SBrad.Beckmann@amd.com << endl; 1826889SBrad.Beckmann@amd.com 1836889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "simics_cycles_executed: " 1846889SBrad.Beckmann@amd.com << simics_cycles_executed 1856889SBrad.Beckmann@amd.com << " " 1866889SBrad.Beckmann@amd.com << perProcCycleCount 1876889SBrad.Beckmann@amd.com << endl; 1886889SBrad.Beckmann@amd.com 1896889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "transactions_started: " 1906889SBrad.Beckmann@amd.com << transactions_started 1916889SBrad.Beckmann@amd.com << " " 1926889SBrad.Beckmann@amd.com << m_perProcStartTransaction 1936889SBrad.Beckmann@amd.com << endl; 1946889SBrad.Beckmann@amd.com 1956889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "transactions_ended: " 1966889SBrad.Beckmann@amd.com << transactions_ended 1976889SBrad.Beckmann@amd.com << " " 1986889SBrad.Beckmann@amd.com << m_perProcEndTransaction 1996889SBrad.Beckmann@amd.com << endl; 2006889SBrad.Beckmann@amd.com 2016889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "mbytes_resident: " 2026889SBrad.Beckmann@amd.com << process_memory_resident() 2036889SBrad.Beckmann@amd.com << endl; 2046889SBrad.Beckmann@amd.com 2056889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "mbytes_total: " 2066889SBrad.Beckmann@amd.com << process_memory_total() 2076889SBrad.Beckmann@amd.com << endl; 2086889SBrad.Beckmann@amd.com 2096145Snate@binkert.org if (process_memory_total() > 0) { 2106889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "resident_ratio: " 2116889SBrad.Beckmann@amd.com << process_memory_resident()/process_memory_total() 2126889SBrad.Beckmann@amd.com << endl; 2136145Snate@binkert.org } 2146889SBrad.Beckmann@amd.com 2156889SBrad.Beckmann@amd.com (*m_periodic_output_file_ptr) << "miss_latency: " 2166889SBrad.Beckmann@amd.com << m_allMissLatencyHistogram 2176889SBrad.Beckmann@amd.com << endl; 2186145Snate@binkert.org 2196145Snate@binkert.org *m_periodic_output_file_ptr << endl; 2206145Snate@binkert.org 2216285Snate@binkert.org if (m_all_instructions) { 2226145Snate@binkert.org m_inst_profiler_ptr->printStats(*m_periodic_output_file_ptr); 2236145Snate@binkert.org } 2246145Snate@binkert.org 2256145Snate@binkert.org //g_system_ptr->getNetwork()->printStats(*m_periodic_output_file_ptr); 2266145Snate@binkert.org g_eventQueue_ptr->scheduleEvent(this, m_stats_period); 2276145Snate@binkert.org} 2286145Snate@binkert.org 2296145Snate@binkert.orgvoid Profiler::setPeriodicStatsFile(const string& filename) 2306145Snate@binkert.org{ 2316145Snate@binkert.org cout << "Recording periodic statistics to file '" << filename << "' every " 2326145Snate@binkert.org << m_stats_period << " Ruby cycles" << endl; 2336145Snate@binkert.org 2346145Snate@binkert.org if (m_periodic_output_file_ptr != &cerr) { 2356145Snate@binkert.org delete m_periodic_output_file_ptr; 2366145Snate@binkert.org } 2376145Snate@binkert.org 2386145Snate@binkert.org m_periodic_output_file_ptr = new ofstream(filename.c_str()); 2396145Snate@binkert.org g_eventQueue_ptr->scheduleEvent(this, 1); 2406145Snate@binkert.org} 2416145Snate@binkert.org 2426145Snate@binkert.orgvoid Profiler::setPeriodicStatsInterval(integer_t period) 2436145Snate@binkert.org{ 2446889SBrad.Beckmann@amd.com cout << "Recording periodic statistics every " << m_stats_period 2456889SBrad.Beckmann@amd.com << " Ruby cycles" << endl; 2466889SBrad.Beckmann@amd.com 2476145Snate@binkert.org m_stats_period = period; 2486145Snate@binkert.org g_eventQueue_ptr->scheduleEvent(this, 1); 2496145Snate@binkert.org} 2506145Snate@binkert.org 2516145Snate@binkert.orgvoid Profiler::printConfig(ostream& out) const 2526145Snate@binkert.org{ 2536145Snate@binkert.org out << endl; 2546145Snate@binkert.org out << "Profiler Configuration" << endl; 2556145Snate@binkert.org out << "----------------------" << endl; 2566145Snate@binkert.org out << "periodic_stats_period: " << m_stats_period << endl; 2576145Snate@binkert.org} 2586145Snate@binkert.org 2596145Snate@binkert.orgvoid Profiler::print(ostream& out) const 2606145Snate@binkert.org{ 2616145Snate@binkert.org out << "[Profiler]"; 2626145Snate@binkert.org} 2636145Snate@binkert.org 2646145Snate@binkert.orgvoid Profiler::printStats(ostream& out, bool short_stats) 2656145Snate@binkert.org{ 2666145Snate@binkert.org out << endl; 2676145Snate@binkert.org if (short_stats) { 2686145Snate@binkert.org out << "SHORT "; 2696145Snate@binkert.org } 2706145Snate@binkert.org out << "Profiler Stats" << endl; 2716145Snate@binkert.org out << "--------------" << endl; 2726145Snate@binkert.org 2736145Snate@binkert.org time_t real_time_current = time(NULL); 2746145Snate@binkert.org double seconds = difftime(real_time_current, m_real_time_start_time); 2756145Snate@binkert.org double minutes = seconds/60.0; 2766145Snate@binkert.org double hours = minutes/60.0; 2776145Snate@binkert.org double days = hours/24.0; 2786145Snate@binkert.org Time ruby_cycles = g_eventQueue_ptr->getTime()-m_ruby_start; 2796145Snate@binkert.org 2806145Snate@binkert.org if (!short_stats) { 2816145Snate@binkert.org out << "Elapsed_time_in_seconds: " << seconds << endl; 2826145Snate@binkert.org out << "Elapsed_time_in_minutes: " << minutes << endl; 2836145Snate@binkert.org out << "Elapsed_time_in_hours: " << hours << endl; 2846145Snate@binkert.org out << "Elapsed_time_in_days: " << days << endl; 2856145Snate@binkert.org out << endl; 2866145Snate@binkert.org } 2876145Snate@binkert.org 2886145Snate@binkert.org // print the virtual runtimes as well 2896145Snate@binkert.org struct tms vtime; 2906145Snate@binkert.org times(&vtime); 2916145Snate@binkert.org seconds = (vtime.tms_utime + vtime.tms_stime) / 100.0; 2926145Snate@binkert.org minutes = seconds / 60.0; 2936145Snate@binkert.org hours = minutes / 60.0; 2946145Snate@binkert.org days = hours / 24.0; 2956145Snate@binkert.org out << "Virtual_time_in_seconds: " << seconds << endl; 2966145Snate@binkert.org out << "Virtual_time_in_minutes: " << minutes << endl; 2976145Snate@binkert.org out << "Virtual_time_in_hours: " << hours << endl; 2986433Sdrh5@cs.wisc.edu out << "Virtual_time_in_days: " << days << endl; 2996145Snate@binkert.org out << endl; 3006145Snate@binkert.org 3016145Snate@binkert.org out << "Ruby_current_time: " << g_eventQueue_ptr->getTime() << endl; 3026145Snate@binkert.org out << "Ruby_start_time: " << m_ruby_start << endl; 3036145Snate@binkert.org out << "Ruby_cycles: " << ruby_cycles << endl; 3046145Snate@binkert.org out << endl; 3056145Snate@binkert.org 3066145Snate@binkert.org if (!short_stats) { 3076145Snate@binkert.org out << "mbytes_resident: " << process_memory_resident() << endl; 3086145Snate@binkert.org out << "mbytes_total: " << process_memory_total() << endl; 3096145Snate@binkert.org if (process_memory_total() > 0) { 3106889SBrad.Beckmann@amd.com out << "resident_ratio: " 3116889SBrad.Beckmann@amd.com << process_memory_resident()/process_memory_total() << endl; 3126145Snate@binkert.org } 3136145Snate@binkert.org out << endl; 3146145Snate@binkert.org 3156145Snate@binkert.org } 3166145Snate@binkert.org 3176145Snate@binkert.org Vector<integer_t> perProcCycleCount; 3186145Snate@binkert.org Vector<double> perProcCyclesPerTrans; 3196145Snate@binkert.org Vector<double> perProcMissesPerTrans; 3206145Snate@binkert.org 3216433Sdrh5@cs.wisc.edu 3226896SBrad.Beckmann@amd.com perProcCycleCount.setSize(m_num_of_sequencers); 3236896SBrad.Beckmann@amd.com perProcCyclesPerTrans.setSize(m_num_of_sequencers); 3246896SBrad.Beckmann@amd.com perProcMissesPerTrans.setSize(m_num_of_sequencers); 3256145Snate@binkert.org 3266896SBrad.Beckmann@amd.com for(int i=0; i < m_num_of_sequencers; i++) { 3276285Snate@binkert.org perProcCycleCount[i] = g_system_ptr->getCycleCount(i) - m_cycles_executed_at_start[i] + 1; 3286145Snate@binkert.org // The +1 allows us to avoid division by zero 3296145Snate@binkert.org 3306145Snate@binkert.org int trans = m_perProcEndTransaction[i]; 3316145Snate@binkert.org if (trans == 0) { 3326145Snate@binkert.org perProcCyclesPerTrans[i] = 0; 3336145Snate@binkert.org perProcMissesPerTrans[i] = 0; 3346145Snate@binkert.org } else { 3356145Snate@binkert.org perProcCyclesPerTrans[i] = ruby_cycles / double(trans); 3366145Snate@binkert.org perProcMissesPerTrans[i] = m_perProcTotalMisses[i] / double(trans); 3376145Snate@binkert.org } 3386145Snate@binkert.org } 3396145Snate@binkert.org 3406145Snate@binkert.org integer_t total_misses = m_perProcTotalMisses.sum(); 3416145Snate@binkert.org integer_t user_misses = m_perProcUserMisses.sum(); 3426145Snate@binkert.org integer_t supervisor_misses = m_perProcSupervisorMisses.sum(); 3436285Snate@binkert.org integer_t simics_cycles_executed = perProcCycleCount.sum(); 3446145Snate@binkert.org integer_t transactions_started = m_perProcStartTransaction.sum(); 3456145Snate@binkert.org integer_t transactions_ended = m_perProcEndTransaction.sum(); 3466145Snate@binkert.org 3476896SBrad.Beckmann@amd.com double cycles_per_transaction = (transactions_ended != 0) ? (m_num_of_sequencers * double(ruby_cycles)) / double(transactions_ended) : 0; 3486145Snate@binkert.org double misses_per_transaction = (transactions_ended != 0) ? double(total_misses) / double(transactions_ended) : 0; 3496145Snate@binkert.org 3506145Snate@binkert.org out << "Total_misses: " << total_misses << endl; 3516145Snate@binkert.org out << "total_misses: " << total_misses << " " << m_perProcTotalMisses << endl; 3526145Snate@binkert.org out << "user_misses: " << user_misses << " " << m_perProcUserMisses << endl; 3536145Snate@binkert.org out << "supervisor_misses: " << supervisor_misses << " " << m_perProcSupervisorMisses << endl; 3546145Snate@binkert.org out << endl; 3556285Snate@binkert.org out << "ruby_cycles_executed: " << simics_cycles_executed << " " << perProcCycleCount << endl; 3566145Snate@binkert.org out << endl; 3576145Snate@binkert.org out << "transactions_started: " << transactions_started << " " << m_perProcStartTransaction << endl; 3586145Snate@binkert.org out << "transactions_ended: " << transactions_ended << " " << m_perProcEndTransaction << endl; 3596145Snate@binkert.org out << "cycles_per_transaction: " << cycles_per_transaction << " " << perProcCyclesPerTrans << endl; 3606145Snate@binkert.org out << "misses_per_transaction: " << misses_per_transaction << " " << perProcMissesPerTrans << endl; 3616145Snate@binkert.org 3626145Snate@binkert.org out << endl; 3636145Snate@binkert.org 3646145Snate@binkert.org out << endl; 3656145Snate@binkert.org 3666889SBrad.Beckmann@amd.com for (int mem_cntrl = 0; 3676889SBrad.Beckmann@amd.com mem_cntrl < m_mc_profilers.size(); 3686889SBrad.Beckmann@amd.com mem_cntrl++) { 3696889SBrad.Beckmann@amd.com uint64 m_memReq = m_mc_profilers[mem_cntrl]->m_memReq; 3706889SBrad.Beckmann@amd.com uint64 m_memRefresh = m_mc_profilers[mem_cntrl]->m_memRefresh; 3716889SBrad.Beckmann@amd.com uint64 m_memInputQ = m_mc_profilers[mem_cntrl]->m_memInputQ; 3726889SBrad.Beckmann@amd.com uint64 m_memBankQ = m_mc_profilers[mem_cntrl]->m_memBankQ; 3736889SBrad.Beckmann@amd.com uint64 m_memWaitCycles = m_mc_profilers[mem_cntrl]->m_memWaitCycles; 3746889SBrad.Beckmann@amd.com uint64 m_memRead = m_mc_profilers[mem_cntrl]->m_memRead; 3756889SBrad.Beckmann@amd.com uint64 m_memWrite = m_mc_profilers[mem_cntrl]->m_memWrite; 3766889SBrad.Beckmann@amd.com uint64 m_memBankBusy = m_mc_profilers[mem_cntrl]->m_memBankBusy; 3776889SBrad.Beckmann@amd.com uint64 m_memRandBusy = m_mc_profilers[mem_cntrl]->m_memRandBusy; 3786889SBrad.Beckmann@amd.com uint64 m_memNotOld = m_mc_profilers[mem_cntrl]->m_memNotOld; 3796889SBrad.Beckmann@amd.com uint64 m_memArbWait = m_mc_profilers[mem_cntrl]->m_memArbWait; 3806889SBrad.Beckmann@amd.com uint64 m_memBusBusy = m_mc_profilers[mem_cntrl]->m_memBusBusy; 3816889SBrad.Beckmann@amd.com uint64 m_memTfawBusy = m_mc_profilers[mem_cntrl]->m_memTfawBusy; 3826889SBrad.Beckmann@amd.com uint64 m_memReadWriteBusy = m_mc_profilers[mem_cntrl]->m_memReadWriteBusy; 3836889SBrad.Beckmann@amd.com uint64 m_memDataBusBusy = m_mc_profilers[mem_cntrl]->m_memDataBusBusy; 3846889SBrad.Beckmann@amd.com Vector<uint64> m_memBankCount = m_mc_profilers[mem_cntrl]->m_memBankCount; 3856285Snate@binkert.org 3866285Snate@binkert.org if (m_memReq || m_memRefresh) { // if there's a memory controller at all 3876889SBrad.Beckmann@amd.com uint64 total_stalls = m_memInputQ + m_memBankQ + m_memWaitCycles; 3886285Snate@binkert.org double stallsPerReq = total_stalls * 1.0 / m_memReq; 3896889SBrad.Beckmann@amd.com out << "Memory control " << mem_cntrl << ":" << endl; 3906285Snate@binkert.org out << " memory_total_requests: " << m_memReq << endl; // does not include refreshes 3916285Snate@binkert.org out << " memory_reads: " << m_memRead << endl; 3926285Snate@binkert.org out << " memory_writes: " << m_memWrite << endl; 3936285Snate@binkert.org out << " memory_refreshes: " << m_memRefresh << endl; 3946285Snate@binkert.org out << " memory_total_request_delays: " << total_stalls << endl; 3956285Snate@binkert.org out << " memory_delays_per_request: " << stallsPerReq << endl; 3966285Snate@binkert.org out << " memory_delays_in_input_queue: " << m_memInputQ << endl; 3976285Snate@binkert.org out << " memory_delays_behind_head_of_bank_queue: " << m_memBankQ << endl; 3986285Snate@binkert.org out << " memory_delays_stalled_at_head_of_bank_queue: " << m_memWaitCycles << endl; 3996285Snate@binkert.org // Note: The following "memory stalls" entries are a breakdown of the 4006285Snate@binkert.org // cycles which already showed up in m_memWaitCycles. The order is 4016285Snate@binkert.org // significant; it is the priority of attributing the cycles. 4026285Snate@binkert.org // For example, bank_busy is before arbitration because if the bank was 4036285Snate@binkert.org // busy, we didn't even check arbitration. 4046285Snate@binkert.org // Note: "not old enough" means that since we grouped waiting heads-of-queues 4056285Snate@binkert.org // into batches to avoid starvation, a request in a newer batch 4066285Snate@binkert.org // didn't try to arbitrate yet because there are older requests waiting. 4076285Snate@binkert.org out << " memory_stalls_for_bank_busy: " << m_memBankBusy << endl; 4086285Snate@binkert.org out << " memory_stalls_for_random_busy: " << m_memRandBusy << endl; 4096285Snate@binkert.org out << " memory_stalls_for_anti_starvation: " << m_memNotOld << endl; 4106285Snate@binkert.org out << " memory_stalls_for_arbitration: " << m_memArbWait << endl; 4116285Snate@binkert.org out << " memory_stalls_for_bus: " << m_memBusBusy << endl; 4126285Snate@binkert.org out << " memory_stalls_for_tfaw: " << m_memTfawBusy << endl; 4136285Snate@binkert.org out << " memory_stalls_for_read_write_turnaround: " << m_memReadWriteBusy << endl; 4146285Snate@binkert.org out << " memory_stalls_for_read_read_turnaround: " << m_memDataBusBusy << endl; 4156285Snate@binkert.org out << " accesses_per_bank: "; 4166285Snate@binkert.org for (int bank=0; bank < m_memBankCount.size(); bank++) { 4176285Snate@binkert.org out << m_memBankCount[bank] << " "; 4186285Snate@binkert.org //if ((bank % 8) == 7) out << " " << endl; 4196285Snate@binkert.org } 4206285Snate@binkert.org out << endl; 4216285Snate@binkert.org out << endl; 4226145Snate@binkert.org } 4236145Snate@binkert.org } 4246145Snate@binkert.org if (!short_stats) { 4256145Snate@binkert.org out << "Busy Controller Counts:" << endl; 4266145Snate@binkert.org for(int i=0; i < MachineType_NUM; i++) { 4276145Snate@binkert.org for(int j=0; j < MachineType_base_count((MachineType)i); j++) { 4286145Snate@binkert.org MachineID machID; 4296145Snate@binkert.org machID.type = (MachineType)i; 4306145Snate@binkert.org machID.num = j; 4316145Snate@binkert.org out << machID << ":" << m_busyControllerCount[i][j] << " "; 4326145Snate@binkert.org if ((j+1)%8 == 0) { 4336145Snate@binkert.org out << endl; 4346145Snate@binkert.org } 4356145Snate@binkert.org } 4366145Snate@binkert.org out << endl; 4376145Snate@binkert.org } 4386145Snate@binkert.org out << endl; 4396145Snate@binkert.org 4406145Snate@binkert.org out << "Busy Bank Count:" << m_busyBankCount << endl; 4416145Snate@binkert.org out << endl; 4426145Snate@binkert.org 4436145Snate@binkert.org out << "sequencer_requests_outstanding: " << m_sequencer_requests << endl; 4446145Snate@binkert.org out << endl; 4456145Snate@binkert.org } 4466145Snate@binkert.org 4476145Snate@binkert.org if (!short_stats) { 4486145Snate@binkert.org out << "All Non-Zero Cycle Demand Cache Accesses" << endl; 4496145Snate@binkert.org out << "----------------------------------------" << endl; 4506145Snate@binkert.org out << "miss_latency: " << m_allMissLatencyHistogram << endl; 4516145Snate@binkert.org for(int i=0; i<m_missLatencyHistograms.size(); i++) { 4526145Snate@binkert.org if (m_missLatencyHistograms[i].size() > 0) { 4536285Snate@binkert.org out << "miss_latency_" << RubyRequestType(i) << ": " << m_missLatencyHistograms[i] << endl; 4546145Snate@binkert.org } 4556145Snate@binkert.org } 4566145Snate@binkert.org for(int i=0; i<m_machLatencyHistograms.size(); i++) { 4576145Snate@binkert.org if (m_machLatencyHistograms[i].size() > 0) { 4586145Snate@binkert.org out << "miss_latency_" << GenericMachineType(i) << ": " << m_machLatencyHistograms[i] << endl; 4596145Snate@binkert.org } 4606145Snate@binkert.org } 4616145Snate@binkert.org 4626145Snate@binkert.org out << endl; 4636145Snate@binkert.org 4646145Snate@binkert.org out << "All Non-Zero Cycle SW Prefetch Requests" << endl; 4656145Snate@binkert.org out << "------------------------------------" << endl; 4666145Snate@binkert.org out << "prefetch_latency: " << m_allSWPrefetchLatencyHistogram << endl; 4676145Snate@binkert.org for(int i=0; i<m_SWPrefetchLatencyHistograms.size(); i++) { 4686145Snate@binkert.org if (m_SWPrefetchLatencyHistograms[i].size() > 0) { 4696145Snate@binkert.org out << "prefetch_latency_" << CacheRequestType(i) << ": " << m_SWPrefetchLatencyHistograms[i] << endl; 4706145Snate@binkert.org } 4716145Snate@binkert.org } 4726145Snate@binkert.org for(int i=0; i<m_SWPrefetchMachLatencyHistograms.size(); i++) { 4736145Snate@binkert.org if (m_SWPrefetchMachLatencyHistograms[i].size() > 0) { 4746145Snate@binkert.org out << "prefetch_latency_" << GenericMachineType(i) << ": " << m_SWPrefetchMachLatencyHistograms[i] << endl; 4756145Snate@binkert.org } 4766145Snate@binkert.org } 4776145Snate@binkert.org out << "prefetch_latency_L2Miss:" << m_SWPrefetchL2MissLatencyHistogram << endl; 4786145Snate@binkert.org 4796145Snate@binkert.org if (m_all_sharing_histogram.size() > 0) { 4806145Snate@binkert.org out << "all_sharing: " << m_all_sharing_histogram << endl; 4816145Snate@binkert.org out << "read_sharing: " << m_read_sharing_histogram << endl; 4826145Snate@binkert.org out << "write_sharing: " << m_write_sharing_histogram << endl; 4836145Snate@binkert.org 4846145Snate@binkert.org out << "all_sharing_percent: "; m_all_sharing_histogram.printPercent(out); out << endl; 4856145Snate@binkert.org out << "read_sharing_percent: "; m_read_sharing_histogram.printPercent(out); out << endl; 4866145Snate@binkert.org out << "write_sharing_percent: "; m_write_sharing_histogram.printPercent(out); out << endl; 4876145Snate@binkert.org 4886145Snate@binkert.org int64 total_miss = m_cache_to_cache + m_memory_to_cache; 4896145Snate@binkert.org out << "all_misses: " << total_miss << endl; 4906145Snate@binkert.org out << "cache_to_cache_misses: " << m_cache_to_cache << endl; 4916145Snate@binkert.org out << "memory_to_cache_misses: " << m_memory_to_cache << endl; 4926145Snate@binkert.org out << "cache_to_cache_percent: " << 100.0 * (double(m_cache_to_cache) / double(total_miss)) << endl; 4936145Snate@binkert.org out << "memory_to_cache_percent: " << 100.0 * (double(m_memory_to_cache) / double(total_miss)) << endl; 4946145Snate@binkert.org out << endl; 4956145Snate@binkert.org } 4966145Snate@binkert.org 4976145Snate@binkert.org if (m_outstanding_requests.size() > 0) { 4986145Snate@binkert.org out << "outstanding_requests: "; m_outstanding_requests.printPercent(out); out << endl; 4996145Snate@binkert.org out << endl; 5006145Snate@binkert.org } 5016145Snate@binkert.org } 5026145Snate@binkert.org 5036145Snate@binkert.org if (!short_stats) { 5046148Ssanchezd@stanford.edu out << "Request vs. RubySystem State Profile" << endl; 5056145Snate@binkert.org out << "--------------------------------" << endl; 5066145Snate@binkert.org out << endl; 5076145Snate@binkert.org 5086145Snate@binkert.org Vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys(); 5096145Snate@binkert.org requestProfileKeys.sortVector(); 5106145Snate@binkert.org 5116145Snate@binkert.org for(int i=0; i<requestProfileKeys.size(); i++) { 5126145Snate@binkert.org int temp_int = m_requestProfileMap_ptr->lookup(requestProfileKeys[i]); 5136145Snate@binkert.org double percent = (100.0*double(temp_int))/double(m_requests); 5146145Snate@binkert.org while (requestProfileKeys[i] != "") { 5156145Snate@binkert.org out << setw(10) << string_split(requestProfileKeys[i], ':'); 5166145Snate@binkert.org } 5176145Snate@binkert.org out << setw(11) << temp_int; 5186145Snate@binkert.org out << setw(14) << percent << endl; 5196145Snate@binkert.org } 5206145Snate@binkert.org out << endl; 5216145Snate@binkert.org 5226145Snate@binkert.org out << "filter_action: " << m_filter_action_histogram << endl; 5236145Snate@binkert.org 5246285Snate@binkert.org if (!m_all_instructions) { 5256145Snate@binkert.org m_address_profiler_ptr->printStats(out); 5266145Snate@binkert.org } 5276145Snate@binkert.org 5286285Snate@binkert.org if (m_all_instructions) { 5296145Snate@binkert.org m_inst_profiler_ptr->printStats(out); 5306145Snate@binkert.org } 5316145Snate@binkert.org 5326145Snate@binkert.org out << endl; 5336145Snate@binkert.org out << "Message Delayed Cycles" << endl; 5346145Snate@binkert.org out << "----------------------" << endl; 5356145Snate@binkert.org out << "Total_delay_cycles: " << m_delayedCyclesHistogram << endl; 5366145Snate@binkert.org out << "Total_nonPF_delay_cycles: " << m_delayedCyclesNonPFHistogram << endl; 5376145Snate@binkert.org for (int i = 0; i < m_delayedCyclesVCHistograms.size(); i++) { 5386145Snate@binkert.org out << " virtual_network_" << i << "_delay_cycles: " << m_delayedCyclesVCHistograms[i] << endl; 5396145Snate@binkert.org } 5406145Snate@binkert.org 5416145Snate@binkert.org printResourceUsage(out); 5426145Snate@binkert.org } 5436145Snate@binkert.org 5446145Snate@binkert.org} 5456145Snate@binkert.org 5466145Snate@binkert.orgvoid Profiler::printResourceUsage(ostream& out) const 5476145Snate@binkert.org{ 5486145Snate@binkert.org out << endl; 5496145Snate@binkert.org out << "Resource Usage" << endl; 5506145Snate@binkert.org out << "--------------" << endl; 5516145Snate@binkert.org 5526145Snate@binkert.org integer_t pagesize = getpagesize(); // page size in bytes 5536145Snate@binkert.org out << "page_size: " << pagesize << endl; 5546145Snate@binkert.org 5556145Snate@binkert.org rusage usage; 5566145Snate@binkert.org getrusage (RUSAGE_SELF, &usage); 5576145Snate@binkert.org 5586145Snate@binkert.org out << "user_time: " << usage.ru_utime.tv_sec << endl; 5596145Snate@binkert.org out << "system_time: " << usage.ru_stime.tv_sec << endl; 5606145Snate@binkert.org out << "page_reclaims: " << usage.ru_minflt << endl; 5616145Snate@binkert.org out << "page_faults: " << usage.ru_majflt << endl; 5626145Snate@binkert.org out << "swaps: " << usage.ru_nswap << endl; 5636145Snate@binkert.org out << "block_inputs: " << usage.ru_inblock << endl; 5646145Snate@binkert.org out << "block_outputs: " << usage.ru_oublock << endl; 5656145Snate@binkert.org} 5666145Snate@binkert.org 5676145Snate@binkert.orgvoid Profiler::clearStats() 5686145Snate@binkert.org{ 5696145Snate@binkert.org m_ruby_start = g_eventQueue_ptr->getTime(); 5706145Snate@binkert.org 5716896SBrad.Beckmann@amd.com m_cycles_executed_at_start.setSize(m_num_of_sequencers); 5726896SBrad.Beckmann@amd.com for (int i=0; i < m_num_of_sequencers; i++) { 5736145Snate@binkert.org if (g_system_ptr == NULL) { 5746145Snate@binkert.org m_cycles_executed_at_start[i] = 0; 5756145Snate@binkert.org } else { 5766285Snate@binkert.org m_cycles_executed_at_start[i] = g_system_ptr->getCycleCount(i); 5776145Snate@binkert.org } 5786145Snate@binkert.org } 5796145Snate@binkert.org 5806896SBrad.Beckmann@amd.com m_perProcTotalMisses.setSize(m_num_of_sequencers); 5816896SBrad.Beckmann@amd.com m_perProcUserMisses.setSize(m_num_of_sequencers); 5826896SBrad.Beckmann@amd.com m_perProcSupervisorMisses.setSize(m_num_of_sequencers); 5836896SBrad.Beckmann@amd.com m_perProcStartTransaction.setSize(m_num_of_sequencers); 5846896SBrad.Beckmann@amd.com m_perProcEndTransaction.setSize(m_num_of_sequencers); 5856145Snate@binkert.org 5866896SBrad.Beckmann@amd.com for(int i=0; i < m_num_of_sequencers; i++) { 5876145Snate@binkert.org m_perProcTotalMisses[i] = 0; 5886145Snate@binkert.org m_perProcUserMisses[i] = 0; 5896145Snate@binkert.org m_perProcSupervisorMisses[i] = 0; 5906145Snate@binkert.org m_perProcStartTransaction[i] = 0; 5916145Snate@binkert.org m_perProcEndTransaction[i] = 0; 5926145Snate@binkert.org } 5936145Snate@binkert.org 5946145Snate@binkert.org m_busyControllerCount.setSize(MachineType_NUM); // all machines 5956145Snate@binkert.org for(int i=0; i < MachineType_NUM; i++) { 5966145Snate@binkert.org m_busyControllerCount[i].setSize(MachineType_base_count((MachineType)i)); 5976145Snate@binkert.org for(int j=0; j < MachineType_base_count((MachineType)i); j++) { 5986145Snate@binkert.org m_busyControllerCount[i][j] = 0; 5996145Snate@binkert.org } 6006145Snate@binkert.org } 6016145Snate@binkert.org m_busyBankCount = 0; 6026145Snate@binkert.org 6036145Snate@binkert.org m_delayedCyclesHistogram.clear(); 6046145Snate@binkert.org m_delayedCyclesNonPFHistogram.clear(); 6056285Snate@binkert.org m_delayedCyclesVCHistograms.setSize(RubySystem::getNetwork()->getNumberOfVirtualNetworks()); 6066285Snate@binkert.org for (int i = 0; i < RubySystem::getNetwork()->getNumberOfVirtualNetworks(); i++) { 6076145Snate@binkert.org m_delayedCyclesVCHistograms[i].clear(); 6086145Snate@binkert.org } 6096145Snate@binkert.org 6106433Sdrh5@cs.wisc.edu m_missLatencyHistograms.setSize(RubyRequestType_NUM); 6116145Snate@binkert.org for(int i=0; i<m_missLatencyHistograms.size(); i++) { 6126145Snate@binkert.org m_missLatencyHistograms[i].clear(200); 6136145Snate@binkert.org } 6146145Snate@binkert.org m_machLatencyHistograms.setSize(GenericMachineType_NUM+1); 6156145Snate@binkert.org for(int i=0; i<m_machLatencyHistograms.size(); i++) { 6166145Snate@binkert.org m_machLatencyHistograms[i].clear(200); 6176145Snate@binkert.org } 6186145Snate@binkert.org m_allMissLatencyHistogram.clear(200); 6196145Snate@binkert.org 6206145Snate@binkert.org m_SWPrefetchLatencyHistograms.setSize(CacheRequestType_NUM); 6216145Snate@binkert.org for(int i=0; i<m_SWPrefetchLatencyHistograms.size(); i++) { 6226145Snate@binkert.org m_SWPrefetchLatencyHistograms[i].clear(200); 6236145Snate@binkert.org } 6246145Snate@binkert.org m_SWPrefetchMachLatencyHistograms.setSize(GenericMachineType_NUM+1); 6256145Snate@binkert.org for(int i=0; i<m_SWPrefetchMachLatencyHistograms.size(); i++) { 6266145Snate@binkert.org m_SWPrefetchMachLatencyHistograms[i].clear(200); 6276145Snate@binkert.org } 6286145Snate@binkert.org m_allSWPrefetchLatencyHistogram.clear(200); 6296145Snate@binkert.org 6306145Snate@binkert.org m_sequencer_requests.clear(); 6316145Snate@binkert.org m_read_sharing_histogram.clear(); 6326145Snate@binkert.org m_write_sharing_histogram.clear(); 6336145Snate@binkert.org m_all_sharing_histogram.clear(); 6346145Snate@binkert.org m_cache_to_cache = 0; 6356145Snate@binkert.org m_memory_to_cache = 0; 6366145Snate@binkert.org 6376145Snate@binkert.org // clear HashMaps 6386145Snate@binkert.org m_requestProfileMap_ptr->clear(); 6396145Snate@binkert.org 6406145Snate@binkert.org // count requests profiled 6416145Snate@binkert.org m_requests = 0; 6426145Snate@binkert.org 6436145Snate@binkert.org m_outstanding_requests.clear(); 6446145Snate@binkert.org m_outstanding_persistent_requests.clear(); 6456145Snate@binkert.org 6466285Snate@binkert.org//added by SS 6476285Snate@binkert.org vector<string>::iterator it; 6486145Snate@binkert.org 6496889SBrad.Beckmann@amd.com for (int mem_cntrl = 0; 6506889SBrad.Beckmann@amd.com mem_cntrl < m_mc_profilers.size(); 6516889SBrad.Beckmann@amd.com mem_cntrl++) { 6526889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memReq = 0; 6536889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankBusy = 0; 6546889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBusBusy = 0; 6556889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memTfawBusy = 0; 6566889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memReadWriteBusy = 0; 6576889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memDataBusBusy = 0; 6586889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRefresh = 0; 6596889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRead = 0; 6606889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memWrite = 0; 6616889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memWaitCycles = 0; 6626889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memInputQ = 0; 6636889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankQ = 0; 6646889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memArbWait = 0; 6656889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRandBusy = 0; 6666889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memNotOld = 0; 6676285Snate@binkert.org 6686889SBrad.Beckmann@amd.com for (int bank=0; 6696889SBrad.Beckmann@amd.com bank < m_mc_profilers[mem_cntrl]->m_memBankCount.size(); 6706889SBrad.Beckmann@amd.com bank++) { 6716889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankCount[bank] = 0; 6726285Snate@binkert.org } 6736285Snate@binkert.org } 6746145Snate@binkert.org // Flush the prefetches through the system - used so that there are no outstanding requests after stats are cleared 6756145Snate@binkert.org //g_eventQueue_ptr->triggerAllEvents(); 6766145Snate@binkert.org 6776145Snate@binkert.org // update the start time 6786145Snate@binkert.org m_ruby_start = g_eventQueue_ptr->getTime(); 6796145Snate@binkert.org} 6806145Snate@binkert.org 6816145Snate@binkert.orgvoid Profiler::addAddressTraceSample(const CacheMsg& msg, NodeID id) 6826145Snate@binkert.org{ 6836145Snate@binkert.org if (msg.getType() != CacheRequestType_IFETCH) { 6846145Snate@binkert.org 6856145Snate@binkert.org // Note: The following line should be commented out if you want to 6866145Snate@binkert.org // use the special profiling that is part of the GS320 protocol 6876145Snate@binkert.org 6886372Sdrh5@cs.wisc.edu // NOTE: Unless PROFILE_HOT_LINES is enabled, nothing will be profiled by the AddressProfiler 6896285Snate@binkert.org m_address_profiler_ptr->addTraceSample(msg.getLineAddress(), msg.getProgramCounter(), msg.getType(), msg.getAccessMode(), id, false); 6906145Snate@binkert.org } 6916145Snate@binkert.org} 6926145Snate@binkert.org 6936145Snate@binkert.orgvoid Profiler::profileSharing(const Address& addr, AccessType type, NodeID requestor, const Set& sharers, const Set& owner) 6946145Snate@binkert.org{ 6956145Snate@binkert.org Set set_contacted(owner); 6966145Snate@binkert.org if (type == AccessType_Write) { 6976145Snate@binkert.org set_contacted.addSet(sharers); 6986145Snate@binkert.org } 6996145Snate@binkert.org set_contacted.remove(requestor); 7006145Snate@binkert.org int number_contacted = set_contacted.count(); 7016145Snate@binkert.org 7026145Snate@binkert.org if (type == AccessType_Write) { 7036145Snate@binkert.org m_write_sharing_histogram.add(number_contacted); 7046145Snate@binkert.org } else { 7056145Snate@binkert.org m_read_sharing_histogram.add(number_contacted); 7066145Snate@binkert.org } 7076145Snate@binkert.org m_all_sharing_histogram.add(number_contacted); 7086145Snate@binkert.org 7096145Snate@binkert.org if (number_contacted == 0) { 7106145Snate@binkert.org m_memory_to_cache++; 7116145Snate@binkert.org } else { 7126145Snate@binkert.org m_cache_to_cache++; 7136145Snate@binkert.org } 7146145Snate@binkert.org 7156145Snate@binkert.org} 7166145Snate@binkert.org 7176145Snate@binkert.orgvoid Profiler::profileMsgDelay(int virtualNetwork, int delayCycles) { 7186145Snate@binkert.org assert(virtualNetwork < m_delayedCyclesVCHistograms.size()); 7196145Snate@binkert.org m_delayedCyclesHistogram.add(delayCycles); 7206145Snate@binkert.org m_delayedCyclesVCHistograms[virtualNetwork].add(delayCycles); 7216145Snate@binkert.org if (virtualNetwork != 0) { 7226145Snate@binkert.org m_delayedCyclesNonPFHistogram.add(delayCycles); 7236145Snate@binkert.org } 7246145Snate@binkert.org} 7256145Snate@binkert.org 7266145Snate@binkert.org// profiles original cache requests including PUTs 7276145Snate@binkert.orgvoid Profiler::profileRequest(const string& requestStr) 7286145Snate@binkert.org{ 7296145Snate@binkert.org m_requests++; 7306145Snate@binkert.org 7316145Snate@binkert.org if (m_requestProfileMap_ptr->exist(requestStr)) { 7326145Snate@binkert.org (m_requestProfileMap_ptr->lookup(requestStr))++; 7336145Snate@binkert.org } else { 7346145Snate@binkert.org m_requestProfileMap_ptr->add(requestStr, 1); 7356145Snate@binkert.org } 7366145Snate@binkert.org} 7376145Snate@binkert.org 7386145Snate@binkert.orgvoid Profiler::startTransaction(int cpu) 7396145Snate@binkert.org{ 7406145Snate@binkert.org m_perProcStartTransaction[cpu]++; 7416145Snate@binkert.org} 7426145Snate@binkert.org 7436145Snate@binkert.orgvoid Profiler::endTransaction(int cpu) 7446145Snate@binkert.org{ 7456145Snate@binkert.org m_perProcEndTransaction[cpu]++; 7466145Snate@binkert.org} 7476145Snate@binkert.org 7486145Snate@binkert.orgvoid Profiler::controllerBusy(MachineID machID) 7496145Snate@binkert.org{ 7506145Snate@binkert.org m_busyControllerCount[(int)machID.type][(int)machID.num]++; 7516145Snate@binkert.org} 7526145Snate@binkert.org 7536145Snate@binkert.orgvoid Profiler::profilePFWait(Time waitTime) 7546145Snate@binkert.org{ 7556145Snate@binkert.org m_prefetchWaitHistogram.add(waitTime); 7566145Snate@binkert.org} 7576145Snate@binkert.org 7586145Snate@binkert.orgvoid Profiler::bankBusy() 7596145Snate@binkert.org{ 7606145Snate@binkert.org m_busyBankCount++; 7616145Snate@binkert.org} 7626145Snate@binkert.org 7636145Snate@binkert.org// non-zero cycle demand request 7646285Snate@binkert.orgvoid Profiler::missLatency(Time t, RubyRequestType type) 7656145Snate@binkert.org{ 7666145Snate@binkert.org m_allMissLatencyHistogram.add(t); 7676145Snate@binkert.org m_missLatencyHistograms[type].add(t); 7686145Snate@binkert.org} 7696145Snate@binkert.org 7706145Snate@binkert.org// non-zero cycle prefetch request 7716145Snate@binkert.orgvoid Profiler::swPrefetchLatency(Time t, CacheRequestType type, GenericMachineType respondingMach) 7726145Snate@binkert.org{ 7736145Snate@binkert.org m_allSWPrefetchLatencyHistogram.add(t); 7746145Snate@binkert.org m_SWPrefetchLatencyHistograms[type].add(t); 7756145Snate@binkert.org m_SWPrefetchMachLatencyHistograms[respondingMach].add(t); 7766145Snate@binkert.org if(respondingMach == GenericMachineType_Directory || respondingMach == GenericMachineType_NUM) { 7776145Snate@binkert.org m_SWPrefetchL2MissLatencyHistogram.add(t); 7786145Snate@binkert.org } 7796145Snate@binkert.org} 7806145Snate@binkert.org 7816285Snate@binkert.orgvoid Profiler::profileTransition(const string& component, NodeID version, Address addr, 7826145Snate@binkert.org const string& state, const string& event, 7836145Snate@binkert.org const string& next_state, const string& note) 7846145Snate@binkert.org{ 7856145Snate@binkert.org const int EVENT_SPACES = 20; 7866145Snate@binkert.org const int ID_SPACES = 3; 7876145Snate@binkert.org const int TIME_SPACES = 7; 7886145Snate@binkert.org const int COMP_SPACES = 10; 7896145Snate@binkert.org const int STATE_SPACES = 6; 7906145Snate@binkert.org 7916145Snate@binkert.org if ((g_debug_ptr->getDebugTime() > 0) && 7926145Snate@binkert.org (g_eventQueue_ptr->getTime() >= g_debug_ptr->getDebugTime())) { 7936145Snate@binkert.org (* debug_cout_ptr).flags(ios::right); 7946145Snate@binkert.org (* debug_cout_ptr) << setw(TIME_SPACES) << g_eventQueue_ptr->getTime() << " "; 7956145Snate@binkert.org (* debug_cout_ptr) << setw(ID_SPACES) << version << " "; 7966145Snate@binkert.org (* debug_cout_ptr) << setw(COMP_SPACES) << component; 7976145Snate@binkert.org (* debug_cout_ptr) << setw(EVENT_SPACES) << event << " "; 7986145Snate@binkert.org 7996285Snate@binkert.org (* debug_cout_ptr).flags(ios::right); 8006285Snate@binkert.org (* debug_cout_ptr) << setw(STATE_SPACES) << state; 8016285Snate@binkert.org (* debug_cout_ptr) << ">"; 8026285Snate@binkert.org (* debug_cout_ptr).flags(ios::left); 8036285Snate@binkert.org (* debug_cout_ptr) << setw(STATE_SPACES) << next_state; 8046285Snate@binkert.org 8056145Snate@binkert.org (* debug_cout_ptr) << " " << addr << " " << note; 8066145Snate@binkert.org 8076145Snate@binkert.org (* debug_cout_ptr) << endl; 8086145Snate@binkert.org } 8096145Snate@binkert.org} 8106145Snate@binkert.org 8116145Snate@binkert.org// Helper function 8126145Snate@binkert.orgstatic double process_memory_total() 8136145Snate@binkert.org{ 8146145Snate@binkert.org const double MULTIPLIER = 4096.0/(1024.0*1024.0); // 4kB page size, 1024*1024 bytes per MB, 8156145Snate@binkert.org ifstream proc_file; 8166145Snate@binkert.org proc_file.open("/proc/self/statm"); 8176145Snate@binkert.org int total_size_in_pages = 0; 8186145Snate@binkert.org int res_size_in_pages = 0; 8196145Snate@binkert.org proc_file >> total_size_in_pages; 8206145Snate@binkert.org proc_file >> res_size_in_pages; 8216145Snate@binkert.org return double(total_size_in_pages)*MULTIPLIER; // size in megabytes 8226145Snate@binkert.org} 8236145Snate@binkert.org 8246145Snate@binkert.orgstatic double process_memory_resident() 8256145Snate@binkert.org{ 8266145Snate@binkert.org const double MULTIPLIER = 4096.0/(1024.0*1024.0); // 4kB page size, 1024*1024 bytes per MB, 8276145Snate@binkert.org ifstream proc_file; 8286145Snate@binkert.org proc_file.open("/proc/self/statm"); 8296145Snate@binkert.org int total_size_in_pages = 0; 8306145Snate@binkert.org int res_size_in_pages = 0; 8316145Snate@binkert.org proc_file >> total_size_in_pages; 8326145Snate@binkert.org proc_file >> res_size_in_pages; 8336145Snate@binkert.org return double(res_size_in_pages)*MULTIPLIER; // size in megabytes 8346145Snate@binkert.org} 8356145Snate@binkert.org 8366285Snate@binkert.orgvoid Profiler::rubyWatch(int id){ 8376288Snate@binkert.org //int rn_g1 = 0;//SIMICS_get_register_number(id, "g1"); 8386285Snate@binkert.org uint64 tr = 0;//SIMICS_read_register(id, rn_g1); 8396285Snate@binkert.org Address watch_address = Address(tr); 8406285Snate@binkert.org const int ID_SPACES = 3; 8416285Snate@binkert.org const int TIME_SPACES = 7; 8426285Snate@binkert.org 8436285Snate@binkert.org (* debug_cout_ptr).flags(ios::right); 8446285Snate@binkert.org (* debug_cout_ptr) << setw(TIME_SPACES) << g_eventQueue_ptr->getTime() << " "; 8456285Snate@binkert.org (* debug_cout_ptr) << setw(ID_SPACES) << id << " " 8466285Snate@binkert.org << "RUBY WATCH " 8476285Snate@binkert.org << watch_address 8486285Snate@binkert.org << endl; 8496285Snate@binkert.org 8506285Snate@binkert.org if(!m_watch_address_list_ptr->exist(watch_address)){ 8516285Snate@binkert.org m_watch_address_list_ptr->add(watch_address, 1); 8526285Snate@binkert.org } 8536285Snate@binkert.org} 8546285Snate@binkert.org 8556285Snate@binkert.orgbool Profiler::watchAddress(Address addr){ 8566285Snate@binkert.org if (m_watch_address_list_ptr->exist(addr)) 8576285Snate@binkert.org return true; 8586285Snate@binkert.org else 8596285Snate@binkert.org return false; 8606285Snate@binkert.org} 8616285Snate@binkert.org 8626433Sdrh5@cs.wisc.eduint64 Profiler::getTotalTransactionsExecuted() const { 8636433Sdrh5@cs.wisc.edu return m_perProcEndTransaction.sum(); 8646433Sdrh5@cs.wisc.edu} 8656433Sdrh5@cs.wisc.edu 8666285Snate@binkert.org// For MemoryControl: 8676889SBrad.Beckmann@amd.comvoid Profiler::profileMemReq(int mem_cntrl, int bank) { 8686889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memReq++; 8696889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankCount[bank]++; 8706285Snate@binkert.org} 8716889SBrad.Beckmann@amd.com 8726889SBrad.Beckmann@amd.comvoid Profiler::profileMemBankBusy(int mem_cntrl) { 8736889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankBusy++; 8746889SBrad.Beckmann@amd.com} 8756889SBrad.Beckmann@amd.com 8766889SBrad.Beckmann@amd.comvoid Profiler::profileMemBusBusy(int mem_cntrl) { 8776889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBusBusy++; 8786889SBrad.Beckmann@amd.com} 8796889SBrad.Beckmann@amd.com 8806889SBrad.Beckmann@amd.comvoid Profiler::profileMemReadWriteBusy(int mem_cntrl) { 8816889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memReadWriteBusy++; 8826889SBrad.Beckmann@amd.com} 8836889SBrad.Beckmann@amd.com 8846889SBrad.Beckmann@amd.comvoid Profiler::profileMemDataBusBusy(int mem_cntrl) { 8856889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memDataBusBusy++; 8866889SBrad.Beckmann@amd.com} 8876889SBrad.Beckmann@amd.com 8886889SBrad.Beckmann@amd.comvoid Profiler::profileMemTfawBusy(int mem_cntrl) { 8896889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memTfawBusy++; 8906889SBrad.Beckmann@amd.com} 8916889SBrad.Beckmann@amd.com 8926889SBrad.Beckmann@amd.comvoid Profiler::profileMemRefresh(int mem_cntrl) { 8936889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRefresh++; 8946889SBrad.Beckmann@amd.com} 8956889SBrad.Beckmann@amd.com 8966889SBrad.Beckmann@amd.comvoid Profiler::profileMemRead(int mem_cntrl) { 8976889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRead++; 8986889SBrad.Beckmann@amd.com} 8996889SBrad.Beckmann@amd.com 9006889SBrad.Beckmann@amd.comvoid Profiler::profileMemWrite(int mem_cntrl) { 9016889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memWrite++; 9026889SBrad.Beckmann@amd.com} 9036889SBrad.Beckmann@amd.com 9046889SBrad.Beckmann@amd.comvoid Profiler::profileMemWaitCycles(int mem_cntrl, int cycles) { 9056889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memWaitCycles += cycles; 9066889SBrad.Beckmann@amd.com} 9076889SBrad.Beckmann@amd.com 9086889SBrad.Beckmann@amd.comvoid Profiler::profileMemInputQ(int mem_cntrl, int cycles) { 9096889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memInputQ += cycles; 9106889SBrad.Beckmann@amd.com} 9116889SBrad.Beckmann@amd.com 9126889SBrad.Beckmann@amd.comvoid Profiler::profileMemBankQ(int mem_cntrl, int cycles) { 9136889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memBankQ += cycles; 9146889SBrad.Beckmann@amd.com} 9156889SBrad.Beckmann@amd.com 9166889SBrad.Beckmann@amd.comvoid Profiler::profileMemArbWait(int mem_cntrl, int cycles) { 9176889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memArbWait += cycles; 9186889SBrad.Beckmann@amd.com} 9196889SBrad.Beckmann@amd.com 9206889SBrad.Beckmann@amd.comvoid Profiler::profileMemRandBusy(int mem_cntrl) { 9216889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memRandBusy++; 9226889SBrad.Beckmann@amd.com} 9236889SBrad.Beckmann@amd.com 9246889SBrad.Beckmann@amd.comvoid Profiler::profileMemNotOld(int mem_cntrl) { 9256889SBrad.Beckmann@amd.com m_mc_profilers[mem_cntrl]->m_memNotOld++; 9266889SBrad.Beckmann@amd.com} 9276285Snate@binkert.org 9286876Ssteve.reinhardt@amd.com 9296876Ssteve.reinhardt@amd.comProfiler * 9306876Ssteve.reinhardt@amd.comRubyProfilerParams::create() 9316876Ssteve.reinhardt@amd.com{ 9326876Ssteve.reinhardt@amd.com return new Profiler(this); 9336876Ssteve.reinhardt@amd.com} 934