Profiler.hh revision 7048:2ab58c54de63
11689SN/A/* 22329SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 31689SN/A * All rights reserved. 41689SN/A * 51689SN/A * Redistribution and use in source and binary forms, with or without 61689SN/A * modification, are permitted provided that the following conditions are 71689SN/A * met: redistributions of source code must retain the above copyright 81689SN/A * notice, this list of conditions and the following disclaimer; 91689SN/A * redistributions in binary form must reproduce the above copyright 101689SN/A * notice, this list of conditions and the following disclaimer in the 111689SN/A * documentation and/or other materials provided with the distribution; 121689SN/A * neither the name of the copyright holders nor the names of its 131689SN/A * contributors may be used to endorse or promote products derived from 141689SN/A * this software without specific prior written permission. 151689SN/A * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu */ 282665Ssaidi@eecs.umich.edu 291689SN/A/* 301689SN/A This file has been modified by Kevin Moore and Dan Nussbaum of the 312292SN/A Scalable Systems Research Group at Sun Microsystems Laboratories 322292SN/A (http://research.sun.com/scalable/) to support the Adaptive 331060SN/A Transactional Memory Test Platform (ATMTP). 341060SN/A 351060SN/A Please send email to atmtp-interest@sun.com with feedback, questions, or 361461SN/A to request future announcements about ATMTP. 371060SN/A 381060SN/A ---------------------------------------------------------------------- 392292SN/A 402329SN/A File modification date: 2008-02-23 412329SN/A 422329SN/A ---------------------------------------------------------------------- 432329SN/A*/ 442329SN/A 452329SN/A#ifndef __MEM_RUBY_PROFILER_PROFILER_HH__ 462329SN/A#define __MEM_RUBY_PROFILER_PROFILER_HH__ 472329SN/A 482329SN/A#include "mem/protocol/AccessModeType.hh" 492329SN/A#include "mem/protocol/AccessType.hh" 502292SN/A#include "mem/protocol/CacheRequestType.hh" 511060SN/A#include "mem/protocol/GenericMachineType.hh" 522292SN/A#include "mem/protocol/GenericRequestType.hh" 531060SN/A#include "mem/protocol/PrefetchBit.hh" 541060SN/A#include "mem/ruby/common/Address.hh" 551060SN/A#include "mem/ruby/common/Consumer.hh" 561060SN/A#include "mem/ruby/common/Global.hh" 571061SN/A#include "mem/ruby/common/Histogram.hh" 582733Sktlim@umich.edu#include "mem/ruby/common/Set.hh" 591060SN/A#include "mem/ruby/libruby.hh" 601060SN/A#include "mem/ruby/system/MachineID.hh" 612292SN/A#include "mem/ruby/system/MemoryControl.hh" 621061SN/A#include "mem/ruby/system/NodeID.hh" 631061SN/A#include "params/RubyProfiler.hh" 641061SN/A#include "sim/sim_object.hh" 651060SN/A 661060SN/Aclass CacheMsg; 672292SN/Aclass AddressProfiler; 682292SN/A 692292SN/Atemplate <class KEY_TYPE, class VALUE_TYPE> class Map; 701060SN/A 711060SN/Aclass Profiler : public SimObject, public Consumer 722107SN/A{ 731060SN/A public: 742329SN/A typedef RubyProfilerParams Params; 752329SN/A Profiler(const Params *); 762329SN/A ~Profiler(); 772329SN/A 782292SN/A void wakeup(); 792292SN/A 801060SN/A void setPeriodicStatsFile(const string& filename); 812329SN/A void setPeriodicStatsInterval(integer_t period); 822329SN/A 832292SN/A void printStats(ostream& out, bool short_stats=false); 842292SN/A void printShortStats(ostream& out) { printStats(out, true); } 852292SN/A void printTraceStats(ostream& out) const; 862292SN/A void clearStats(); 872292SN/A void printConfig(ostream& out) const; 882292SN/A void printResourceUsage(ostream& out) const; 892292SN/A 902292SN/A AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; } 911060SN/A AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; } 921060SN/A 932292SN/A void addAddressTraceSample(const CacheMsg& msg, NodeID id); 941060SN/A 951060SN/A void profileRequest(const string& requestStr); 961060SN/A void profileSharing(const Address& addr, AccessType type, 972301SN/A NodeID requestor, const Set& sharers, 981060SN/A const Set& owner); 991060SN/A 1001060SN/A void profileMulticastRetry(const Address& addr, int count); 1012292SN/A 1022292SN/A void profileFilterAction(int action); 1032292SN/A 1042292SN/A void profileConflictingRequests(const Address& addr); 1052292SN/A 1061060SN/A void 1071060SN/A profileOutstandingRequest(int outstanding) 1082292SN/A { 1092292SN/A m_outstanding_requests.add(outstanding); 1101060SN/A } 1112292SN/A 1122292SN/A void 1132292SN/A profileOutstandingPersistentRequest(int outstanding) 1142292SN/A { 1151062SN/A m_outstanding_persistent_requests.add(outstanding); 1161062SN/A } 1172292SN/A 1182733Sktlim@umich.edu void 1191060SN/A profileAverageLatencyEstimate(int latency) 1202292SN/A { 1211060SN/A m_average_latency_estimate.add(latency); 1221060SN/A } 1232292SN/A 1241060SN/A void recordPrediction(bool wasGood, bool wasPredicted); 1251060SN/A 1262292SN/A void startTransaction(int cpu); 1271060SN/A void endTransaction(int cpu); 1281060SN/A void profilePFWait(Time waitTime); 1292292SN/A 1302292SN/A void controllerBusy(MachineID machID); 1312292SN/A void bankBusy(); 1321060SN/A void missLatency(Time t, RubyRequestType type); 1332292SN/A void swPrefetchLatency(Time t, CacheRequestType type, 1342292SN/A GenericMachineType respondingMach); 1352292SN/A void sequencerRequests(int num) { m_sequencer_requests.add(num); } 1362292SN/A 1372292SN/A void profileTransition(const string& component, NodeID version, 1382292SN/A Address addr, const string& state, 1392292SN/A const string& event, const string& next_state, 1402292SN/A const string& note); 1412292SN/A void profileMsgDelay(int virtualNetwork, int delayCycles); 1422292SN/A 1432292SN/A void print(ostream& out) const; 1442292SN/A 1452292SN/A void rubyWatch(int proc); 1462292SN/A bool watchAddress(Address addr); 1472292SN/A 1482292SN/A // return Ruby's start time 1492292SN/A Time 1502292SN/A getRubyStartTime() 1512292SN/A { 1522292SN/A return m_ruby_start; 1532292SN/A } 1542292SN/A 1551060SN/A // added by SS 1561060SN/A bool getHotLines() { return m_hot_lines; } 1572292SN/A bool getAllInstructions() { return m_all_instructions; } 1582292SN/A 1592292SN/A private: 1602843Sktlim@umich.edu // Private copy constructor and assignment operator 1612863Sktlim@umich.edu Profiler(const Profiler& obj); 1622843Sktlim@umich.edu Profiler& operator=(const Profiler& obj); 1632843Sktlim@umich.edu 1642843Sktlim@umich.edu AddressProfiler* m_address_profiler_ptr; 1652843Sktlim@umich.edu AddressProfiler* m_inst_profiler_ptr; 1662348SN/A 1672307SN/A Vector<int64> m_instructions_executed_at_start; 1682307SN/A Vector<int64> m_cycles_executed_at_start; 1692348SN/A 1702307SN/A ostream* m_periodic_output_file_ptr; 1712307SN/A integer_t m_stats_period; 1722292SN/A 1732292SN/A Time m_ruby_start; 1742292SN/A time_t m_real_time_start_time; 1752292SN/A 1762292SN/A Vector <Vector<integer_t> > m_busyControllerCount; 1772292SN/A integer_t m_busyBankCount; 1782292SN/A Histogram m_multicast_retry_histogram; 1792292SN/A 1802292SN/A Histogram m_filter_action_histogram; 1811060SN/A Histogram m_tbeProfile; 1821060SN/A 1832292SN/A Histogram m_sequencer_requests; 1842292SN/A Histogram m_read_sharing_histogram; 1852292SN/A Histogram m_write_sharing_histogram; 1862292SN/A Histogram m_all_sharing_histogram; 1872292SN/A int64 m_cache_to_cache; 1882292SN/A int64 m_memory_to_cache; 1892292SN/A 1901060SN/A Histogram m_prefetchWaitHistogram; 1912292SN/A 1922292SN/A Vector<Histogram> m_missLatencyHistograms; 1932292SN/A Vector<Histogram> m_machLatencyHistograms; 1942292SN/A Histogram m_allMissLatencyHistogram; 1951060SN/A 1962292SN/A Histogram m_allSWPrefetchLatencyHistogram; 1972292SN/A Histogram m_SWPrefetchL2MissLatencyHistogram; 1982292SN/A Vector<Histogram> m_SWPrefetchLatencyHistograms; 1992292SN/A Vector<Histogram> m_SWPrefetchMachLatencyHistograms; 2001060SN/A 2012292SN/A Histogram m_delayedCyclesHistogram; 2022292SN/A Histogram m_delayedCyclesNonPFHistogram; 2032292SN/A Vector<Histogram> m_delayedCyclesVCHistograms; 2042292SN/A 2051060SN/A Histogram m_outstanding_requests; 2062292SN/A Histogram m_outstanding_persistent_requests; 2072292SN/A 2081060SN/A Histogram m_average_latency_estimate; 2092292SN/A 2102292SN/A Map<Address, int>* m_watch_address_list_ptr; 2111060SN/A // counts all initiated cache request including PUTs 2122292SN/A int m_requests; 2132292SN/A Map <string, int>* m_requestProfileMap_ptr; 2142292SN/A 2152292SN/A //added by SS 2162292SN/A bool m_hot_lines; 2171060SN/A bool m_all_instructions; 2182292SN/A 2192292SN/A int m_num_of_sequencers; 2202292SN/A}; 2212292SN/A 2222292SN/Ainline ostream& 2231061SN/Aoperator<<(ostream& out, const Profiler& obj) 2242292SN/A{ 2252292SN/A obj.print(out); 2261061SN/A out << flush; 2272292SN/A return out; 2282292SN/A} 2291061SN/A 2302292SN/A#endif // __MEM_RUBY_PROFILER_PROFILER_HH__ 2312292SN/A 2321061SN/A 2332292SN/A