Profiler.hh (9599:e95479c2926f) | Profiler.hh (9692:67d9da312ef0) |
---|---|
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 This file has been modified by Kevin Moore and Dan Nussbaum of the 31 Scalable Systems Research Group at Sun Microsystems Laboratories 32 (http://research.sun.com/scalable/) to support the Adaptive 33 Transactional Memory Test Platform (ATMTP). 34 35 Please send email to atmtp-interest@sun.com with feedback, questions, or 36 to request future announcements about ATMTP. 37 38 ---------------------------------------------------------------------- 39 40 File modification date: 2008-02-23 41 42 ---------------------------------------------------------------------- 43*/ 44 45#ifndef __MEM_RUBY_PROFILER_PROFILER_HH__ 46#define __MEM_RUBY_PROFILER_PROFILER_HH__ 47 48#include <iostream> 49#include <map> 50#include <string> 51#include <vector> 52 53#include "base/hashmap.hh" 54#include "mem/protocol/AccessType.hh" 55#include "mem/protocol/GenericMachineType.hh" | 1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 This file has been modified by Kevin Moore and Dan Nussbaum of the 31 Scalable Systems Research Group at Sun Microsystems Laboratories 32 (http://research.sun.com/scalable/) to support the Adaptive 33 Transactional Memory Test Platform (ATMTP). 34 35 Please send email to atmtp-interest@sun.com with feedback, questions, or 36 to request future announcements about ATMTP. 37 38 ---------------------------------------------------------------------- 39 40 File modification date: 2008-02-23 41 42 ---------------------------------------------------------------------- 43*/ 44 45#ifndef __MEM_RUBY_PROFILER_PROFILER_HH__ 46#define __MEM_RUBY_PROFILER_PROFILER_HH__ 47 48#include <iostream> 49#include <map> 50#include <string> 51#include <vector> 52 53#include "base/hashmap.hh" 54#include "mem/protocol/AccessType.hh" 55#include "mem/protocol/GenericMachineType.hh" |
56#include "mem/protocol/GenericRequestType.hh" | |
57#include "mem/protocol/PrefetchBit.hh" 58#include "mem/protocol/RubyAccessMode.hh" 59#include "mem/protocol/RubyRequestType.hh" 60#include "mem/ruby/common/Address.hh" 61#include "mem/ruby/common/Global.hh" 62#include "mem/ruby/common/Histogram.hh" 63#include "mem/ruby/common/Set.hh" 64#include "mem/ruby/system/MachineID.hh" 65#include "mem/ruby/system/MemoryControl.hh" 66#include "params/RubyProfiler.hh" 67#include "sim/sim_object.hh" 68 69class RubyRequest; 70class AddressProfiler; 71 72class Profiler : public SimObject 73{ 74 public: 75 typedef RubyProfilerParams Params; 76 Profiler(const Params *); 77 ~Profiler(); 78 79 void wakeup(); 80 81 void setPeriodicStatsFile(const std::string& filename); 82 void setPeriodicStatsInterval(int64_t period); 83 84 void printStats(std::ostream& out, bool short_stats=false); 85 void printShortStats(std::ostream& out) { printStats(out, true); } 86 void printTraceStats(std::ostream& out) const; 87 void clearStats(); 88 void printResourceUsage(std::ostream& out) const; 89 90 AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; } 91 AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; } 92 93 void addAddressTraceSample(const RubyRequest& msg, NodeID id); 94 95 void profileRequest(const std::string& requestStr); 96 void profileSharing(const Address& addr, AccessType type, 97 NodeID requestor, const Set& sharers, 98 const Set& owner); 99 100 void profileMulticastRetry(const Address& addr, int count); 101 102 void profileFilterAction(int action); 103 104 void profileConflictingRequests(const Address& addr); 105 106 void 107 profileAverageLatencyEstimate(int latency) 108 { 109 m_average_latency_estimate.add(latency); 110 } 111 112 void recordPrediction(bool wasGood, bool wasPredicted); 113 114 void startTransaction(int cpu); 115 void endTransaction(int cpu); 116 void profilePFWait(Cycles waitTime); 117 118 void controllerBusy(MachineID machID); 119 void bankBusy(); 120 121 void missLatency(Cycles t, RubyRequestType type, 122 const GenericMachineType respondingMach); 123 124 void missLatencyWcc(Cycles issuedTime, Cycles initialRequestTime, 125 Cycles forwardRequestTime, Cycles firstResponseTime, 126 Cycles completionTime); 127 128 void missLatencyDir(Cycles issuedTime, Cycles initialRequestTime, 129 Cycles forwardRequestTime, Cycles firstResponseTime, 130 Cycles completionTime); 131 132 void swPrefetchLatency(Cycles t, RubyRequestType type, 133 const GenericMachineType respondingMach); 134 135 void print(std::ostream& out) const; 136 137 void rubyWatch(int proc); 138 bool watchAddress(Address addr); 139 140 // return Ruby's start time 141 Cycles getRubyStartTime() { return m_ruby_start; } 142 143 // added by SS 144 bool getHotLines() { return m_hot_lines; } 145 bool getAllInstructions() { return m_all_instructions; } 146 147 private: 148 void printRequestProfile(std::ostream &out) const; 149 void printDelayProfile(std::ostream &out) const; 150 void printOutstandingReqProfile(std::ostream &out) const; 151 152 private: 153 // Private copy constructor and assignment operator 154 Profiler(const Profiler& obj); 155 Profiler& operator=(const Profiler& obj); 156 157 AddressProfiler* m_address_profiler_ptr; 158 AddressProfiler* m_inst_profiler_ptr; 159 160 std::vector<int64> m_instructions_executed_at_start; 161 std::vector<int64> m_cycles_executed_at_start; 162 163 std::ostream* m_periodic_output_file_ptr; 164 int64_t m_stats_period; 165 166 Cycles m_ruby_start; 167 time_t m_real_time_start_time; 168 169 int64_t m_busyBankCount; 170 Histogram m_multicast_retry_histogram; 171 172 Histogram m_filter_action_histogram; 173 Histogram m_tbeProfile; 174 175 Histogram m_read_sharing_histogram; 176 Histogram m_write_sharing_histogram; 177 Histogram m_all_sharing_histogram; 178 int64 m_cache_to_cache; 179 int64 m_memory_to_cache; 180 181 Histogram m_prefetchWaitHistogram; 182 183 std::vector<Histogram> m_missLatencyHistograms; 184 std::vector<Histogram> m_machLatencyHistograms; 185 std::vector< std::vector<Histogram> > m_missMachLatencyHistograms; 186 Histogram m_wCCIssueToInitialRequestHistogram; 187 Histogram m_wCCInitialRequestToForwardRequestHistogram; 188 Histogram m_wCCForwardRequestToFirstResponseHistogram; 189 Histogram m_wCCFirstResponseToCompleteHistogram; 190 int64 m_wCCIncompleteTimes; 191 Histogram m_dirIssueToInitialRequestHistogram; 192 Histogram m_dirInitialRequestToForwardRequestHistogram; 193 Histogram m_dirForwardRequestToFirstResponseHistogram; 194 Histogram m_dirFirstResponseToCompleteHistogram; 195 int64 m_dirIncompleteTimes; 196 197 Histogram m_allMissLatencyHistogram; 198 199 Histogram m_allSWPrefetchLatencyHistogram; 200 Histogram m_SWPrefetchL2MissLatencyHistogram; 201 std::vector<Histogram> m_SWPrefetchLatencyHistograms; 202 std::vector<Histogram> m_SWPrefetchMachLatencyHistograms; 203 204 Histogram m_average_latency_estimate; 205 m5::hash_set<Address> m_watch_address_set; 206 207 //added by SS 208 bool m_hot_lines; 209 bool m_all_instructions; 210 211 int m_num_of_sequencers; 212 213 protected: 214 class ProfileEvent : public Event 215 { 216 public: 217 ProfileEvent(Profiler *_profiler) 218 { 219 profiler = _profiler; 220 } 221 private: 222 void process() { profiler->wakeup(); } 223 Profiler *profiler; 224 }; 225 ProfileEvent m_event; 226}; 227 228inline std::ostream& 229operator<<(std::ostream& out, const Profiler& obj) 230{ 231 obj.print(out); 232 out << std::flush; 233 return out; 234} 235 236#endif // __MEM_RUBY_PROFILER_PROFILER_HH__ | 56#include "mem/protocol/PrefetchBit.hh" 57#include "mem/protocol/RubyAccessMode.hh" 58#include "mem/protocol/RubyRequestType.hh" 59#include "mem/ruby/common/Address.hh" 60#include "mem/ruby/common/Global.hh" 61#include "mem/ruby/common/Histogram.hh" 62#include "mem/ruby/common/Set.hh" 63#include "mem/ruby/system/MachineID.hh" 64#include "mem/ruby/system/MemoryControl.hh" 65#include "params/RubyProfiler.hh" 66#include "sim/sim_object.hh" 67 68class RubyRequest; 69class AddressProfiler; 70 71class Profiler : public SimObject 72{ 73 public: 74 typedef RubyProfilerParams Params; 75 Profiler(const Params *); 76 ~Profiler(); 77 78 void wakeup(); 79 80 void setPeriodicStatsFile(const std::string& filename); 81 void setPeriodicStatsInterval(int64_t period); 82 83 void printStats(std::ostream& out, bool short_stats=false); 84 void printShortStats(std::ostream& out) { printStats(out, true); } 85 void printTraceStats(std::ostream& out) const; 86 void clearStats(); 87 void printResourceUsage(std::ostream& out) const; 88 89 AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; } 90 AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; } 91 92 void addAddressTraceSample(const RubyRequest& msg, NodeID id); 93 94 void profileRequest(const std::string& requestStr); 95 void profileSharing(const Address& addr, AccessType type, 96 NodeID requestor, const Set& sharers, 97 const Set& owner); 98 99 void profileMulticastRetry(const Address& addr, int count); 100 101 void profileFilterAction(int action); 102 103 void profileConflictingRequests(const Address& addr); 104 105 void 106 profileAverageLatencyEstimate(int latency) 107 { 108 m_average_latency_estimate.add(latency); 109 } 110 111 void recordPrediction(bool wasGood, bool wasPredicted); 112 113 void startTransaction(int cpu); 114 void endTransaction(int cpu); 115 void profilePFWait(Cycles waitTime); 116 117 void controllerBusy(MachineID machID); 118 void bankBusy(); 119 120 void missLatency(Cycles t, RubyRequestType type, 121 const GenericMachineType respondingMach); 122 123 void missLatencyWcc(Cycles issuedTime, Cycles initialRequestTime, 124 Cycles forwardRequestTime, Cycles firstResponseTime, 125 Cycles completionTime); 126 127 void missLatencyDir(Cycles issuedTime, Cycles initialRequestTime, 128 Cycles forwardRequestTime, Cycles firstResponseTime, 129 Cycles completionTime); 130 131 void swPrefetchLatency(Cycles t, RubyRequestType type, 132 const GenericMachineType respondingMach); 133 134 void print(std::ostream& out) const; 135 136 void rubyWatch(int proc); 137 bool watchAddress(Address addr); 138 139 // return Ruby's start time 140 Cycles getRubyStartTime() { return m_ruby_start; } 141 142 // added by SS 143 bool getHotLines() { return m_hot_lines; } 144 bool getAllInstructions() { return m_all_instructions; } 145 146 private: 147 void printRequestProfile(std::ostream &out) const; 148 void printDelayProfile(std::ostream &out) const; 149 void printOutstandingReqProfile(std::ostream &out) const; 150 151 private: 152 // Private copy constructor and assignment operator 153 Profiler(const Profiler& obj); 154 Profiler& operator=(const Profiler& obj); 155 156 AddressProfiler* m_address_profiler_ptr; 157 AddressProfiler* m_inst_profiler_ptr; 158 159 std::vector<int64> m_instructions_executed_at_start; 160 std::vector<int64> m_cycles_executed_at_start; 161 162 std::ostream* m_periodic_output_file_ptr; 163 int64_t m_stats_period; 164 165 Cycles m_ruby_start; 166 time_t m_real_time_start_time; 167 168 int64_t m_busyBankCount; 169 Histogram m_multicast_retry_histogram; 170 171 Histogram m_filter_action_histogram; 172 Histogram m_tbeProfile; 173 174 Histogram m_read_sharing_histogram; 175 Histogram m_write_sharing_histogram; 176 Histogram m_all_sharing_histogram; 177 int64 m_cache_to_cache; 178 int64 m_memory_to_cache; 179 180 Histogram m_prefetchWaitHistogram; 181 182 std::vector<Histogram> m_missLatencyHistograms; 183 std::vector<Histogram> m_machLatencyHistograms; 184 std::vector< std::vector<Histogram> > m_missMachLatencyHistograms; 185 Histogram m_wCCIssueToInitialRequestHistogram; 186 Histogram m_wCCInitialRequestToForwardRequestHistogram; 187 Histogram m_wCCForwardRequestToFirstResponseHistogram; 188 Histogram m_wCCFirstResponseToCompleteHistogram; 189 int64 m_wCCIncompleteTimes; 190 Histogram m_dirIssueToInitialRequestHistogram; 191 Histogram m_dirInitialRequestToForwardRequestHistogram; 192 Histogram m_dirForwardRequestToFirstResponseHistogram; 193 Histogram m_dirFirstResponseToCompleteHistogram; 194 int64 m_dirIncompleteTimes; 195 196 Histogram m_allMissLatencyHistogram; 197 198 Histogram m_allSWPrefetchLatencyHistogram; 199 Histogram m_SWPrefetchL2MissLatencyHistogram; 200 std::vector<Histogram> m_SWPrefetchLatencyHistograms; 201 std::vector<Histogram> m_SWPrefetchMachLatencyHistograms; 202 203 Histogram m_average_latency_estimate; 204 m5::hash_set<Address> m_watch_address_set; 205 206 //added by SS 207 bool m_hot_lines; 208 bool m_all_instructions; 209 210 int m_num_of_sequencers; 211 212 protected: 213 class ProfileEvent : public Event 214 { 215 public: 216 ProfileEvent(Profiler *_profiler) 217 { 218 profiler = _profiler; 219 } 220 private: 221 void process() { profiler->wakeup(); } 222 Profiler *profiler; 223 }; 224 ProfileEvent m_event; 225}; 226 227inline std::ostream& 228operator<<(std::ostream& out, const Profiler& obj) 229{ 230 obj.print(out); 231 out << std::flush; 232 return out; 233} 234 235#endif // __MEM_RUBY_PROFILER_PROFILER_HH__ |