gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Profiler.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2013 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 
46 
47 #include <sys/types.h>
48 #include <unistd.h>
49 
50 #include <algorithm>
51 #include <fstream>
52 
53 #include "base/stl_helpers.hh"
54 #include "base/str.hh"
55 #include "mem/protocol/MachineType.hh"
56 #include "mem/protocol/RubyRequest.hh"
59 
73 #ifdef BUILD_GPU
75 #endif
76 
78 
79 using namespace std;
80 using m5::stl_helpers::operator<<;
81 
82 Profiler::Profiler(const RubySystemParams *p, RubySystem *rs)
83  : m_ruby_system(rs), m_hot_lines(p->hot_lines),
84  m_all_instructions(p->all_instructions),
85  m_num_vnets(p->number_of_virtual_networks)
86 {
87  m_address_profiler_ptr = new AddressProfiler(p->num_of_sequencers, this);
90 
91  if (m_all_instructions) {
92  m_inst_profiler_ptr = new AddressProfiler(p->num_of_sequencers, this);
95  }
96 }
97 
99 {
100 }
101 
102 void
103 Profiler::regStats(const std::string &pName)
104 {
105  if (!m_all_instructions) {
107  }
108 
109  if (m_all_instructions) {
111  }
112 
114  .init(10)
115  .name(pName + ".delayHist")
116  .desc("delay histogram for all message")
118 
119  for (int i = 0; i < m_num_vnets; i++) {
120  delayVCHistogram.push_back(new Stats::Histogram());
122  ->init(10)
123  .name(pName + csprintf(".delayVCHist.vnet_%i", i))
124  .desc(csprintf("delay histogram for vnet_%i", i))
126  }
127 
129  .init(10)
130  .name(pName + ".outstanding_req_hist_seqr")
131  .desc("")
133 
135  .init(10)
136  .name(pName + ".outstanding_req_hist_coalsr")
137  .desc("")
139 
141  .init(10)
142  .name(pName + ".latency_hist_seqr")
143  .desc("")
145 
147  .init(10)
148  .name(pName + ".latency_hist_coalsr")
149  .desc("")
151 
153  .init(10)
154  .name(pName + ".hit_latency_hist_seqr")
155  .desc("")
157 
159  .init(10)
160  .name(pName + ".miss_latency_hist_seqr")
161  .desc("")
163 
165  .init(10)
166  .name(pName + ".miss_latency_hist_coalsr")
167  .desc("")
169 
170  for (int i = 0; i < RubyRequestType_NUM; i++) {
171  m_typeLatencyHistSeqr.push_back(new Stats::Histogram());
173  ->init(10)
174  .name(pName + csprintf(".%s.latency_hist_seqr",
175  RubyRequestType(i)))
176  .desc("")
178 
179  m_typeLatencyHistCoalsr.push_back(new Stats::Histogram());
181  ->init(10)
182  .name(pName + csprintf(".%s.latency_hist_coalsr",
183  RubyRequestType(i)))
184  .desc("")
186 
189  ->init(10)
190  .name(pName + csprintf(".%s.hit_latency_hist_seqr",
191  RubyRequestType(i)))
192  .desc("")
194 
197  ->init(10)
198  .name(pName + csprintf(".%s.miss_latency_hist_seqr",
199  RubyRequestType(i)))
200  .desc("")
202 
205  ->init(10)
206  .name(pName + csprintf(".%s.miss_latency_hist_coalsr",
207  RubyRequestType(i)))
208  .desc("")
210  }
211 
212  for (int i = 0; i < MachineType_NUM; i++) {
215  ->init(10)
216  .name(pName + csprintf(".%s.hit_mach_latency_hist_seqr",
217  MachineType(i)))
218  .desc("")
220 
223  ->init(10)
224  .name(pName + csprintf(".%s.miss_mach_latency_hist_seqr",
225  MachineType(i)))
226  .desc("")
228 
231  ->init(10)
232  .name(pName + csprintf(".%s.miss_mach_latency_hist_coalsr",
233  MachineType(i)))
234  .desc("")
236 
239  ->init(10)
240  .name(pName + csprintf(
241  ".%s.miss_latency_hist_seqr.issue_to_initial_request",
242  MachineType(i)))
243  .desc("")
245 
248  ->init(10)
249  .name(pName + csprintf(
250  ".%s.miss_latency_hist_coalsr.issue_to_initial_request",
251  MachineType(i)))
252  .desc("")
254 
257  ->init(10)
258  .name(pName + csprintf(".%s.miss_latency_hist_seqr.initial_to_forward",
259  MachineType(i)))
260  .desc("")
262 
265  ->init(10)
266  .name(pName + csprintf(".%s.miss_latency_hist_coalsr.initial_to_forward",
267  MachineType(i)))
268  .desc("")
270 
273  ->init(10)
274  .name(pName + csprintf(
275  ".%s.miss_latency_hist_seqr.forward_to_first_response",
276  MachineType(i)))
277  .desc("")
279 
282  ->init(10)
283  .name(pName + csprintf(
284  ".%s.miss_latency_hist_coalsr.forward_to_first_response",
285  MachineType(i)))
286  .desc("")
288 
291  ->init(10)
292  .name(pName + csprintf(
293  ".%s.miss_latency_hist_seqr.first_response_to_completion",
294  MachineType(i)))
295  .desc("")
297 
300  ->init(10)
301  .name(pName + csprintf(
302  ".%s.miss_latency_hist_coalsr.first_response_to_completion",
303  MachineType(i)))
304  .desc("")
306 
308  .name(pName + csprintf(".%s.incomplete_times_seqr", MachineType(i)))
309  .desc("")
311  }
312 
313  for (int i = 0; i < RubyRequestType_NUM; i++) {
317 
318  for (int j = 0; j < MachineType_NUM; j++) {
321  ->init(10)
322  .name(pName + csprintf(".%s.%s.hit_type_mach_latency_hist_seqr",
323  RubyRequestType(i), MachineType(j)))
324  .desc("")
326 
329  ->init(10)
330  .name(pName + csprintf(".%s.%s.miss_type_mach_latency_hist_seqr",
331  RubyRequestType(i), MachineType(j)))
332  .desc("")
334 
337  ->init(10)
338  .name(pName + csprintf(".%s.%s.miss_type_mach_latency_hist_coalsr",
339  RubyRequestType(i), MachineType(j)))
340  .desc("")
342  }
343  }
344 }
345 
346 void
348 {
349  if (!m_all_instructions) {
351  }
352 
353  if (m_all_instructions) {
355  }
356 
357  for (uint32_t i = 0; i < MachineType_NUM; i++) {
358  for (map<uint32_t, AbstractController*>::iterator it =
360  it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
361 
362  AbstractController *ctr = (*it).second;
364 
365  for (uint32_t i = 0; i < m_num_vnets; i++) {
366  delayVCHistogram[i]->add(ctr->getDelayVCHist(i));
367  }
368  }
369  }
370 
371  for (uint32_t i = 0; i < MachineType_NUM; i++) {
372  for (map<uint32_t, AbstractController*>::iterator it =
374  it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
375 
376  AbstractController *ctr = (*it).second;
377  Sequencer *seq = ctr->getCPUSequencer();
378  if (seq != NULL) {
380  }
381 #ifdef BUILD_GPU
382  GPUCoalescer *coal = ctr->getGPUCoalescer();
383  if (coal != NULL) {
385  }
386 #endif
387  }
388  }
389 
390  for (uint32_t i = 0; i < MachineType_NUM; i++) {
391  for (map<uint32_t, AbstractController*>::iterator it =
393  it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
394 
395  AbstractController *ctr = (*it).second;
396  Sequencer *seq = ctr->getCPUSequencer();
397  if (seq != NULL) {
398  // add all the latencies
402 
403  // add the per request type latencies
404  for (uint32_t j = 0; j < RubyRequestType_NUM; ++j) {
406  ->add(seq->getTypeLatencyHist(j));
408  ->add(seq->getHitTypeLatencyHist(j));
410  ->add(seq->getMissTypeLatencyHist(j));
411  }
412 
413  // add the per machine type miss latencies
414  for (uint32_t j = 0; j < MachineType_NUM; ++j) {
416  ->add(seq->getHitMachLatencyHist(j));
418  ->add(seq->getMissMachLatencyHist(j));
419 
421  seq->getIssueToInitialDelayHist(MachineType(j)));
422 
424  seq->getInitialToForwardDelayHist(MachineType(j)));
426  getForwardRequestToFirstResponseHist(MachineType(j)));
427 
429  getFirstResponseToCompletionDelayHist(
430  MachineType(j)));
432  seq->getIncompleteTimes(MachineType(j));
433  }
434 
435  // add the per (request, machine) type miss latencies
436  for (uint32_t j = 0; j < RubyRequestType_NUM; j++) {
437  for (uint32_t k = 0; k < MachineType_NUM; k++) {
442  }
443  }
444  }
445 #ifdef BUILD_GPU
446  GPUCoalescer *coal = ctr->getGPUCoalescer();
447  if (coal != NULL) {
448  // add all the latencies
451 
452  // add the per request type latencies
453  for (uint32_t j = 0; j < RubyRequestType_NUM; ++j) {
455  ->add(coal->getTypeLatencyHist(j));
457  ->add(coal->getMissTypeLatencyHist(j));
458  }
459 
460  // add the per machine type miss latencies
461  for (uint32_t j = 0; j < MachineType_NUM; ++j) {
463  ->add(coal->getMissMachLatencyHist(j));
464 
466  coal->getIssueToInitialDelayHist(MachineType(j)));
467 
469  coal->getInitialToForwardDelayHist(MachineType(j)));
471  getForwardRequestToFirstResponseHist(MachineType(j)));
472 
474  getFirstResponseToCompletionDelayHist(
475  MachineType(j)));
476  }
477 
478  // add the per (request, machine) type miss latencies
479  for (uint32_t j = 0; j < RubyRequestType_NUM; j++) {
480  for (uint32_t k = 0; k < MachineType_NUM; k++) {
483  }
484  }
485  }
486 #endif
487  }
488  }
489 }
490 
491 void
493 {
494  if (msg.getType() != RubyRequestType_IFETCH) {
495  // Note: The following line should be commented out if you
496  // want to use the special profiling that is part of the GS320
497  // protocol
498 
499  // NOTE: Unless PROFILE_HOT_LINES is enabled, nothing will be
500  // profiled by the AddressProfiler
502  addTraceSample(msg.getLineAddress(), msg.getProgramCounter(),
503  msg.getType(), msg.getAccessMode(), id, false);
504  }
505 }
Stats::Histogram & getLatencyHist()
Stats::Histogram & getIssueToInitialDelayHist(uint32_t t) const
Definition: Sequencer.hh:133
const FlagsType pdf
Print the percent of the total that this entry represents.
Definition: info.hh:51
Stats::Histogram & getMissLatencyHist()
Definition: Sequencer.hh:121
Stats::Scalar m_IncompleteTimesSeqr[MachineType_NUM]
Definition: Profiler.hh:135
Stats::Histogram & getHitTypeLatencyHist(uint32_t t)
Definition: Sequencer.hh:112
Stats::Histogram m_hitLatencyHistSeqr
Histogram for holding latency profile of all requests that hit in the controller connected to this se...
Definition: Profiler.hh:108
std::vector< Stats::Histogram * > m_hitMachLatencyHistSeqr
Histograms for profiling the latencies for requests that did not required external messages...
Definition: Profiler.hh:113
std::vector< Stats::Histogram * > m_FirstResponseToCompletionDelayHistSeqr
Definition: Profiler.hh:134
std::vector< Stats::Histogram * > m_missTypeLatencyHistCoalsr
Definition: Profiler.hh:121
AddressProfiler * m_address_profiler_ptr
Definition: Profiler.hh:90
Bitfield< 7 > i
Definition: miscregs.hh:1378
void collateStats()
Definition: Profiler.cc:347
Stats::Histogram & getTypeLatencyHist(uint32_t t)
Definition: Sequencer.hh:108
std::vector< Stats::Histogram * > m_typeLatencyHistCoalsr
Definition: Profiler.hh:104
std::vector< Stats::Histogram * > m_IssueToInitialDelayHistCoalsr
Definition: Profiler.hh:136
std::vector< Stats::Histogram * > m_hitTypeLatencyHistSeqr
Definition: Profiler.hh:109
Stats::Histogram & getMissTypeMachLatencyHist(uint32_t r, uint32_t t) const
Definition: Sequencer.hh:130
Stats::Histogram & getMissTypeLatencyHist(uint32_t t)
const RubyRequestType & getType() const
Definition: RubyRequest.hh:149
Histogram & init(size_type size)
Set the parameters of this histogram.
Definition: statistics.hh:2560
const bool m_hot_lines
Definition: Profiler.hh:142
Stats::Histogram & getHitTypeMachLatencyHist(uint32_t r, uint32_t t)
Definition: Sequencer.hh:118
void setHotLines(bool hot_lines)
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Definition: statistics.hh:311
std::vector< Stats::Histogram * > delayVCHistogram
Definition: Profiler.hh:94
std::vector< Stats::Histogram * > m_typeLatencyHistSeqr
Definition: Profiler.hh:103
unsigned int NodeID
Definition: TypeDefines.hh:34
std::vector< Stats::Histogram * > m_missTypeLatencyHistSeqr
Definition: Profiler.hh:120
Stats::Histogram & getMissMachLatencyHist(uint32_t t) const
Definition: Sequencer.hh:126
Stats::Histogram delayHistogram
Definition: Profiler.hh:93
std::vector< Stats::Histogram * > m_ForwardToFirstResponseDelayHistCoalsr
Definition: Profiler.hh:138
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
void addAddressTraceSample(const RubyRequest &msg, NodeID id)
Definition: Profiler.cc:492
Addr getLineAddress() const
Definition: RubyRequest.hh:147
std::vector< std::vector< Stats::Histogram * > > m_hitTypeMachLatencyHistSeqr
Definition: Profiler.hh:114
Stats::Histogram m_outstandReqHistSeqr
Histogram for number of outstanding requests per cycle.
Definition: Profiler.hh:97
Stats::Histogram & getOutstandReqHist()
Definition: Sequencer.hh:105
std::vector< Stats::Histogram * > m_FirstResponseToCompletionDelayHistCoalsr
Definition: Profiler.hh:139
Bitfield< 23 > k
Definition: dt_constants.hh:80
Stats::Histogram & getIssueToInitialDelayHist(uint32_t t) const
Stats::Histogram & getHitLatencyHist()
Definition: Sequencer.hh:111
Stats::Histogram & getLatencyHist()
Definition: Sequencer.hh:107
const FlagsType oneline
Print all values on a single line.
Definition: info.hh:61
std::vector< std::map< uint32_t, AbstractController * > > m_abstract_controls
Definition: RubySystem.hh:153
Stats::Histogram & getDelayVCHist(uint32_t index)
std::vector< std::vector< Stats::Histogram * > > m_missTypeMachLatencyHistSeqr
Definition: Profiler.hh:126
A simple histogram stat.
Definition: statistics.hh:2551
Stats::Histogram & getHitMachLatencyHist(uint32_t t)
Definition: Sequencer.hh:115
const RubyAccessMode & getAccessMode() const
Definition: RubyRequest.hh:151
std::vector< Stats::Histogram * > m_InitialToForwardDelayHistSeqr
Definition: Profiler.hh:132
Stats::Histogram m_missLatencyHistSeqr
Histogram for holding latency profile of all requests that miss in the controller connected to this s...
Definition: Profiler.hh:118
void regStats(const std::string &name)
Definition: Profiler.cc:103
RubySystem * m_ruby_system
Definition: Profiler.hh:70
Stats::Histogram & getInitialToForwardDelayHist(const MachineType t) const
std::vector< Stats::Histogram * > m_InitialToForwardDelayHistCoalsr
Definition: Profiler.hh:137
Stats::Histogram & getMissTypeMachLatencyHist(uint32_t r, uint32_t t) const
Stats::Histogram & getInitialToForwardDelayHist(const MachineType t) const
Definition: Sequencer.hh:137
const uint32_t m_num_vnets
Definition: Profiler.hh:144
Stats::Histogram & getOutstandReqHist()
Bitfield< 24 > j
Definition: miscregs.hh:1369
virtual Sequencer * getCPUSequencer() const =0
void setAllInstructions(bool all_instructions)
Stats::Histogram m_outstandReqHistCoalsr
Definition: Profiler.hh:98
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:254
Stats::Histogram & getMissLatencyHist()
Stats::Histogram & getTypeLatencyHist(uint32_t t)
Stats::Counter getIncompleteTimes(const MachineType t) const
Definition: Sequencer.hh:148
std::vector< Stats::Histogram * > m_ForwardToFirstResponseDelayHistSeqr
Definition: Profiler.hh:133
void add(DistBase &d)
Add the argument distribution to the this distribution.
Definition: statistics.hh:1901
Stats::Histogram & getDelayHist()
Stats::Histogram m_latencyHistCoalsr
Definition: Profiler.hh:102
virtual GPUCoalescer * getGPUCoalescer() const =0
const bool m_all_instructions
Definition: Profiler.hh:143
AddressProfiler * m_inst_profiler_ptr
Definition: Profiler.hh:91
Addr getProgramCounter() const
Definition: RubyRequest.hh:150
Stats::Histogram & getMissTypeLatencyHist(uint32_t t)
Definition: Sequencer.hh:123
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:287
std::vector< Stats::Histogram * > m_missMachLatencyHistCoalsr
Definition: Profiler.hh:127
~Profiler()
Definition: Profiler.cc:98
std::vector< std::vector< Stats::Histogram * > > m_missTypeMachLatencyHistCoalsr
Definition: Profiler.hh:128
Stats::Histogram m_latencyHistSeqr
Histogram for holding latency profile of all requests.
Definition: Profiler.hh:101
Stats::Histogram & getMissMachLatencyHist(uint32_t t) const
Bitfield< 11 > id
Definition: miscregs.hh:124
const FlagsType nozero
Don't print if this is zero.
Definition: info.hh:57
Bitfield< 0 > p
Bitfield< 9, 8 > rs
Definition: miscregs.hh:1560
std::vector< Stats::Histogram * > m_IssueToInitialDelayHistSeqr
Histograms for recording the breakdown of miss latency.
Definition: Profiler.hh:131
Stats::Histogram m_missLatencyHistCoalsr
Definition: Profiler.hh:119
Profiler(const RubySystemParams *params, RubySystem *rs)
Definition: Profiler.cc:82
std::vector< Stats::Histogram * > m_missMachLatencyHistSeqr
Histograms for profiling the latencies for requests that required external messages.
Definition: Profiler.hh:125
void regStats(const std::string &name)

Generated on Fri Jun 9 2017 13:03:50 for gem5 by doxygen 1.8.6