Profiler.hh revision 6897:cfeb3d9563dd
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/*
46 * Profiler.hh
47 *
48 * Description:
49 *
50 * $Id$
51 *
52 */
53
54#ifndef PROFILER_H
55#define PROFILER_H
56
57#include "mem/ruby/libruby.hh"
58
59#include "mem/ruby/common/Global.hh"
60#include "mem/protocol/GenericMachineType.hh"
61#include "mem/ruby/common/Histogram.hh"
62#include "mem/ruby/common/Consumer.hh"
63#include "mem/protocol/AccessModeType.hh"
64#include "mem/protocol/AccessType.hh"
65#include "mem/ruby/system/NodeID.hh"
66#include "mem/ruby/system/MachineID.hh"
67#include "mem/protocol/PrefetchBit.hh"
68#include "mem/ruby/common/Address.hh"
69#include "mem/ruby/common/Set.hh"
70#include "mem/protocol/CacheRequestType.hh"
71#include "mem/protocol/GenericRequestType.hh"
72#include "mem/ruby/system/MemoryControl.hh"
73
74#include "params/RubyProfiler.hh"
75#include "sim/sim_object.hh"
76
77class CacheMsg;
78class AddressProfiler;
79
80template <class KEY_TYPE, class VALUE_TYPE> class Map;
81
82class Profiler : public SimObject, public Consumer {
83public:
84  // Constructors
85    typedef RubyProfilerParams Params;
86  Profiler(const Params *);
87
88  // Destructor
89  ~Profiler();
90
91  // Public Methods
92  void wakeup();
93
94  void setPeriodicStatsFile(const string& filename);
95  void setPeriodicStatsInterval(integer_t period);
96
97  void printStats(ostream& out, bool short_stats=false);
98  void printShortStats(ostream& out) { printStats(out, true); }
99  void printTraceStats(ostream& out) const;
100  void clearStats();
101  void printConfig(ostream& out) const;
102  void printResourceUsage(ostream& out) const;
103
104  AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; }
105  AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; }
106
107  void addAddressTraceSample(const CacheMsg& msg, NodeID id);
108
109  void profileRequest(const string& requestStr);
110  void profileSharing(const Address& addr, AccessType type, NodeID requestor, const Set& sharers, const Set& owner);
111
112  void profileMulticastRetry(const Address& addr, int count);
113
114  void profileFilterAction(int action);
115
116  void profileConflictingRequests(const Address& addr);
117  void profileOutstandingRequest(int outstanding) { m_outstanding_requests.add(outstanding); }
118  void profileOutstandingPersistentRequest(int outstanding) { m_outstanding_persistent_requests.add(outstanding); }
119  void profileAverageLatencyEstimate(int latency) { m_average_latency_estimate.add(latency); }
120
121  void recordPrediction(bool wasGood, bool wasPredicted);
122
123  void startTransaction(int cpu);
124  void endTransaction(int cpu);
125  void profilePFWait(Time waitTime);
126
127  void controllerBusy(MachineID machID);
128  void bankBusy();
129  void missLatency(Time t, RubyRequestType type);
130  void swPrefetchLatency(Time t, CacheRequestType type, GenericMachineType respondingMach);
131  void sequencerRequests(int num) { m_sequencer_requests.add(num); }
132
133  void profileTransition(const string& component, NodeID version, Address addr,
134                         const string& state, const string& event,
135                         const string& next_state, const string& note);
136  void profileMsgDelay(int virtualNetwork, int delayCycles);
137
138  void print(ostream& out) const;
139
140  int64 getTotalTransactionsExecuted() const;
141
142  void rubyWatch(int proc);
143  bool watchAddress(Address addr);
144
145  // return Ruby's start time
146  Time getRubyStartTime(){
147    return m_ruby_start;
148  }
149
150  //added by SS
151  bool getHotLines() { return m_hot_lines; }
152  bool getAllInstructions() { return m_all_instructions; }
153
154private:
155
156  // Private copy constructor and assignment operator
157  Profiler(const Profiler& obj);
158  Profiler& operator=(const Profiler& obj);
159
160  // Data Members (m_ prefix)
161  AddressProfiler* m_address_profiler_ptr;
162  AddressProfiler* m_inst_profiler_ptr;
163
164  Vector<int64> m_instructions_executed_at_start;
165  Vector<int64> m_cycles_executed_at_start;
166
167  ostream* m_periodic_output_file_ptr;
168  integer_t m_stats_period;
169
170  Time m_ruby_start;
171  time_t m_real_time_start_time;
172
173  Vector<integer_t> m_perProcTotalMisses;
174  Vector<integer_t> m_perProcUserMisses;
175  Vector<integer_t> m_perProcSupervisorMisses;
176  Vector<integer_t> m_perProcStartTransaction;
177  Vector<integer_t> m_perProcEndTransaction;
178  Vector < Vector < integer_t > > m_busyControllerCount;
179  integer_t m_busyBankCount;
180  Histogram m_multicast_retry_histogram;
181
182  Histogram m_filter_action_histogram;
183  Histogram m_tbeProfile;
184
185  Histogram m_sequencer_requests;
186  Histogram m_read_sharing_histogram;
187  Histogram m_write_sharing_histogram;
188  Histogram m_all_sharing_histogram;
189  int64 m_cache_to_cache;
190  int64 m_memory_to_cache;
191
192  Histogram m_prefetchWaitHistogram;
193
194  Vector<Histogram> m_missLatencyHistograms;
195  Vector<Histogram> m_machLatencyHistograms;
196  Histogram m_allMissLatencyHistogram;
197
198  Histogram  m_allSWPrefetchLatencyHistogram;
199  Histogram  m_SWPrefetchL2MissLatencyHistogram;
200  Vector<Histogram> m_SWPrefetchLatencyHistograms;
201  Vector<Histogram> m_SWPrefetchMachLatencyHistograms;
202
203  Histogram m_delayedCyclesHistogram;
204  Histogram m_delayedCyclesNonPFHistogram;
205  Vector<Histogram> m_delayedCyclesVCHistograms;
206
207  Histogram m_outstanding_requests;
208  Histogram m_outstanding_persistent_requests;
209
210  Histogram m_average_latency_estimate;
211
212  Map<Address, int>* m_watch_address_list_ptr;
213  // counts all initiated cache request including PUTs
214  int m_requests;
215  Map <string, int>* m_requestProfileMap_ptr;
216
217  //added by SS
218  bool m_hot_lines;
219  bool m_all_instructions;
220
221  int m_num_of_sequencers;
222};
223
224// Output operator declaration
225ostream& operator<<(ostream& out, const Profiler& obj);
226
227// ******************* Definitions *******************
228
229// Output operator definition
230extern inline
231ostream& operator<<(ostream& out, const Profiler& obj)
232{
233  obj.print(out);
234  out << flush;
235  return out;
236}
237
238#endif //PROFILER_H
239
240
241