Profiler.hh revision 7546
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 1417546SBrad.Beckmann@amd.com void swPrefetchLatency(Time t, 1427546SBrad.Beckmann@amd.com CacheRequestType type, 1437546SBrad.Beckmann@amd.com const GenericMachineType respondingMach); 1447546SBrad.Beckmann@amd.com 1457048Snate@binkert.org void sequencerRequests(int num) { m_sequencer_requests.add(num); } 1466145Snate@binkert.org 1477055Snate@binkert.org void profileTransition(const std::string& component, NodeID version, 1487055Snate@binkert.org Address addr, const std::string& state, const std::string& event, 1497055Snate@binkert.org const std::string& next_state, const std::string& note); 1507048Snate@binkert.org void profileMsgDelay(int virtualNetwork, int delayCycles); 1516145Snate@binkert.org 1527055Snate@binkert.org void print(std::ostream& out) const; 1536285Snate@binkert.org 1547048Snate@binkert.org void rubyWatch(int proc); 1557048Snate@binkert.org bool watchAddress(Address addr); 1566145Snate@binkert.org 1577048Snate@binkert.org // return Ruby's start time 1587048Snate@binkert.org Time 1597048Snate@binkert.org getRubyStartTime() 1607048Snate@binkert.org { 1617048Snate@binkert.org return m_ruby_start; 1627048Snate@binkert.org } 1636145Snate@binkert.org 1647048Snate@binkert.org // added by SS 1657048Snate@binkert.org bool getHotLines() { return m_hot_lines; } 1667048Snate@binkert.org bool getAllInstructions() { return m_all_instructions; } 1676145Snate@binkert.org 1687048Snate@binkert.org private: 1697048Snate@binkert.org // Private copy constructor and assignment operator 1707048Snate@binkert.org Profiler(const Profiler& obj); 1717048Snate@binkert.org Profiler& operator=(const Profiler& obj); 1726145Snate@binkert.org 1737048Snate@binkert.org AddressProfiler* m_address_profiler_ptr; 1747048Snate@binkert.org AddressProfiler* m_inst_profiler_ptr; 1756145Snate@binkert.org 1767454Snate@binkert.org std::vector<int64> m_instructions_executed_at_start; 1777454Snate@binkert.org std::vector<int64> m_cycles_executed_at_start; 1786145Snate@binkert.org 1797055Snate@binkert.org std::ostream* m_periodic_output_file_ptr; 1807048Snate@binkert.org integer_t m_stats_period; 1816145Snate@binkert.org 1827048Snate@binkert.org Time m_ruby_start; 1837048Snate@binkert.org time_t m_real_time_start_time; 1846145Snate@binkert.org 1857454Snate@binkert.org std::vector<std::vector<integer_t> > m_busyControllerCount; 1867048Snate@binkert.org integer_t m_busyBankCount; 1877048Snate@binkert.org Histogram m_multicast_retry_histogram; 1886145Snate@binkert.org 1897048Snate@binkert.org Histogram m_filter_action_histogram; 1907048Snate@binkert.org Histogram m_tbeProfile; 1916145Snate@binkert.org 1927048Snate@binkert.org Histogram m_sequencer_requests; 1937048Snate@binkert.org Histogram m_read_sharing_histogram; 1947048Snate@binkert.org Histogram m_write_sharing_histogram; 1957048Snate@binkert.org Histogram m_all_sharing_histogram; 1967048Snate@binkert.org int64 m_cache_to_cache; 1977048Snate@binkert.org int64 m_memory_to_cache; 1986145Snate@binkert.org 1997048Snate@binkert.org Histogram m_prefetchWaitHistogram; 2006145Snate@binkert.org 2017454Snate@binkert.org std::vector<Histogram> m_missLatencyHistograms; 2027454Snate@binkert.org std::vector<Histogram> m_machLatencyHistograms; 2037048Snate@binkert.org Histogram m_allMissLatencyHistogram; 2046145Snate@binkert.org 2057048Snate@binkert.org Histogram m_allSWPrefetchLatencyHistogram; 2067048Snate@binkert.org Histogram m_SWPrefetchL2MissLatencyHistogram; 2077454Snate@binkert.org std::vector<Histogram> m_SWPrefetchLatencyHistograms; 2087454Snate@binkert.org std::vector<Histogram> m_SWPrefetchMachLatencyHistograms; 2096145Snate@binkert.org 2107048Snate@binkert.org Histogram m_delayedCyclesHistogram; 2117048Snate@binkert.org Histogram m_delayedCyclesNonPFHistogram; 2127454Snate@binkert.org std::vector<Histogram> m_delayedCyclesVCHistograms; 2136145Snate@binkert.org 2147048Snate@binkert.org Histogram m_outstanding_requests; 2157048Snate@binkert.org Histogram m_outstanding_persistent_requests; 2166145Snate@binkert.org 2177048Snate@binkert.org Histogram m_average_latency_estimate; 2186145Snate@binkert.org 2197455Snate@binkert.org m5::hash_set<Address> m_watch_address_set; 2207048Snate@binkert.org // counts all initiated cache request including PUTs 2217048Snate@binkert.org int m_requests; 2227455Snate@binkert.org std::map<std::string, int> m_requestProfileMap; 2236896SBrad.Beckmann@amd.com 2247048Snate@binkert.org //added by SS 2257048Snate@binkert.org bool m_hot_lines; 2267048Snate@binkert.org bool m_all_instructions; 2277048Snate@binkert.org 2287048Snate@binkert.org int m_num_of_sequencers; 2296145Snate@binkert.org}; 2306145Snate@binkert.org 2317055Snate@binkert.orginline std::ostream& 2327055Snate@binkert.orgoperator<<(std::ostream& out, const Profiler& obj) 2336145Snate@binkert.org{ 2347048Snate@binkert.org obj.print(out); 2357055Snate@binkert.org out << std::flush; 2367048Snate@binkert.org return out; 2376145Snate@binkert.org} 2386145Snate@binkert.org 2397048Snate@binkert.org#endif // __MEM_RUBY_PROFILER_PROFILER_HH__ 2406145Snate@binkert.org 2416145Snate@binkert.org 242