Profiler.hh revision 9773:915be89faf30
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/PrefetchBit.hh" 56#include "mem/protocol/RubyAccessMode.hh" 57#include "mem/protocol/RubyRequestType.hh" 58#include "mem/ruby/common/Address.hh" 59#include "mem/ruby/common/Global.hh" 60#include "mem/ruby/common/Histogram.hh" 61#include "mem/ruby/common/Set.hh" 62#include "mem/ruby/system/MachineID.hh" 63#include "mem/ruby/system/MemoryControl.hh" 64#include "params/RubyProfiler.hh" 65#include "sim/sim_object.hh" 66 67class RubyRequest; 68class AddressProfiler; 69 70class Profiler : public SimObject 71{ 72 public: 73 typedef RubyProfilerParams Params; 74 Profiler(const Params *); 75 ~Profiler(); 76 77 void wakeup(); 78 79 void setPeriodicStatsFile(const std::string& filename); 80 void setPeriodicStatsInterval(int64_t period); 81 82 void printStats(std::ostream& out, bool short_stats=false); 83 void printShortStats(std::ostream& out) { printStats(out, true); } 84 void printTraceStats(std::ostream& out) const; 85 void clearStats(); 86 void printResourceUsage(std::ostream& out) const; 87 88 AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; } 89 AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; } 90 91 void addAddressTraceSample(const RubyRequest& msg, NodeID id); 92 93 void profileRequest(const std::string& requestStr); 94 void profileSharing(const Address& addr, AccessType type, 95 NodeID requestor, const Set& sharers, 96 const Set& owner); 97 98 void profileMulticastRetry(const Address& addr, int count); 99 100 void profileFilterAction(int action); 101 102 void profileConflictingRequests(const Address& addr); 103 104 void 105 profileAverageLatencyEstimate(int latency) 106 { 107 m_average_latency_estimate.add(latency); 108 } 109 110 void controllerBusy(MachineID machID); 111 void bankBusy(); 112 113 void print(std::ostream& out) const; 114 115 void rubyWatch(int proc); 116 bool watchAddress(Address addr); 117 118 // return Ruby's start time 119 Cycles getRubyStartTime() { return m_ruby_start; } 120 121 // added by SS 122 bool getHotLines() { return m_hot_lines; } 123 bool getAllInstructions() { return m_all_instructions; } 124 125 private: 126 void printRequestProfile(std::ostream &out) const; 127 void printDelayProfile(std::ostream &out) const; 128 void printOutstandingReqProfile(std::ostream &out) const; 129 void printMissLatencyProfile(std::ostream &out) const; 130 131 private: 132 // Private copy constructor and assignment operator 133 Profiler(const Profiler& obj); 134 Profiler& operator=(const Profiler& obj); 135 136 AddressProfiler* m_address_profiler_ptr; 137 AddressProfiler* m_inst_profiler_ptr; 138 139 Cycles m_ruby_start; 140 time_t m_real_time_start_time; 141 142 int64_t m_busyBankCount; 143 144 Histogram m_read_sharing_histogram; 145 Histogram m_write_sharing_histogram; 146 Histogram m_all_sharing_histogram; 147 int64 m_cache_to_cache; 148 int64 m_memory_to_cache; 149 150 Histogram m_average_latency_estimate; 151 m5::hash_set<Address> m_watch_address_set; 152 153 //added by SS 154 bool m_hot_lines; 155 bool m_all_instructions; 156 157 int m_num_of_sequencers; 158}; 159 160inline std::ostream& 161operator<<(std::ostream& out, const Profiler& obj) 162{ 163 obj.print(out); 164 out << std::flush; 165 return out; 166} 167 168#endif // __MEM_RUBY_PROFILER_PROFILER_HH__ 169