Profiler.hh revision 8229
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/* 306284Snate@binkert.org This file has been modified by Kevin Moore and Dan Nussbaum of the 316284Snate@binkert.org Scalable Systems Research Group at Sun Microsystems Laboratories 326284Snate@binkert.org (http://research.sun.com/scalable/) to support the Adaptive 336284Snate@binkert.org Transactional Memory Test Platform (ATMTP). 346145Snate@binkert.org 356284Snate@binkert.org Please send email to atmtp-interest@sun.com with feedback, questions, or 366284Snate@binkert.org to request future announcements about ATMTP. 376145Snate@binkert.org 386284Snate@binkert.org ---------------------------------------------------------------------- 396145Snate@binkert.org 406284Snate@binkert.org File modification date: 2008-02-23 416145Snate@binkert.org 426284Snate@binkert.org ---------------------------------------------------------------------- 436145Snate@binkert.org*/ 446145Snate@binkert.org 457048Snate@binkert.org#ifndef __MEM_RUBY_PROFILER_PROFILER_HH__ 467048Snate@binkert.org#define __MEM_RUBY_PROFILER_PROFILER_HH__ 476145Snate@binkert.org 487055Snate@binkert.org#include <iostream> 497455Snate@binkert.org#include <map> 507055Snate@binkert.org#include <string> 517454Snate@binkert.org#include <vector> 527055Snate@binkert.org 537455Snate@binkert.org#include "base/hashmap.hh" 546154Snate@binkert.org#include "mem/protocol/AccessType.hh" 557048Snate@binkert.org#include "mem/protocol/GenericMachineType.hh" 567048Snate@binkert.org#include "mem/protocol/GenericRequestType.hh" 576154Snate@binkert.org#include "mem/protocol/PrefetchBit.hh" 588229Snate@binkert.org#include "mem/protocol/RubyAccessMode.hh" 598229Snate@binkert.org#include "mem/protocol/RubyRequestType.hh" 606154Snate@binkert.org#include "mem/ruby/common/Address.hh" 617048Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 627048Snate@binkert.org#include "mem/ruby/common/Global.hh" 637048Snate@binkert.org#include "mem/ruby/common/Histogram.hh" 646154Snate@binkert.org#include "mem/ruby/common/Set.hh" 657048Snate@binkert.org#include "mem/ruby/system/MachineID.hh" 666285Snate@binkert.org#include "mem/ruby/system/MemoryControl.hh" 677048Snate@binkert.org#include "mem/ruby/system/NodeID.hh" 686876Ssteve.reinhardt@amd.com#include "params/RubyProfiler.hh" 696876Ssteve.reinhardt@amd.com#include "sim/sim_object.hh" 706876Ssteve.reinhardt@amd.com 718174Snilay@cs.wisc.educlass RubyRequest; 726145Snate@binkert.orgclass AddressProfiler; 736145Snate@binkert.org 747048Snate@binkert.orgclass Profiler : public SimObject, public Consumer 757048Snate@binkert.org{ 767048Snate@binkert.org public: 776876Ssteve.reinhardt@amd.com typedef RubyProfilerParams Params; 787048Snate@binkert.org Profiler(const Params *); 797048Snate@binkert.org ~Profiler(); 806145Snate@binkert.org 817048Snate@binkert.org void wakeup(); 826145Snate@binkert.org 837055Snate@binkert.org void setPeriodicStatsFile(const std::string& filename); 847048Snate@binkert.org void setPeriodicStatsInterval(integer_t period); 856145Snate@binkert.org 867055Snate@binkert.org void printStats(std::ostream& out, bool short_stats=false); 877055Snate@binkert.org void printShortStats(std::ostream& out) { printStats(out, true); } 887055Snate@binkert.org void printTraceStats(std::ostream& out) const; 897048Snate@binkert.org void clearStats(); 907055Snate@binkert.org void printConfig(std::ostream& out) const; 917055Snate@binkert.org void printResourceUsage(std::ostream& out) const; 926145Snate@binkert.org 937048Snate@binkert.org AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; } 947048Snate@binkert.org AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; } 956145Snate@binkert.org 968174Snilay@cs.wisc.edu void addAddressTraceSample(const RubyRequest& msg, NodeID id); 976145Snate@binkert.org 987055Snate@binkert.org void profileRequest(const std::string& requestStr); 997048Snate@binkert.org void profileSharing(const Address& addr, AccessType type, 1007048Snate@binkert.org NodeID requestor, const Set& sharers, 1017048Snate@binkert.org const Set& owner); 1026145Snate@binkert.org 1037048Snate@binkert.org void profileMulticastRetry(const Address& addr, int count); 1046145Snate@binkert.org 1057048Snate@binkert.org void profileFilterAction(int action); 1066145Snate@binkert.org 1077048Snate@binkert.org void profileConflictingRequests(const Address& addr); 1086145Snate@binkert.org 1097048Snate@binkert.org void 1107048Snate@binkert.org profileOutstandingRequest(int outstanding) 1117048Snate@binkert.org { 1127048Snate@binkert.org m_outstanding_requests.add(outstanding); 1137048Snate@binkert.org } 1146145Snate@binkert.org 1157048Snate@binkert.org void 1167048Snate@binkert.org profileOutstandingPersistentRequest(int outstanding) 1177048Snate@binkert.org { 1187048Snate@binkert.org m_outstanding_persistent_requests.add(outstanding); 1197048Snate@binkert.org } 1206145Snate@binkert.org 1217048Snate@binkert.org void 1227048Snate@binkert.org profileAverageLatencyEstimate(int latency) 1237048Snate@binkert.org { 1247048Snate@binkert.org m_average_latency_estimate.add(latency); 1257048Snate@binkert.org } 1266145Snate@binkert.org 1277048Snate@binkert.org void recordPrediction(bool wasGood, bool wasPredicted); 1286145Snate@binkert.org 1297048Snate@binkert.org void startTransaction(int cpu); 1307048Snate@binkert.org void endTransaction(int cpu); 1317048Snate@binkert.org void profilePFWait(Time waitTime); 1326145Snate@binkert.org 1337048Snate@binkert.org void controllerBusy(MachineID machID); 1347048Snate@binkert.org void bankBusy(); 1357546SBrad.Beckmann@amd.com 1367546SBrad.Beckmann@amd.com void missLatency(Time t, 1377546SBrad.Beckmann@amd.com RubyRequestType type, 1387546SBrad.Beckmann@amd.com const GenericMachineType respondingMach); 1397546SBrad.Beckmann@amd.com 1407565SBrad.Beckmann@amd.com void missLatencyWcc(Time issuedTime, 1417565SBrad.Beckmann@amd.com Time initialRequestTime, 1427565SBrad.Beckmann@amd.com Time forwardRequestTime, 1437565SBrad.Beckmann@amd.com Time firstResponseTime, 1447565SBrad.Beckmann@amd.com Time completionTime); 1457565SBrad.Beckmann@amd.com 1467565SBrad.Beckmann@amd.com void missLatencyDir(Time issuedTime, 1477565SBrad.Beckmann@amd.com Time initialRequestTime, 1487565SBrad.Beckmann@amd.com Time forwardRequestTime, 1497565SBrad.Beckmann@amd.com Time firstResponseTime, 1507565SBrad.Beckmann@amd.com Time completionTime); 1517565SBrad.Beckmann@amd.com 1527546SBrad.Beckmann@amd.com void swPrefetchLatency(Time t, 1538165Snilay@cs.wisc.edu RubyRequestType type, 1547546SBrad.Beckmann@amd.com const GenericMachineType respondingMach); 1557546SBrad.Beckmann@amd.com 1567048Snate@binkert.org void sequencerRequests(int num) { m_sequencer_requests.add(num); } 1576145Snate@binkert.org 1587048Snate@binkert.org void profileMsgDelay(int virtualNetwork, int delayCycles); 1596145Snate@binkert.org 1607055Snate@binkert.org void print(std::ostream& out) const; 1616285Snate@binkert.org 1627048Snate@binkert.org void rubyWatch(int proc); 1637048Snate@binkert.org bool watchAddress(Address addr); 1646145Snate@binkert.org 1657048Snate@binkert.org // return Ruby's start time 1667048Snate@binkert.org Time 1677048Snate@binkert.org getRubyStartTime() 1687048Snate@binkert.org { 1697048Snate@binkert.org return m_ruby_start; 1707048Snate@binkert.org } 1716145Snate@binkert.org 1727048Snate@binkert.org // added by SS 1737048Snate@binkert.org bool getHotLines() { return m_hot_lines; } 1747048Snate@binkert.org bool getAllInstructions() { return m_all_instructions; } 1756145Snate@binkert.org 1767048Snate@binkert.org private: 1777048Snate@binkert.org // Private copy constructor and assignment operator 1787048Snate@binkert.org Profiler(const Profiler& obj); 1797048Snate@binkert.org Profiler& operator=(const Profiler& obj); 1806145Snate@binkert.org 1817048Snate@binkert.org AddressProfiler* m_address_profiler_ptr; 1827048Snate@binkert.org AddressProfiler* m_inst_profiler_ptr; 1836145Snate@binkert.org 1847454Snate@binkert.org std::vector<int64> m_instructions_executed_at_start; 1857454Snate@binkert.org std::vector<int64> m_cycles_executed_at_start; 1866145Snate@binkert.org 1877055Snate@binkert.org std::ostream* m_periodic_output_file_ptr; 1887048Snate@binkert.org integer_t m_stats_period; 1896145Snate@binkert.org 1907048Snate@binkert.org Time m_ruby_start; 1917048Snate@binkert.org time_t m_real_time_start_time; 1926145Snate@binkert.org 1937454Snate@binkert.org std::vector<std::vector<integer_t> > m_busyControllerCount; 1947048Snate@binkert.org integer_t m_busyBankCount; 1957048Snate@binkert.org Histogram m_multicast_retry_histogram; 1966145Snate@binkert.org 1977048Snate@binkert.org Histogram m_filter_action_histogram; 1987048Snate@binkert.org Histogram m_tbeProfile; 1996145Snate@binkert.org 2007048Snate@binkert.org Histogram m_sequencer_requests; 2017048Snate@binkert.org Histogram m_read_sharing_histogram; 2027048Snate@binkert.org Histogram m_write_sharing_histogram; 2037048Snate@binkert.org Histogram m_all_sharing_histogram; 2047048Snate@binkert.org int64 m_cache_to_cache; 2057048Snate@binkert.org int64 m_memory_to_cache; 2066145Snate@binkert.org 2077048Snate@binkert.org Histogram m_prefetchWaitHistogram; 2086145Snate@binkert.org 2097454Snate@binkert.org std::vector<Histogram> m_missLatencyHistograms; 2107454Snate@binkert.org std::vector<Histogram> m_machLatencyHistograms; 2117565SBrad.Beckmann@amd.com std::vector< std::vector<Histogram> > m_missMachLatencyHistograms; 2127565SBrad.Beckmann@amd.com Histogram m_wCCIssueToInitialRequestHistogram; 2137565SBrad.Beckmann@amd.com Histogram m_wCCInitialRequestToForwardRequestHistogram; 2147565SBrad.Beckmann@amd.com Histogram m_wCCForwardRequestToFirstResponseHistogram; 2157565SBrad.Beckmann@amd.com Histogram m_wCCFirstResponseToCompleteHistogram; 2167565SBrad.Beckmann@amd.com int64 m_wCCIncompleteTimes; 2177565SBrad.Beckmann@amd.com Histogram m_dirIssueToInitialRequestHistogram; 2187565SBrad.Beckmann@amd.com Histogram m_dirInitialRequestToForwardRequestHistogram; 2197565SBrad.Beckmann@amd.com Histogram m_dirForwardRequestToFirstResponseHistogram; 2207565SBrad.Beckmann@amd.com Histogram m_dirFirstResponseToCompleteHistogram; 2217565SBrad.Beckmann@amd.com int64 m_dirIncompleteTimes; 2227565SBrad.Beckmann@amd.com 2237048Snate@binkert.org Histogram m_allMissLatencyHistogram; 2246145Snate@binkert.org 2257048Snate@binkert.org Histogram m_allSWPrefetchLatencyHistogram; 2267048Snate@binkert.org Histogram m_SWPrefetchL2MissLatencyHistogram; 2277454Snate@binkert.org std::vector<Histogram> m_SWPrefetchLatencyHistograms; 2287454Snate@binkert.org std::vector<Histogram> m_SWPrefetchMachLatencyHistograms; 2296145Snate@binkert.org 2307048Snate@binkert.org Histogram m_delayedCyclesHistogram; 2317048Snate@binkert.org Histogram m_delayedCyclesNonPFHistogram; 2327454Snate@binkert.org std::vector<Histogram> m_delayedCyclesVCHistograms; 2336145Snate@binkert.org 2347048Snate@binkert.org Histogram m_outstanding_requests; 2357048Snate@binkert.org Histogram m_outstanding_persistent_requests; 2366145Snate@binkert.org 2377048Snate@binkert.org Histogram m_average_latency_estimate; 2386145Snate@binkert.org 2397455Snate@binkert.org m5::hash_set<Address> m_watch_address_set; 2407048Snate@binkert.org // counts all initiated cache request including PUTs 2417048Snate@binkert.org int m_requests; 2427455Snate@binkert.org std::map<std::string, int> m_requestProfileMap; 2436896SBrad.Beckmann@amd.com 2447048Snate@binkert.org //added by SS 2457048Snate@binkert.org bool m_hot_lines; 2467048Snate@binkert.org bool m_all_instructions; 2477048Snate@binkert.org 2487048Snate@binkert.org int m_num_of_sequencers; 2496145Snate@binkert.org}; 2506145Snate@binkert.org 2517055Snate@binkert.orginline std::ostream& 2527055Snate@binkert.orgoperator<<(std::ostream& out, const Profiler& obj) 2536145Snate@binkert.org{ 2547048Snate@binkert.org obj.print(out); 2557055Snate@binkert.org out << std::flush; 2567048Snate@binkert.org return out; 2576145Snate@binkert.org} 2586145Snate@binkert.org 2597048Snate@binkert.org#endif // __MEM_RUBY_PROFILER_PROFILER_HH__ 2606145Snate@binkert.org 2616145Snate@binkert.org 262