Profiler.hh revision 7565
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/AccessModeType.hh" 556154Snate@binkert.org#include "mem/protocol/AccessType.hh" 567048Snate@binkert.org#include "mem/protocol/CacheRequestType.hh" 577048Snate@binkert.org#include "mem/protocol/GenericMachineType.hh" 587048Snate@binkert.org#include "mem/protocol/GenericRequestType.hh" 596154Snate@binkert.org#include "mem/protocol/PrefetchBit.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/libruby.hh" 667048Snate@binkert.org#include "mem/ruby/system/MachineID.hh" 676285Snate@binkert.org#include "mem/ruby/system/MemoryControl.hh" 687048Snate@binkert.org#include "mem/ruby/system/NodeID.hh" 696876Ssteve.reinhardt@amd.com#include "params/RubyProfiler.hh" 706876Ssteve.reinhardt@amd.com#include "sim/sim_object.hh" 716876Ssteve.reinhardt@amd.com 726145Snate@binkert.orgclass CacheMsg; 736145Snate@binkert.orgclass AddressProfiler; 746145Snate@binkert.org 757048Snate@binkert.orgclass Profiler : public SimObject, public Consumer 767048Snate@binkert.org{ 777048Snate@binkert.org public: 786876Ssteve.reinhardt@amd.com typedef RubyProfilerParams Params; 797048Snate@binkert.org Profiler(const Params *); 807048Snate@binkert.org ~Profiler(); 816145Snate@binkert.org 827048Snate@binkert.org void wakeup(); 836145Snate@binkert.org 847055Snate@binkert.org void setPeriodicStatsFile(const std::string& filename); 857048Snate@binkert.org void setPeriodicStatsInterval(integer_t period); 866145Snate@binkert.org 877055Snate@binkert.org void printStats(std::ostream& out, bool short_stats=false); 887055Snate@binkert.org void printShortStats(std::ostream& out) { printStats(out, true); } 897055Snate@binkert.org void printTraceStats(std::ostream& out) const; 907048Snate@binkert.org void clearStats(); 917055Snate@binkert.org void printConfig(std::ostream& out) const; 927055Snate@binkert.org void printResourceUsage(std::ostream& out) const; 936145Snate@binkert.org 947048Snate@binkert.org AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; } 957048Snate@binkert.org AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; } 966145Snate@binkert.org 977048Snate@binkert.org void addAddressTraceSample(const CacheMsg& msg, NodeID id); 986145Snate@binkert.org 997055Snate@binkert.org void profileRequest(const std::string& requestStr); 1007048Snate@binkert.org void profileSharing(const Address& addr, AccessType type, 1017048Snate@binkert.org NodeID requestor, const Set& sharers, 1027048Snate@binkert.org const Set& owner); 1036145Snate@binkert.org 1047048Snate@binkert.org void profileMulticastRetry(const Address& addr, int count); 1056145Snate@binkert.org 1067048Snate@binkert.org void profileFilterAction(int action); 1076145Snate@binkert.org 1087048Snate@binkert.org void profileConflictingRequests(const Address& addr); 1096145Snate@binkert.org 1107048Snate@binkert.org void 1117048Snate@binkert.org profileOutstandingRequest(int outstanding) 1127048Snate@binkert.org { 1137048Snate@binkert.org m_outstanding_requests.add(outstanding); 1147048Snate@binkert.org } 1156145Snate@binkert.org 1167048Snate@binkert.org void 1177048Snate@binkert.org profileOutstandingPersistentRequest(int outstanding) 1187048Snate@binkert.org { 1197048Snate@binkert.org m_outstanding_persistent_requests.add(outstanding); 1207048Snate@binkert.org } 1216145Snate@binkert.org 1227048Snate@binkert.org void 1237048Snate@binkert.org profileAverageLatencyEstimate(int latency) 1247048Snate@binkert.org { 1257048Snate@binkert.org m_average_latency_estimate.add(latency); 1267048Snate@binkert.org } 1276145Snate@binkert.org 1287048Snate@binkert.org void recordPrediction(bool wasGood, bool wasPredicted); 1296145Snate@binkert.org 1307048Snate@binkert.org void startTransaction(int cpu); 1317048Snate@binkert.org void endTransaction(int cpu); 1327048Snate@binkert.org void profilePFWait(Time waitTime); 1336145Snate@binkert.org 1347048Snate@binkert.org void controllerBusy(MachineID machID); 1357048Snate@binkert.org void bankBusy(); 1367546SBrad.Beckmann@amd.com 1377546SBrad.Beckmann@amd.com void missLatency(Time t, 1387546SBrad.Beckmann@amd.com RubyRequestType type, 1397546SBrad.Beckmann@amd.com const GenericMachineType respondingMach); 1407546SBrad.Beckmann@amd.com 1417565SBrad.Beckmann@amd.com void missLatencyWcc(Time issuedTime, 1427565SBrad.Beckmann@amd.com Time initialRequestTime, 1437565SBrad.Beckmann@amd.com Time forwardRequestTime, 1447565SBrad.Beckmann@amd.com Time firstResponseTime, 1457565SBrad.Beckmann@amd.com Time completionTime); 1467565SBrad.Beckmann@amd.com 1477565SBrad.Beckmann@amd.com void missLatencyDir(Time issuedTime, 1487565SBrad.Beckmann@amd.com Time initialRequestTime, 1497565SBrad.Beckmann@amd.com Time forwardRequestTime, 1507565SBrad.Beckmann@amd.com Time firstResponseTime, 1517565SBrad.Beckmann@amd.com Time completionTime); 1527565SBrad.Beckmann@amd.com 1537546SBrad.Beckmann@amd.com void swPrefetchLatency(Time t, 1547546SBrad.Beckmann@amd.com CacheRequestType type, 1557546SBrad.Beckmann@amd.com const GenericMachineType respondingMach); 1567546SBrad.Beckmann@amd.com 1577048Snate@binkert.org void sequencerRequests(int num) { m_sequencer_requests.add(num); } 1586145Snate@binkert.org 1597055Snate@binkert.org void profileTransition(const std::string& component, NodeID version, 1607055Snate@binkert.org Address addr, const std::string& state, const std::string& event, 1617055Snate@binkert.org const std::string& next_state, const std::string& note); 1627048Snate@binkert.org void profileMsgDelay(int virtualNetwork, int delayCycles); 1636145Snate@binkert.org 1647055Snate@binkert.org void print(std::ostream& out) const; 1656285Snate@binkert.org 1667048Snate@binkert.org void rubyWatch(int proc); 1677048Snate@binkert.org bool watchAddress(Address addr); 1686145Snate@binkert.org 1697048Snate@binkert.org // return Ruby's start time 1707048Snate@binkert.org Time 1717048Snate@binkert.org getRubyStartTime() 1727048Snate@binkert.org { 1737048Snate@binkert.org return m_ruby_start; 1747048Snate@binkert.org } 1756145Snate@binkert.org 1767048Snate@binkert.org // added by SS 1777048Snate@binkert.org bool getHotLines() { return m_hot_lines; } 1787048Snate@binkert.org bool getAllInstructions() { return m_all_instructions; } 1796145Snate@binkert.org 1807048Snate@binkert.org private: 1817048Snate@binkert.org // Private copy constructor and assignment operator 1827048Snate@binkert.org Profiler(const Profiler& obj); 1837048Snate@binkert.org Profiler& operator=(const Profiler& obj); 1846145Snate@binkert.org 1857048Snate@binkert.org AddressProfiler* m_address_profiler_ptr; 1867048Snate@binkert.org AddressProfiler* m_inst_profiler_ptr; 1876145Snate@binkert.org 1887454Snate@binkert.org std::vector<int64> m_instructions_executed_at_start; 1897454Snate@binkert.org std::vector<int64> m_cycles_executed_at_start; 1906145Snate@binkert.org 1917055Snate@binkert.org std::ostream* m_periodic_output_file_ptr; 1927048Snate@binkert.org integer_t m_stats_period; 1936145Snate@binkert.org 1947048Snate@binkert.org Time m_ruby_start; 1957048Snate@binkert.org time_t m_real_time_start_time; 1966145Snate@binkert.org 1977454Snate@binkert.org std::vector<std::vector<integer_t> > m_busyControllerCount; 1987048Snate@binkert.org integer_t m_busyBankCount; 1997048Snate@binkert.org Histogram m_multicast_retry_histogram; 2006145Snate@binkert.org 2017048Snate@binkert.org Histogram m_filter_action_histogram; 2027048Snate@binkert.org Histogram m_tbeProfile; 2036145Snate@binkert.org 2047048Snate@binkert.org Histogram m_sequencer_requests; 2057048Snate@binkert.org Histogram m_read_sharing_histogram; 2067048Snate@binkert.org Histogram m_write_sharing_histogram; 2077048Snate@binkert.org Histogram m_all_sharing_histogram; 2087048Snate@binkert.org int64 m_cache_to_cache; 2097048Snate@binkert.org int64 m_memory_to_cache; 2106145Snate@binkert.org 2117048Snate@binkert.org Histogram m_prefetchWaitHistogram; 2126145Snate@binkert.org 2137454Snate@binkert.org std::vector<Histogram> m_missLatencyHistograms; 2147454Snate@binkert.org std::vector<Histogram> m_machLatencyHistograms; 2157565SBrad.Beckmann@amd.com std::vector< std::vector<Histogram> > m_missMachLatencyHistograms; 2167565SBrad.Beckmann@amd.com Histogram m_wCCIssueToInitialRequestHistogram; 2177565SBrad.Beckmann@amd.com Histogram m_wCCInitialRequestToForwardRequestHistogram; 2187565SBrad.Beckmann@amd.com Histogram m_wCCForwardRequestToFirstResponseHistogram; 2197565SBrad.Beckmann@amd.com Histogram m_wCCFirstResponseToCompleteHistogram; 2207565SBrad.Beckmann@amd.com int64 m_wCCIncompleteTimes; 2217565SBrad.Beckmann@amd.com Histogram m_dirIssueToInitialRequestHistogram; 2227565SBrad.Beckmann@amd.com Histogram m_dirInitialRequestToForwardRequestHistogram; 2237565SBrad.Beckmann@amd.com Histogram m_dirForwardRequestToFirstResponseHistogram; 2247565SBrad.Beckmann@amd.com Histogram m_dirFirstResponseToCompleteHistogram; 2257565SBrad.Beckmann@amd.com int64 m_dirIncompleteTimes; 2267565SBrad.Beckmann@amd.com 2277048Snate@binkert.org Histogram m_allMissLatencyHistogram; 2286145Snate@binkert.org 2297048Snate@binkert.org Histogram m_allSWPrefetchLatencyHistogram; 2307048Snate@binkert.org Histogram m_SWPrefetchL2MissLatencyHistogram; 2317454Snate@binkert.org std::vector<Histogram> m_SWPrefetchLatencyHistograms; 2327454Snate@binkert.org std::vector<Histogram> m_SWPrefetchMachLatencyHistograms; 2336145Snate@binkert.org 2347048Snate@binkert.org Histogram m_delayedCyclesHistogram; 2357048Snate@binkert.org Histogram m_delayedCyclesNonPFHistogram; 2367454Snate@binkert.org std::vector<Histogram> m_delayedCyclesVCHistograms; 2376145Snate@binkert.org 2387048Snate@binkert.org Histogram m_outstanding_requests; 2397048Snate@binkert.org Histogram m_outstanding_persistent_requests; 2406145Snate@binkert.org 2417048Snate@binkert.org Histogram m_average_latency_estimate; 2426145Snate@binkert.org 2437455Snate@binkert.org m5::hash_set<Address> m_watch_address_set; 2447048Snate@binkert.org // counts all initiated cache request including PUTs 2457048Snate@binkert.org int m_requests; 2467455Snate@binkert.org std::map<std::string, int> m_requestProfileMap; 2476896SBrad.Beckmann@amd.com 2487048Snate@binkert.org //added by SS 2497048Snate@binkert.org bool m_hot_lines; 2507048Snate@binkert.org bool m_all_instructions; 2517048Snate@binkert.org 2527048Snate@binkert.org int m_num_of_sequencers; 2536145Snate@binkert.org}; 2546145Snate@binkert.org 2557055Snate@binkert.orginline std::ostream& 2567055Snate@binkert.orgoperator<<(std::ostream& out, const Profiler& obj) 2576145Snate@binkert.org{ 2587048Snate@binkert.org obj.print(out); 2597055Snate@binkert.org out << std::flush; 2607048Snate@binkert.org return out; 2616145Snate@binkert.org} 2626145Snate@binkert.org 2637048Snate@binkert.org#endif // __MEM_RUBY_PROFILER_PROFILER_HH__ 2646145Snate@binkert.org 2656145Snate@binkert.org 266