Profiler.cc revision 11798
16145Snate@binkert.org/*
210012Snilay@cs.wisc.edu * Copyright (c) 1999-2013 Mark D. Hill and David A. Wood
36145Snate@binkert.org * All rights reserved.
46145Snate@binkert.org *
56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66145Snate@binkert.org * modification, are permitted provided that the following conditions are
76145Snate@binkert.org * met: redistributions of source code must retain the above copyright
86145Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116145Snate@binkert.org * documentation and/or other materials provided with the distribution;
126145Snate@binkert.org * neither the name of the copyright holders nor the names of its
136145Snate@binkert.org * contributors may be used to endorse or promote products derived from
146145Snate@binkert.org * this software without specific prior written permission.
156145Snate@binkert.org *
166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145Snate@binkert.org */
286145Snate@binkert.org
296145Snate@binkert.org/*
306145Snate@binkert.org   This file has been modified by Kevin Moore and Dan Nussbaum of the
316145Snate@binkert.org   Scalable Systems Research Group at Sun Microsystems Laboratories
326145Snate@binkert.org   (http://research.sun.com/scalable/) to support the Adaptive
336145Snate@binkert.org   Transactional Memory Test Platform (ATMTP).
346145Snate@binkert.org
356145Snate@binkert.org   Please send email to atmtp-interest@sun.com with feedback, questions, or
366145Snate@binkert.org   to request future announcements about ATMTP.
376145Snate@binkert.org
386145Snate@binkert.org   ----------------------------------------------------------------------
396145Snate@binkert.org
406145Snate@binkert.org   File modification date: 2008-02-23
416145Snate@binkert.org
426145Snate@binkert.org   ----------------------------------------------------------------------
436145Snate@binkert.org*/
446145Snate@binkert.org
4511309Sdavid.hashe@amd.com#include "mem/ruby/profiler/Profiler.hh"
4611309Sdavid.hashe@amd.com
478946Sandreas.hansson@arm.com#include <sys/types.h>
488946Sandreas.hansson@arm.com#include <unistd.h>
497002Snate@binkert.org
507454Snate@binkert.org#include <algorithm>
517832Snate@binkert.org#include <fstream>
527454Snate@binkert.org
537454Snate@binkert.org#include "base/stl_helpers.hh"
547056Snate@binkert.org#include "base/str.hh"
557048Snate@binkert.org#include "mem/protocol/MachineType.hh"
568229Snate@binkert.org#include "mem/protocol/RubyRequest.hh"
577048Snate@binkert.org#include "mem/ruby/network/Network.hh"
587048Snate@binkert.org#include "mem/ruby/profiler/AddressProfiler.hh"
5911798Santhony.gutierrez@amd.com
6011798Santhony.gutierrez@amd.com/**
6111798Santhony.gutierrez@amd.com * the profiler uses GPUCoalescer code even
6211798Santhony.gutierrez@amd.com * though the GPUCoalescer is not built for
6311798Santhony.gutierrez@amd.com * all ISAs, which can lead to run/link time
6411798Santhony.gutierrez@amd.com * errors. here we guard the coalescer code
6511798Santhony.gutierrez@amd.com * with ifdefs as there is no easy way to
6611798Santhony.gutierrez@amd.com * refactor this code without removing
6711798Santhony.gutierrez@amd.com * GPUCoalescer stats from the profiler.
6811798Santhony.gutierrez@amd.com *
6911798Santhony.gutierrez@amd.com * eventually we should use probe points
7011798Santhony.gutierrez@amd.com * here, but until then these ifdefs will
7111798Santhony.gutierrez@amd.com * serve.
7211798Santhony.gutierrez@amd.com */
7311798Santhony.gutierrez@amd.com#ifdef BUILD_GPU
7411309Sdavid.hashe@amd.com#include "mem/ruby/system/GPUCoalescer.hh"
7511798Santhony.gutierrez@amd.com#endif
7611798Santhony.gutierrez@amd.com
779598Snilay@cs.wisc.edu#include "mem/ruby/system/Sequencer.hh"
786876Ssteve.reinhardt@amd.com
797055Snate@binkert.orgusing namespace std;
807454Snate@binkert.orgusing m5::stl_helpers::operator<<;
817055Snate@binkert.org
8210920Sbrandon.potter@amd.comProfiler::Profiler(const RubySystemParams *p, RubySystem *rs)
8311172Snilay@cs.wisc.edu    : m_ruby_system(rs), m_hot_lines(p->hot_lines),
8411172Snilay@cs.wisc.edu      m_all_instructions(p->all_instructions),
8511172Snilay@cs.wisc.edu      m_num_vnets(p->number_of_virtual_networks)
866145Snate@binkert.org{
8710919Sbrandon.potter@amd.com    m_address_profiler_ptr = new AddressProfiler(p->num_of_sequencers, this);
887048Snate@binkert.org    m_address_profiler_ptr->setHotLines(m_hot_lines);
897048Snate@binkert.org    m_address_profiler_ptr->setAllInstructions(m_all_instructions);
906285Snate@binkert.org
917048Snate@binkert.org    if (m_all_instructions) {
9210919Sbrandon.potter@amd.com        m_inst_profiler_ptr = new AddressProfiler(p->num_of_sequencers, this);
937048Snate@binkert.org        m_inst_profiler_ptr->setHotLines(m_hot_lines);
947048Snate@binkert.org        m_inst_profiler_ptr->setAllInstructions(m_all_instructions);
957048Snate@binkert.org    }
966285Snate@binkert.org}
976285Snate@binkert.org
986889SBrad.Beckmann@amd.comProfiler::~Profiler()
996889SBrad.Beckmann@amd.com{
1007048Snate@binkert.org}
1017048Snate@binkert.org
1027048Snate@binkert.orgvoid
10310012Snilay@cs.wisc.eduProfiler::regStats(const std::string &pName)
1047048Snate@binkert.org{
10510012Snilay@cs.wisc.edu    if (!m_all_instructions) {
10610012Snilay@cs.wisc.edu        m_address_profiler_ptr->regStats(pName);
10710012Snilay@cs.wisc.edu    }
10810012Snilay@cs.wisc.edu
10910012Snilay@cs.wisc.edu    if (m_all_instructions) {
11010012Snilay@cs.wisc.edu        m_inst_profiler_ptr->regStats(pName);
11110012Snilay@cs.wisc.edu    }
11210012Snilay@cs.wisc.edu
11310012Snilay@cs.wisc.edu    delayHistogram
11410012Snilay@cs.wisc.edu        .init(10)
11510012Snilay@cs.wisc.edu        .name(pName + ".delayHist")
11610012Snilay@cs.wisc.edu        .desc("delay histogram for all message")
11710012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
11810012Snilay@cs.wisc.edu
11911172Snilay@cs.wisc.edu    for (int i = 0; i < m_num_vnets; i++) {
12010012Snilay@cs.wisc.edu        delayVCHistogram.push_back(new Stats::Histogram());
12110012Snilay@cs.wisc.edu        delayVCHistogram[i]
12210012Snilay@cs.wisc.edu            ->init(10)
12310012Snilay@cs.wisc.edu            .name(pName + csprintf(".delayVCHist.vnet_%i", i))
12410012Snilay@cs.wisc.edu            .desc(csprintf("delay histogram for vnet_%i", i))
12510012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
12610012Snilay@cs.wisc.edu    }
12710012Snilay@cs.wisc.edu
12811309Sdavid.hashe@amd.com    m_outstandReqHistSeqr
12910012Snilay@cs.wisc.edu        .init(10)
13011309Sdavid.hashe@amd.com        .name(pName + ".outstanding_req_hist_seqr")
13110012Snilay@cs.wisc.edu        .desc("")
13210012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
13310012Snilay@cs.wisc.edu
13411309Sdavid.hashe@amd.com    m_outstandReqHistCoalsr
13510012Snilay@cs.wisc.edu        .init(10)
13611309Sdavid.hashe@amd.com        .name(pName + ".outstanding_req_hist_coalsr")
13710012Snilay@cs.wisc.edu        .desc("")
13810012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
13910012Snilay@cs.wisc.edu
14011309Sdavid.hashe@amd.com    m_latencyHistSeqr
14110012Snilay@cs.wisc.edu        .init(10)
14211309Sdavid.hashe@amd.com        .name(pName + ".latency_hist_seqr")
14310012Snilay@cs.wisc.edu        .desc("")
14410012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
14510012Snilay@cs.wisc.edu
14611309Sdavid.hashe@amd.com    m_latencyHistCoalsr
14710012Snilay@cs.wisc.edu        .init(10)
14811309Sdavid.hashe@amd.com        .name(pName + ".latency_hist_coalsr")
14911309Sdavid.hashe@amd.com        .desc("")
15011309Sdavid.hashe@amd.com        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
15111309Sdavid.hashe@amd.com
15211309Sdavid.hashe@amd.com    m_hitLatencyHistSeqr
15311309Sdavid.hashe@amd.com        .init(10)
15411309Sdavid.hashe@amd.com        .name(pName + ".hit_latency_hist_seqr")
15511309Sdavid.hashe@amd.com        .desc("")
15611309Sdavid.hashe@amd.com        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
15711309Sdavid.hashe@amd.com
15811309Sdavid.hashe@amd.com    m_missLatencyHistSeqr
15911309Sdavid.hashe@amd.com        .init(10)
16011309Sdavid.hashe@amd.com        .name(pName + ".miss_latency_hist_seqr")
16111309Sdavid.hashe@amd.com        .desc("")
16211309Sdavid.hashe@amd.com        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
16311309Sdavid.hashe@amd.com
16411309Sdavid.hashe@amd.com    m_missLatencyHistCoalsr
16511309Sdavid.hashe@amd.com        .init(10)
16611309Sdavid.hashe@amd.com        .name(pName + ".miss_latency_hist_coalsr")
16710012Snilay@cs.wisc.edu        .desc("")
16810012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
16910012Snilay@cs.wisc.edu
17010012Snilay@cs.wisc.edu    for (int i = 0; i < RubyRequestType_NUM; i++) {
17111309Sdavid.hashe@amd.com        m_typeLatencyHistSeqr.push_back(new Stats::Histogram());
17211309Sdavid.hashe@amd.com        m_typeLatencyHistSeqr[i]
17310012Snilay@cs.wisc.edu            ->init(10)
17411309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.latency_hist_seqr",
17510012Snilay@cs.wisc.edu                                    RubyRequestType(i)))
17610012Snilay@cs.wisc.edu            .desc("")
17710012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
17810012Snilay@cs.wisc.edu
17911309Sdavid.hashe@amd.com        m_typeLatencyHistCoalsr.push_back(new Stats::Histogram());
18011309Sdavid.hashe@amd.com        m_typeLatencyHistCoalsr[i]
18110012Snilay@cs.wisc.edu            ->init(10)
18211309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.latency_hist_coalsr",
18310012Snilay@cs.wisc.edu                                    RubyRequestType(i)))
18410012Snilay@cs.wisc.edu            .desc("")
18510012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
18610012Snilay@cs.wisc.edu
18711309Sdavid.hashe@amd.com        m_hitTypeLatencyHistSeqr.push_back(new Stats::Histogram());
18811309Sdavid.hashe@amd.com        m_hitTypeLatencyHistSeqr[i]
18910012Snilay@cs.wisc.edu            ->init(10)
19011309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.hit_latency_hist_seqr",
19111309Sdavid.hashe@amd.com                                    RubyRequestType(i)))
19211309Sdavid.hashe@amd.com            .desc("")
19311309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
19411309Sdavid.hashe@amd.com
19511309Sdavid.hashe@amd.com        m_missTypeLatencyHistSeqr.push_back(new Stats::Histogram());
19611309Sdavid.hashe@amd.com        m_missTypeLatencyHistSeqr[i]
19711309Sdavid.hashe@amd.com            ->init(10)
19811309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_seqr",
19911309Sdavid.hashe@amd.com                                    RubyRequestType(i)))
20011309Sdavid.hashe@amd.com            .desc("")
20111309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
20211309Sdavid.hashe@amd.com
20311309Sdavid.hashe@amd.com        m_missTypeLatencyHistCoalsr.push_back(new Stats::Histogram());
20411309Sdavid.hashe@amd.com        m_missTypeLatencyHistCoalsr[i]
20511309Sdavid.hashe@amd.com            ->init(10)
20611309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_coalsr",
20710012Snilay@cs.wisc.edu                                    RubyRequestType(i)))
20810012Snilay@cs.wisc.edu            .desc("")
20910012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
21010012Snilay@cs.wisc.edu    }
21110012Snilay@cs.wisc.edu
21210012Snilay@cs.wisc.edu    for (int i = 0; i < MachineType_NUM; i++) {
21311309Sdavid.hashe@amd.com        m_hitMachLatencyHistSeqr.push_back(new Stats::Histogram());
21411309Sdavid.hashe@amd.com        m_hitMachLatencyHistSeqr[i]
21510012Snilay@cs.wisc.edu            ->init(10)
21611309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.hit_mach_latency_hist_seqr",
21710012Snilay@cs.wisc.edu                                    MachineType(i)))
21810012Snilay@cs.wisc.edu            .desc("")
21910012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
22010012Snilay@cs.wisc.edu
22111309Sdavid.hashe@amd.com        m_missMachLatencyHistSeqr.push_back(new Stats::Histogram());
22211309Sdavid.hashe@amd.com        m_missMachLatencyHistSeqr[i]
22310012Snilay@cs.wisc.edu            ->init(10)
22411309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_mach_latency_hist_seqr",
22510012Snilay@cs.wisc.edu                                    MachineType(i)))
22610012Snilay@cs.wisc.edu            .desc("")
22710012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
22810012Snilay@cs.wisc.edu
22911309Sdavid.hashe@amd.com        m_missMachLatencyHistCoalsr.push_back(new Stats::Histogram());
23011309Sdavid.hashe@amd.com        m_missMachLatencyHistCoalsr[i]
23111309Sdavid.hashe@amd.com            ->init(10)
23211309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_mach_latency_hist_coalsr",
23311309Sdavid.hashe@amd.com                                    MachineType(i)))
23411309Sdavid.hashe@amd.com            .desc("")
23511309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
23611309Sdavid.hashe@amd.com
23711309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistSeqr.push_back(new Stats::Histogram());
23811309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistSeqr[i]
23910012Snilay@cs.wisc.edu            ->init(10)
24010012Snilay@cs.wisc.edu            .name(pName + csprintf(
24111309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_seqr.issue_to_initial_request",
24210012Snilay@cs.wisc.edu                MachineType(i)))
24310012Snilay@cs.wisc.edu            .desc("")
24410012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
24510012Snilay@cs.wisc.edu
24611309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistCoalsr.push_back(new Stats::Histogram());
24711309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistCoalsr[i]
24810012Snilay@cs.wisc.edu            ->init(10)
24911309Sdavid.hashe@amd.com            .name(pName + csprintf(
25011309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_coalsr.issue_to_initial_request",
25111309Sdavid.hashe@amd.com                MachineType(i)))
25211309Sdavid.hashe@amd.com            .desc("")
25311309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
25411309Sdavid.hashe@amd.com
25511309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistSeqr.push_back(new Stats::Histogram());
25611309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistSeqr[i]
25711309Sdavid.hashe@amd.com            ->init(10)
25811309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_seqr.initial_to_forward",
25910012Snilay@cs.wisc.edu                                   MachineType(i)))
26010012Snilay@cs.wisc.edu            .desc("")
26110012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
26210012Snilay@cs.wisc.edu
26311309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistCoalsr.push_back(new Stats::Histogram());
26411309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistCoalsr[i]
26511309Sdavid.hashe@amd.com            ->init(10)
26611309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_coalsr.initial_to_forward",
26711309Sdavid.hashe@amd.com                                   MachineType(i)))
26811309Sdavid.hashe@amd.com            .desc("")
26911309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
27011309Sdavid.hashe@amd.com
27111309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistSeqr.push_back(new Stats::Histogram());
27211309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistSeqr[i]
27310012Snilay@cs.wisc.edu            ->init(10)
27410012Snilay@cs.wisc.edu            .name(pName + csprintf(
27511309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_seqr.forward_to_first_response",
27610012Snilay@cs.wisc.edu                MachineType(i)))
27710012Snilay@cs.wisc.edu            .desc("")
27810012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
27910012Snilay@cs.wisc.edu
28011309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistCoalsr.push_back(new Stats::Histogram());
28111309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistCoalsr[i]
28210012Snilay@cs.wisc.edu            ->init(10)
28310012Snilay@cs.wisc.edu            .name(pName + csprintf(
28411309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_coalsr.forward_to_first_response",
28510012Snilay@cs.wisc.edu                MachineType(i)))
28610012Snilay@cs.wisc.edu            .desc("")
28710012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
28810012Snilay@cs.wisc.edu
28911309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistSeqr.push_back(new Stats::Histogram());
29011309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistSeqr[i]
29111309Sdavid.hashe@amd.com            ->init(10)
29211309Sdavid.hashe@amd.com            .name(pName + csprintf(
29311309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_seqr.first_response_to_completion",
29411309Sdavid.hashe@amd.com                MachineType(i)))
29511309Sdavid.hashe@amd.com            .desc("")
29611309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
29711309Sdavid.hashe@amd.com
29811309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistCoalsr.push_back(new Stats::Histogram());
29911309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistCoalsr[i]
30011309Sdavid.hashe@amd.com            ->init(10)
30111309Sdavid.hashe@amd.com            .name(pName + csprintf(
30211309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_coalsr.first_response_to_completion",
30311309Sdavid.hashe@amd.com                MachineType(i)))
30411309Sdavid.hashe@amd.com            .desc("")
30511309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
30611309Sdavid.hashe@amd.com
30711309Sdavid.hashe@amd.com        m_IncompleteTimesSeqr[i]
30811309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.incomplete_times_seqr", MachineType(i)))
30910012Snilay@cs.wisc.edu            .desc("")
31010012Snilay@cs.wisc.edu            .flags(Stats::nozero);
31110012Snilay@cs.wisc.edu    }
31210012Snilay@cs.wisc.edu
31310012Snilay@cs.wisc.edu    for (int i = 0; i < RubyRequestType_NUM; i++) {
31411309Sdavid.hashe@amd.com        m_hitTypeMachLatencyHistSeqr.push_back(std::vector<Stats::Histogram *>());
31511309Sdavid.hashe@amd.com        m_missTypeMachLatencyHistSeqr.push_back(std::vector<Stats::Histogram *>());
31611309Sdavid.hashe@amd.com        m_missTypeMachLatencyHistCoalsr.push_back(std::vector<Stats::Histogram *>());
31710012Snilay@cs.wisc.edu
31810012Snilay@cs.wisc.edu        for (int j = 0; j < MachineType_NUM; j++) {
31911309Sdavid.hashe@amd.com            m_hitTypeMachLatencyHistSeqr[i].push_back(new Stats::Histogram());
32011309Sdavid.hashe@amd.com            m_hitTypeMachLatencyHistSeqr[i][j]
32110012Snilay@cs.wisc.edu                ->init(10)
32211309Sdavid.hashe@amd.com                .name(pName + csprintf(".%s.%s.hit_type_mach_latency_hist_seqr",
32310012Snilay@cs.wisc.edu                                       RubyRequestType(i), MachineType(j)))
32410012Snilay@cs.wisc.edu                .desc("")
32510012Snilay@cs.wisc.edu                .flags(Stats::nozero | Stats::pdf | Stats::oneline);
32610012Snilay@cs.wisc.edu
32711309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistSeqr[i].push_back(new Stats::Histogram());
32811309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistSeqr[i][j]
32910012Snilay@cs.wisc.edu                ->init(10)
33011309Sdavid.hashe@amd.com                .name(pName + csprintf(".%s.%s.miss_type_mach_latency_hist_seqr",
33111309Sdavid.hashe@amd.com                                       RubyRequestType(i), MachineType(j)))
33211309Sdavid.hashe@amd.com                .desc("")
33311309Sdavid.hashe@amd.com                .flags(Stats::nozero | Stats::pdf | Stats::oneline);
33411309Sdavid.hashe@amd.com
33511309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistCoalsr[i].push_back(new Stats::Histogram());
33611309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistCoalsr[i][j]
33711309Sdavid.hashe@amd.com                ->init(10)
33811309Sdavid.hashe@amd.com                .name(pName + csprintf(".%s.%s.miss_type_mach_latency_hist_coalsr",
33910012Snilay@cs.wisc.edu                                       RubyRequestType(i), MachineType(j)))
34010012Snilay@cs.wisc.edu                .desc("")
34110012Snilay@cs.wisc.edu                .flags(Stats::nozero | Stats::pdf | Stats::oneline);
34210012Snilay@cs.wisc.edu        }
34310012Snilay@cs.wisc.edu    }
3447048Snate@binkert.org}
3457048Snate@binkert.org
3467048Snate@binkert.orgvoid
34710012Snilay@cs.wisc.eduProfiler::collateStats()
3489496Snilay@cs.wisc.edu{
34910012Snilay@cs.wisc.edu    if (!m_all_instructions) {
35010012Snilay@cs.wisc.edu        m_address_profiler_ptr->collateStats();
3519496Snilay@cs.wisc.edu    }
3529496Snilay@cs.wisc.edu
35310012Snilay@cs.wisc.edu    if (m_all_instructions) {
35410012Snilay@cs.wisc.edu        m_inst_profiler_ptr->collateStats();
3559496Snilay@cs.wisc.edu    }
3569497Snilay@cs.wisc.edu
3579497Snilay@cs.wisc.edu    for (uint32_t i = 0; i < MachineType_NUM; i++) {
3589497Snilay@cs.wisc.edu        for (map<uint32_t, AbstractController*>::iterator it =
35910920Sbrandon.potter@amd.com                  m_ruby_system->m_abstract_controls[i].begin();
36010920Sbrandon.potter@amd.com             it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
3619497Snilay@cs.wisc.edu
3629497Snilay@cs.wisc.edu            AbstractController *ctr = (*it).second;
3639497Snilay@cs.wisc.edu            delayHistogram.add(ctr->getDelayHist());
3649497Snilay@cs.wisc.edu
36511172Snilay@cs.wisc.edu            for (uint32_t i = 0; i < m_num_vnets; i++) {
36610012Snilay@cs.wisc.edu                delayVCHistogram[i]->add(ctr->getDelayVCHist(i));
3679497Snilay@cs.wisc.edu            }
3689497Snilay@cs.wisc.edu        }
3699497Snilay@cs.wisc.edu    }
3709497Snilay@cs.wisc.edu
3719598Snilay@cs.wisc.edu    for (uint32_t i = 0; i < MachineType_NUM; i++) {
3729598Snilay@cs.wisc.edu        for (map<uint32_t, AbstractController*>::iterator it =
37310920Sbrandon.potter@amd.com                m_ruby_system->m_abstract_controls[i].begin();
37410920Sbrandon.potter@amd.com                it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
3759598Snilay@cs.wisc.edu
3769598Snilay@cs.wisc.edu            AbstractController *ctr = (*it).second;
37711308Santhony.gutierrez@amd.com            Sequencer *seq = ctr->getCPUSequencer();
3789598Snilay@cs.wisc.edu            if (seq != NULL) {
37911309Sdavid.hashe@amd.com                m_outstandReqHistSeqr.add(seq->getOutstandReqHist());
38011309Sdavid.hashe@amd.com            }
38111798Santhony.gutierrez@amd.com#ifdef BUILD_GPU
38211309Sdavid.hashe@amd.com            GPUCoalescer *coal = ctr->getGPUCoalescer();
38311309Sdavid.hashe@amd.com            if (coal != NULL) {
38411309Sdavid.hashe@amd.com                m_outstandReqHistCoalsr.add(coal->getOutstandReqHist());
3859598Snilay@cs.wisc.edu            }
38611798Santhony.gutierrez@amd.com#endif
3879598Snilay@cs.wisc.edu        }
3889598Snilay@cs.wisc.edu    }
3899598Snilay@cs.wisc.edu
3909773Snilay@cs.wisc.edu    for (uint32_t i = 0; i < MachineType_NUM; i++) {
3919773Snilay@cs.wisc.edu        for (map<uint32_t, AbstractController*>::iterator it =
39210920Sbrandon.potter@amd.com                m_ruby_system->m_abstract_controls[i].begin();
39310920Sbrandon.potter@amd.com                it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
3949773Snilay@cs.wisc.edu
3959773Snilay@cs.wisc.edu            AbstractController *ctr = (*it).second;
39611308Santhony.gutierrez@amd.com            Sequencer *seq = ctr->getCPUSequencer();
3979773Snilay@cs.wisc.edu            if (seq != NULL) {
3989773Snilay@cs.wisc.edu                // add all the latencies
39911309Sdavid.hashe@amd.com                m_latencyHistSeqr.add(seq->getLatencyHist());
40011309Sdavid.hashe@amd.com                m_hitLatencyHistSeqr.add(seq->getHitLatencyHist());
40111309Sdavid.hashe@amd.com                m_missLatencyHistSeqr.add(seq->getMissLatencyHist());
4029773Snilay@cs.wisc.edu
4039773Snilay@cs.wisc.edu                // add the per request type latencies
4049773Snilay@cs.wisc.edu                for (uint32_t j = 0; j < RubyRequestType_NUM; ++j) {
40511309Sdavid.hashe@amd.com                    m_typeLatencyHistSeqr[j]
40610012Snilay@cs.wisc.edu                        ->add(seq->getTypeLatencyHist(j));
40711309Sdavid.hashe@amd.com                    m_hitTypeLatencyHistSeqr[j]
40810012Snilay@cs.wisc.edu                        ->add(seq->getHitTypeLatencyHist(j));
40911309Sdavid.hashe@amd.com                    m_missTypeLatencyHistSeqr[j]
41010012Snilay@cs.wisc.edu                        ->add(seq->getMissTypeLatencyHist(j));
4119773Snilay@cs.wisc.edu                }
4129773Snilay@cs.wisc.edu
4139773Snilay@cs.wisc.edu                // add the per machine type miss latencies
4149773Snilay@cs.wisc.edu                for (uint32_t j = 0; j < MachineType_NUM; ++j) {
41511309Sdavid.hashe@amd.com                    m_hitMachLatencyHistSeqr[j]
41610012Snilay@cs.wisc.edu                        ->add(seq->getHitMachLatencyHist(j));
41711309Sdavid.hashe@amd.com                    m_missMachLatencyHistSeqr[j]
41810012Snilay@cs.wisc.edu                        ->add(seq->getMissMachLatencyHist(j));
4199773Snilay@cs.wisc.edu
42011309Sdavid.hashe@amd.com                    m_IssueToInitialDelayHistSeqr[j]->add(
4219773Snilay@cs.wisc.edu                        seq->getIssueToInitialDelayHist(MachineType(j)));
4229773Snilay@cs.wisc.edu
42311309Sdavid.hashe@amd.com                    m_InitialToForwardDelayHistSeqr[j]->add(
4249773Snilay@cs.wisc.edu                        seq->getInitialToForwardDelayHist(MachineType(j)));
42511309Sdavid.hashe@amd.com                    m_ForwardToFirstResponseDelayHistSeqr[j]->add(seq->
4269773Snilay@cs.wisc.edu                        getForwardRequestToFirstResponseHist(MachineType(j)));
4279773Snilay@cs.wisc.edu
42811309Sdavid.hashe@amd.com                    m_FirstResponseToCompletionDelayHistSeqr[j]->add(seq->
42910012Snilay@cs.wisc.edu                        getFirstResponseToCompletionDelayHist(
43010012Snilay@cs.wisc.edu                            MachineType(j)));
43111309Sdavid.hashe@amd.com                    m_IncompleteTimesSeqr[j] +=
4329773Snilay@cs.wisc.edu                        seq->getIncompleteTimes(MachineType(j));
4339773Snilay@cs.wisc.edu                }
4349773Snilay@cs.wisc.edu
4359773Snilay@cs.wisc.edu                // add the per (request, machine) type miss latencies
4369773Snilay@cs.wisc.edu                for (uint32_t j = 0; j < RubyRequestType_NUM; j++) {
4379773Snilay@cs.wisc.edu                    for (uint32_t k = 0; k < MachineType_NUM; k++) {
43811309Sdavid.hashe@amd.com                        m_hitTypeMachLatencyHistSeqr[j][k]->add(
43910012Snilay@cs.wisc.edu                                seq->getHitTypeMachLatencyHist(j,k));
44011309Sdavid.hashe@amd.com                        m_missTypeMachLatencyHistSeqr[j][k]->add(
44110012Snilay@cs.wisc.edu                                seq->getMissTypeMachLatencyHist(j,k));
4429773Snilay@cs.wisc.edu                    }
4439773Snilay@cs.wisc.edu                }
4449773Snilay@cs.wisc.edu            }
44511798Santhony.gutierrez@amd.com#ifdef BUILD_GPU
44611309Sdavid.hashe@amd.com            GPUCoalescer *coal = ctr->getGPUCoalescer();
44711309Sdavid.hashe@amd.com            if (coal != NULL) {
44811309Sdavid.hashe@amd.com                // add all the latencies
44911309Sdavid.hashe@amd.com                m_latencyHistCoalsr.add(coal->getLatencyHist());
45011309Sdavid.hashe@amd.com                m_missLatencyHistCoalsr.add(coal->getMissLatencyHist());
45111309Sdavid.hashe@amd.com
45211309Sdavid.hashe@amd.com                // add the per request type latencies
45311309Sdavid.hashe@amd.com                for (uint32_t j = 0; j < RubyRequestType_NUM; ++j) {
45411309Sdavid.hashe@amd.com                    m_typeLatencyHistCoalsr[j]
45511309Sdavid.hashe@amd.com                        ->add(coal->getTypeLatencyHist(j));
45611309Sdavid.hashe@amd.com                    m_missTypeLatencyHistCoalsr[j]
45711309Sdavid.hashe@amd.com                        ->add(coal->getMissTypeLatencyHist(j));
45811309Sdavid.hashe@amd.com                }
45911309Sdavid.hashe@amd.com
46011309Sdavid.hashe@amd.com                // add the per machine type miss latencies
46111309Sdavid.hashe@amd.com                for (uint32_t j = 0; j < MachineType_NUM; ++j) {
46211309Sdavid.hashe@amd.com                    m_missMachLatencyHistCoalsr[j]
46311309Sdavid.hashe@amd.com                        ->add(coal->getMissMachLatencyHist(j));
46411309Sdavid.hashe@amd.com
46511309Sdavid.hashe@amd.com                    m_IssueToInitialDelayHistCoalsr[j]->add(
46611309Sdavid.hashe@amd.com                        coal->getIssueToInitialDelayHist(MachineType(j)));
46711309Sdavid.hashe@amd.com
46811309Sdavid.hashe@amd.com                    m_InitialToForwardDelayHistCoalsr[j]->add(
46911309Sdavid.hashe@amd.com                        coal->getInitialToForwardDelayHist(MachineType(j)));
47011309Sdavid.hashe@amd.com                    m_ForwardToFirstResponseDelayHistCoalsr[j]->add(coal->
47111309Sdavid.hashe@amd.com                        getForwardRequestToFirstResponseHist(MachineType(j)));
47211309Sdavid.hashe@amd.com
47311309Sdavid.hashe@amd.com                    m_FirstResponseToCompletionDelayHistCoalsr[j]->add(coal->
47411309Sdavid.hashe@amd.com                        getFirstResponseToCompletionDelayHist(
47511309Sdavid.hashe@amd.com                            MachineType(j)));
47611309Sdavid.hashe@amd.com                }
47711309Sdavid.hashe@amd.com
47811309Sdavid.hashe@amd.com                // add the per (request, machine) type miss latencies
47911309Sdavid.hashe@amd.com                for (uint32_t j = 0; j < RubyRequestType_NUM; j++) {
48011309Sdavid.hashe@amd.com                    for (uint32_t k = 0; k < MachineType_NUM; k++) {
48111309Sdavid.hashe@amd.com                        m_missTypeMachLatencyHistCoalsr[j][k]->add(
48211309Sdavid.hashe@amd.com                                coal->getMissTypeMachLatencyHist(j,k));
48311309Sdavid.hashe@amd.com                    }
48411309Sdavid.hashe@amd.com                }
48511309Sdavid.hashe@amd.com            }
48611798Santhony.gutierrez@amd.com#endif
4879773Snilay@cs.wisc.edu        }
4889773Snilay@cs.wisc.edu    }
4896145Snate@binkert.org}
4906145Snate@binkert.org
4917048Snate@binkert.orgvoid
4928174Snilay@cs.wisc.eduProfiler::addAddressTraceSample(const RubyRequest& msg, NodeID id)
4936145Snate@binkert.org{
4948165Snilay@cs.wisc.edu    if (msg.getType() != RubyRequestType_IFETCH) {
4957048Snate@binkert.org        // Note: The following line should be commented out if you
4967048Snate@binkert.org        // want to use the special profiling that is part of the GS320
4977048Snate@binkert.org        // protocol
4986145Snate@binkert.org
4997048Snate@binkert.org        // NOTE: Unless PROFILE_HOT_LINES is enabled, nothing will be
5007048Snate@binkert.org        // profiled by the AddressProfiler
5017048Snate@binkert.org        m_address_profiler_ptr->
5027048Snate@binkert.org            addTraceSample(msg.getLineAddress(), msg.getProgramCounter(),
5037048Snate@binkert.org                           msg.getType(), msg.getAccessMode(), id, false);
5047048Snate@binkert.org    }
5056145Snate@binkert.org}
506