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/ruby/network/Network.hh"
567048Snate@binkert.org#include "mem/ruby/profiler/AddressProfiler.hh"
5714184Sgabeblack@google.com#include "mem/ruby/protocol/MachineType.hh"
5814184Sgabeblack@google.com#include "mem/ruby/protocol/RubyRequest.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"
7514184Sgabeblack@google.com
7611798Santhony.gutierrez@amd.com#endif
7711798Santhony.gutierrez@amd.com
789598Snilay@cs.wisc.edu#include "mem/ruby/system/Sequencer.hh"
796876Ssteve.reinhardt@amd.com
807055Snate@binkert.orgusing namespace std;
817454Snate@binkert.orgusing m5::stl_helpers::operator<<;
827055Snate@binkert.org
8310920Sbrandon.potter@amd.comProfiler::Profiler(const RubySystemParams *p, RubySystem *rs)
8411172Snilay@cs.wisc.edu    : m_ruby_system(rs), m_hot_lines(p->hot_lines),
8511172Snilay@cs.wisc.edu      m_all_instructions(p->all_instructions),
8611172Snilay@cs.wisc.edu      m_num_vnets(p->number_of_virtual_networks)
876145Snate@binkert.org{
8810919Sbrandon.potter@amd.com    m_address_profiler_ptr = new AddressProfiler(p->num_of_sequencers, this);
897048Snate@binkert.org    m_address_profiler_ptr->setHotLines(m_hot_lines);
907048Snate@binkert.org    m_address_profiler_ptr->setAllInstructions(m_all_instructions);
916285Snate@binkert.org
927048Snate@binkert.org    if (m_all_instructions) {
9310919Sbrandon.potter@amd.com        m_inst_profiler_ptr = new AddressProfiler(p->num_of_sequencers, this);
947048Snate@binkert.org        m_inst_profiler_ptr->setHotLines(m_hot_lines);
957048Snate@binkert.org        m_inst_profiler_ptr->setAllInstructions(m_all_instructions);
967048Snate@binkert.org    }
976285Snate@binkert.org}
986285Snate@binkert.org
996889SBrad.Beckmann@amd.comProfiler::~Profiler()
1006889SBrad.Beckmann@amd.com{
1017048Snate@binkert.org}
1027048Snate@binkert.org
1037048Snate@binkert.orgvoid
10410012Snilay@cs.wisc.eduProfiler::regStats(const std::string &pName)
1057048Snate@binkert.org{
10610012Snilay@cs.wisc.edu    if (!m_all_instructions) {
10710012Snilay@cs.wisc.edu        m_address_profiler_ptr->regStats(pName);
10810012Snilay@cs.wisc.edu    }
10910012Snilay@cs.wisc.edu
11010012Snilay@cs.wisc.edu    if (m_all_instructions) {
11110012Snilay@cs.wisc.edu        m_inst_profiler_ptr->regStats(pName);
11210012Snilay@cs.wisc.edu    }
11310012Snilay@cs.wisc.edu
11410012Snilay@cs.wisc.edu    delayHistogram
11510012Snilay@cs.wisc.edu        .init(10)
11610012Snilay@cs.wisc.edu        .name(pName + ".delayHist")
11710012Snilay@cs.wisc.edu        .desc("delay histogram for all message")
11810012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
11910012Snilay@cs.wisc.edu
12011172Snilay@cs.wisc.edu    for (int i = 0; i < m_num_vnets; i++) {
12110012Snilay@cs.wisc.edu        delayVCHistogram.push_back(new Stats::Histogram());
12210012Snilay@cs.wisc.edu        delayVCHistogram[i]
12310012Snilay@cs.wisc.edu            ->init(10)
12410012Snilay@cs.wisc.edu            .name(pName + csprintf(".delayVCHist.vnet_%i", i))
12510012Snilay@cs.wisc.edu            .desc(csprintf("delay histogram for vnet_%i", i))
12610012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
12710012Snilay@cs.wisc.edu    }
12810012Snilay@cs.wisc.edu
12911309Sdavid.hashe@amd.com    m_outstandReqHistSeqr
13010012Snilay@cs.wisc.edu        .init(10)
13111309Sdavid.hashe@amd.com        .name(pName + ".outstanding_req_hist_seqr")
13210012Snilay@cs.wisc.edu        .desc("")
13310012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
13410012Snilay@cs.wisc.edu
13511309Sdavid.hashe@amd.com    m_outstandReqHistCoalsr
13610012Snilay@cs.wisc.edu        .init(10)
13711309Sdavid.hashe@amd.com        .name(pName + ".outstanding_req_hist_coalsr")
13810012Snilay@cs.wisc.edu        .desc("")
13910012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
14010012Snilay@cs.wisc.edu
14111309Sdavid.hashe@amd.com    m_latencyHistSeqr
14210012Snilay@cs.wisc.edu        .init(10)
14311309Sdavid.hashe@amd.com        .name(pName + ".latency_hist_seqr")
14410012Snilay@cs.wisc.edu        .desc("")
14510012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
14610012Snilay@cs.wisc.edu
14711309Sdavid.hashe@amd.com    m_latencyHistCoalsr
14810012Snilay@cs.wisc.edu        .init(10)
14911309Sdavid.hashe@amd.com        .name(pName + ".latency_hist_coalsr")
15011309Sdavid.hashe@amd.com        .desc("")
15111309Sdavid.hashe@amd.com        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
15211309Sdavid.hashe@amd.com
15311309Sdavid.hashe@amd.com    m_hitLatencyHistSeqr
15411309Sdavid.hashe@amd.com        .init(10)
15511309Sdavid.hashe@amd.com        .name(pName + ".hit_latency_hist_seqr")
15611309Sdavid.hashe@amd.com        .desc("")
15711309Sdavid.hashe@amd.com        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
15811309Sdavid.hashe@amd.com
15911309Sdavid.hashe@amd.com    m_missLatencyHistSeqr
16011309Sdavid.hashe@amd.com        .init(10)
16111309Sdavid.hashe@amd.com        .name(pName + ".miss_latency_hist_seqr")
16211309Sdavid.hashe@amd.com        .desc("")
16311309Sdavid.hashe@amd.com        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
16411309Sdavid.hashe@amd.com
16511309Sdavid.hashe@amd.com    m_missLatencyHistCoalsr
16611309Sdavid.hashe@amd.com        .init(10)
16711309Sdavid.hashe@amd.com        .name(pName + ".miss_latency_hist_coalsr")
16810012Snilay@cs.wisc.edu        .desc("")
16910012Snilay@cs.wisc.edu        .flags(Stats::nozero | Stats::pdf | Stats::oneline);
17010012Snilay@cs.wisc.edu
17110012Snilay@cs.wisc.edu    for (int i = 0; i < RubyRequestType_NUM; i++) {
17211309Sdavid.hashe@amd.com        m_typeLatencyHistSeqr.push_back(new Stats::Histogram());
17311309Sdavid.hashe@amd.com        m_typeLatencyHistSeqr[i]
17410012Snilay@cs.wisc.edu            ->init(10)
17511309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.latency_hist_seqr",
17610012Snilay@cs.wisc.edu                                    RubyRequestType(i)))
17710012Snilay@cs.wisc.edu            .desc("")
17810012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
17910012Snilay@cs.wisc.edu
18011309Sdavid.hashe@amd.com        m_typeLatencyHistCoalsr.push_back(new Stats::Histogram());
18111309Sdavid.hashe@amd.com        m_typeLatencyHistCoalsr[i]
18210012Snilay@cs.wisc.edu            ->init(10)
18311309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.latency_hist_coalsr",
18410012Snilay@cs.wisc.edu                                    RubyRequestType(i)))
18510012Snilay@cs.wisc.edu            .desc("")
18610012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
18710012Snilay@cs.wisc.edu
18811309Sdavid.hashe@amd.com        m_hitTypeLatencyHistSeqr.push_back(new Stats::Histogram());
18911309Sdavid.hashe@amd.com        m_hitTypeLatencyHistSeqr[i]
19010012Snilay@cs.wisc.edu            ->init(10)
19111309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.hit_latency_hist_seqr",
19211309Sdavid.hashe@amd.com                                    RubyRequestType(i)))
19311309Sdavid.hashe@amd.com            .desc("")
19411309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
19511309Sdavid.hashe@amd.com
19611309Sdavid.hashe@amd.com        m_missTypeLatencyHistSeqr.push_back(new Stats::Histogram());
19711309Sdavid.hashe@amd.com        m_missTypeLatencyHistSeqr[i]
19811309Sdavid.hashe@amd.com            ->init(10)
19911309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_seqr",
20011309Sdavid.hashe@amd.com                                    RubyRequestType(i)))
20111309Sdavid.hashe@amd.com            .desc("")
20211309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
20311309Sdavid.hashe@amd.com
20411309Sdavid.hashe@amd.com        m_missTypeLatencyHistCoalsr.push_back(new Stats::Histogram());
20511309Sdavid.hashe@amd.com        m_missTypeLatencyHistCoalsr[i]
20611309Sdavid.hashe@amd.com            ->init(10)
20711309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_coalsr",
20810012Snilay@cs.wisc.edu                                    RubyRequestType(i)))
20910012Snilay@cs.wisc.edu            .desc("")
21010012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
21110012Snilay@cs.wisc.edu    }
21210012Snilay@cs.wisc.edu
21310012Snilay@cs.wisc.edu    for (int i = 0; i < MachineType_NUM; i++) {
21411309Sdavid.hashe@amd.com        m_hitMachLatencyHistSeqr.push_back(new Stats::Histogram());
21511309Sdavid.hashe@amd.com        m_hitMachLatencyHistSeqr[i]
21610012Snilay@cs.wisc.edu            ->init(10)
21711309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.hit_mach_latency_hist_seqr",
21810012Snilay@cs.wisc.edu                                    MachineType(i)))
21910012Snilay@cs.wisc.edu            .desc("")
22010012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
22110012Snilay@cs.wisc.edu
22211309Sdavid.hashe@amd.com        m_missMachLatencyHistSeqr.push_back(new Stats::Histogram());
22311309Sdavid.hashe@amd.com        m_missMachLatencyHistSeqr[i]
22410012Snilay@cs.wisc.edu            ->init(10)
22511309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_mach_latency_hist_seqr",
22610012Snilay@cs.wisc.edu                                    MachineType(i)))
22710012Snilay@cs.wisc.edu            .desc("")
22810012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
22910012Snilay@cs.wisc.edu
23011309Sdavid.hashe@amd.com        m_missMachLatencyHistCoalsr.push_back(new Stats::Histogram());
23111309Sdavid.hashe@amd.com        m_missMachLatencyHistCoalsr[i]
23211309Sdavid.hashe@amd.com            ->init(10)
23311309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_mach_latency_hist_coalsr",
23411309Sdavid.hashe@amd.com                                    MachineType(i)))
23511309Sdavid.hashe@amd.com            .desc("")
23611309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
23711309Sdavid.hashe@amd.com
23811309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistSeqr.push_back(new Stats::Histogram());
23911309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistSeqr[i]
24010012Snilay@cs.wisc.edu            ->init(10)
24110012Snilay@cs.wisc.edu            .name(pName + csprintf(
24211309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_seqr.issue_to_initial_request",
24310012Snilay@cs.wisc.edu                MachineType(i)))
24410012Snilay@cs.wisc.edu            .desc("")
24510012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
24610012Snilay@cs.wisc.edu
24711309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistCoalsr.push_back(new Stats::Histogram());
24811309Sdavid.hashe@amd.com        m_IssueToInitialDelayHistCoalsr[i]
24910012Snilay@cs.wisc.edu            ->init(10)
25011309Sdavid.hashe@amd.com            .name(pName + csprintf(
25111309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_coalsr.issue_to_initial_request",
25211309Sdavid.hashe@amd.com                MachineType(i)))
25311309Sdavid.hashe@amd.com            .desc("")
25411309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
25511309Sdavid.hashe@amd.com
25611309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistSeqr.push_back(new Stats::Histogram());
25711309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistSeqr[i]
25811309Sdavid.hashe@amd.com            ->init(10)
25911309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_seqr.initial_to_forward",
26010012Snilay@cs.wisc.edu                                   MachineType(i)))
26110012Snilay@cs.wisc.edu            .desc("")
26210012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
26310012Snilay@cs.wisc.edu
26411309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistCoalsr.push_back(new Stats::Histogram());
26511309Sdavid.hashe@amd.com        m_InitialToForwardDelayHistCoalsr[i]
26611309Sdavid.hashe@amd.com            ->init(10)
26711309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.miss_latency_hist_coalsr.initial_to_forward",
26811309Sdavid.hashe@amd.com                                   MachineType(i)))
26911309Sdavid.hashe@amd.com            .desc("")
27011309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
27111309Sdavid.hashe@amd.com
27211309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistSeqr.push_back(new Stats::Histogram());
27311309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistSeqr[i]
27410012Snilay@cs.wisc.edu            ->init(10)
27510012Snilay@cs.wisc.edu            .name(pName + csprintf(
27611309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_seqr.forward_to_first_response",
27710012Snilay@cs.wisc.edu                MachineType(i)))
27810012Snilay@cs.wisc.edu            .desc("")
27910012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
28010012Snilay@cs.wisc.edu
28111309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistCoalsr.push_back(new Stats::Histogram());
28211309Sdavid.hashe@amd.com        m_ForwardToFirstResponseDelayHistCoalsr[i]
28310012Snilay@cs.wisc.edu            ->init(10)
28410012Snilay@cs.wisc.edu            .name(pName + csprintf(
28511309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_coalsr.forward_to_first_response",
28610012Snilay@cs.wisc.edu                MachineType(i)))
28710012Snilay@cs.wisc.edu            .desc("")
28810012Snilay@cs.wisc.edu            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
28910012Snilay@cs.wisc.edu
29011309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistSeqr.push_back(new Stats::Histogram());
29111309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistSeqr[i]
29211309Sdavid.hashe@amd.com            ->init(10)
29311309Sdavid.hashe@amd.com            .name(pName + csprintf(
29411309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_seqr.first_response_to_completion",
29511309Sdavid.hashe@amd.com                MachineType(i)))
29611309Sdavid.hashe@amd.com            .desc("")
29711309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
29811309Sdavid.hashe@amd.com
29911309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistCoalsr.push_back(new Stats::Histogram());
30011309Sdavid.hashe@amd.com        m_FirstResponseToCompletionDelayHistCoalsr[i]
30111309Sdavid.hashe@amd.com            ->init(10)
30211309Sdavid.hashe@amd.com            .name(pName + csprintf(
30311309Sdavid.hashe@amd.com                ".%s.miss_latency_hist_coalsr.first_response_to_completion",
30411309Sdavid.hashe@amd.com                MachineType(i)))
30511309Sdavid.hashe@amd.com            .desc("")
30611309Sdavid.hashe@amd.com            .flags(Stats::nozero | Stats::pdf | Stats::oneline);
30711309Sdavid.hashe@amd.com
30811309Sdavid.hashe@amd.com        m_IncompleteTimesSeqr[i]
30911309Sdavid.hashe@amd.com            .name(pName + csprintf(".%s.incomplete_times_seqr", MachineType(i)))
31010012Snilay@cs.wisc.edu            .desc("")
31110012Snilay@cs.wisc.edu            .flags(Stats::nozero);
31210012Snilay@cs.wisc.edu    }
31310012Snilay@cs.wisc.edu
31410012Snilay@cs.wisc.edu    for (int i = 0; i < RubyRequestType_NUM; i++) {
31511309Sdavid.hashe@amd.com        m_hitTypeMachLatencyHistSeqr.push_back(std::vector<Stats::Histogram *>());
31611309Sdavid.hashe@amd.com        m_missTypeMachLatencyHistSeqr.push_back(std::vector<Stats::Histogram *>());
31711309Sdavid.hashe@amd.com        m_missTypeMachLatencyHistCoalsr.push_back(std::vector<Stats::Histogram *>());
31810012Snilay@cs.wisc.edu
31910012Snilay@cs.wisc.edu        for (int j = 0; j < MachineType_NUM; j++) {
32011309Sdavid.hashe@amd.com            m_hitTypeMachLatencyHistSeqr[i].push_back(new Stats::Histogram());
32111309Sdavid.hashe@amd.com            m_hitTypeMachLatencyHistSeqr[i][j]
32210012Snilay@cs.wisc.edu                ->init(10)
32311309Sdavid.hashe@amd.com                .name(pName + csprintf(".%s.%s.hit_type_mach_latency_hist_seqr",
32410012Snilay@cs.wisc.edu                                       RubyRequestType(i), MachineType(j)))
32510012Snilay@cs.wisc.edu                .desc("")
32610012Snilay@cs.wisc.edu                .flags(Stats::nozero | Stats::pdf | Stats::oneline);
32710012Snilay@cs.wisc.edu
32811309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistSeqr[i].push_back(new Stats::Histogram());
32911309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistSeqr[i][j]
33010012Snilay@cs.wisc.edu                ->init(10)
33111309Sdavid.hashe@amd.com                .name(pName + csprintf(".%s.%s.miss_type_mach_latency_hist_seqr",
33211309Sdavid.hashe@amd.com                                       RubyRequestType(i), MachineType(j)))
33311309Sdavid.hashe@amd.com                .desc("")
33411309Sdavid.hashe@amd.com                .flags(Stats::nozero | Stats::pdf | Stats::oneline);
33511309Sdavid.hashe@amd.com
33611309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistCoalsr[i].push_back(new Stats::Histogram());
33711309Sdavid.hashe@amd.com            m_missTypeMachLatencyHistCoalsr[i][j]
33811309Sdavid.hashe@amd.com                ->init(10)
33911309Sdavid.hashe@amd.com                .name(pName + csprintf(".%s.%s.miss_type_mach_latency_hist_coalsr",
34010012Snilay@cs.wisc.edu                                       RubyRequestType(i), MachineType(j)))
34110012Snilay@cs.wisc.edu                .desc("")
34210012Snilay@cs.wisc.edu                .flags(Stats::nozero | Stats::pdf | Stats::oneline);
34310012Snilay@cs.wisc.edu        }
34410012Snilay@cs.wisc.edu    }
3457048Snate@binkert.org}
3467048Snate@binkert.org
3477048Snate@binkert.orgvoid
34810012Snilay@cs.wisc.eduProfiler::collateStats()
3499496Snilay@cs.wisc.edu{
35010012Snilay@cs.wisc.edu    if (!m_all_instructions) {
35110012Snilay@cs.wisc.edu        m_address_profiler_ptr->collateStats();
3529496Snilay@cs.wisc.edu    }
3539496Snilay@cs.wisc.edu
35410012Snilay@cs.wisc.edu    if (m_all_instructions) {
35510012Snilay@cs.wisc.edu        m_inst_profiler_ptr->collateStats();
3569496Snilay@cs.wisc.edu    }
3579497Snilay@cs.wisc.edu
3589497Snilay@cs.wisc.edu    for (uint32_t i = 0; i < MachineType_NUM; i++) {
3599497Snilay@cs.wisc.edu        for (map<uint32_t, AbstractController*>::iterator it =
36010920Sbrandon.potter@amd.com                  m_ruby_system->m_abstract_controls[i].begin();
36110920Sbrandon.potter@amd.com             it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
3629497Snilay@cs.wisc.edu
3639497Snilay@cs.wisc.edu            AbstractController *ctr = (*it).second;
3649497Snilay@cs.wisc.edu            delayHistogram.add(ctr->getDelayHist());
3659497Snilay@cs.wisc.edu
36611172Snilay@cs.wisc.edu            for (uint32_t i = 0; i < m_num_vnets; i++) {
36710012Snilay@cs.wisc.edu                delayVCHistogram[i]->add(ctr->getDelayVCHist(i));
3689497Snilay@cs.wisc.edu            }
3699497Snilay@cs.wisc.edu        }
3709497Snilay@cs.wisc.edu    }
3719497Snilay@cs.wisc.edu
3729598Snilay@cs.wisc.edu    for (uint32_t i = 0; i < MachineType_NUM; i++) {
3739598Snilay@cs.wisc.edu        for (map<uint32_t, AbstractController*>::iterator it =
37410920Sbrandon.potter@amd.com                m_ruby_system->m_abstract_controls[i].begin();
37510920Sbrandon.potter@amd.com                it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
3769598Snilay@cs.wisc.edu
3779598Snilay@cs.wisc.edu            AbstractController *ctr = (*it).second;
37811308Santhony.gutierrez@amd.com            Sequencer *seq = ctr->getCPUSequencer();
3799598Snilay@cs.wisc.edu            if (seq != NULL) {
38011309Sdavid.hashe@amd.com                m_outstandReqHistSeqr.add(seq->getOutstandReqHist());
38111309Sdavid.hashe@amd.com            }
38211798Santhony.gutierrez@amd.com#ifdef BUILD_GPU
38311309Sdavid.hashe@amd.com            GPUCoalescer *coal = ctr->getGPUCoalescer();
38411309Sdavid.hashe@amd.com            if (coal != NULL) {
38511309Sdavid.hashe@amd.com                m_outstandReqHistCoalsr.add(coal->getOutstandReqHist());
3869598Snilay@cs.wisc.edu            }
38711798Santhony.gutierrez@amd.com#endif
3889598Snilay@cs.wisc.edu        }
3899598Snilay@cs.wisc.edu    }
3909598Snilay@cs.wisc.edu
3919773Snilay@cs.wisc.edu    for (uint32_t i = 0; i < MachineType_NUM; i++) {
3929773Snilay@cs.wisc.edu        for (map<uint32_t, AbstractController*>::iterator it =
39310920Sbrandon.potter@amd.com                m_ruby_system->m_abstract_controls[i].begin();
39410920Sbrandon.potter@amd.com                it != m_ruby_system->m_abstract_controls[i].end(); ++it) {
3959773Snilay@cs.wisc.edu
3969773Snilay@cs.wisc.edu            AbstractController *ctr = (*it).second;
39711308Santhony.gutierrez@amd.com            Sequencer *seq = ctr->getCPUSequencer();
3989773Snilay@cs.wisc.edu            if (seq != NULL) {
3999773Snilay@cs.wisc.edu                // add all the latencies
40011309Sdavid.hashe@amd.com                m_latencyHistSeqr.add(seq->getLatencyHist());
40111309Sdavid.hashe@amd.com                m_hitLatencyHistSeqr.add(seq->getHitLatencyHist());
40211309Sdavid.hashe@amd.com                m_missLatencyHistSeqr.add(seq->getMissLatencyHist());
4039773Snilay@cs.wisc.edu
4049773Snilay@cs.wisc.edu                // add the per request type latencies
4059773Snilay@cs.wisc.edu                for (uint32_t j = 0; j < RubyRequestType_NUM; ++j) {
40611309Sdavid.hashe@amd.com                    m_typeLatencyHistSeqr[j]
40710012Snilay@cs.wisc.edu                        ->add(seq->getTypeLatencyHist(j));
40811309Sdavid.hashe@amd.com                    m_hitTypeLatencyHistSeqr[j]
40910012Snilay@cs.wisc.edu                        ->add(seq->getHitTypeLatencyHist(j));
41011309Sdavid.hashe@amd.com                    m_missTypeLatencyHistSeqr[j]
41110012Snilay@cs.wisc.edu                        ->add(seq->getMissTypeLatencyHist(j));
4129773Snilay@cs.wisc.edu                }
4139773Snilay@cs.wisc.edu
4149773Snilay@cs.wisc.edu                // add the per machine type miss latencies
4159773Snilay@cs.wisc.edu                for (uint32_t j = 0; j < MachineType_NUM; ++j) {
41611309Sdavid.hashe@amd.com                    m_hitMachLatencyHistSeqr[j]
41710012Snilay@cs.wisc.edu                        ->add(seq->getHitMachLatencyHist(j));
41811309Sdavid.hashe@amd.com                    m_missMachLatencyHistSeqr[j]
41910012Snilay@cs.wisc.edu                        ->add(seq->getMissMachLatencyHist(j));
4209773Snilay@cs.wisc.edu
42111309Sdavid.hashe@amd.com                    m_IssueToInitialDelayHistSeqr[j]->add(
4229773Snilay@cs.wisc.edu                        seq->getIssueToInitialDelayHist(MachineType(j)));
4239773Snilay@cs.wisc.edu
42411309Sdavid.hashe@amd.com                    m_InitialToForwardDelayHistSeqr[j]->add(
4259773Snilay@cs.wisc.edu                        seq->getInitialToForwardDelayHist(MachineType(j)));
42611309Sdavid.hashe@amd.com                    m_ForwardToFirstResponseDelayHistSeqr[j]->add(seq->
4279773Snilay@cs.wisc.edu                        getForwardRequestToFirstResponseHist(MachineType(j)));
4289773Snilay@cs.wisc.edu
42911309Sdavid.hashe@amd.com                    m_FirstResponseToCompletionDelayHistSeqr[j]->add(seq->
43010012Snilay@cs.wisc.edu                        getFirstResponseToCompletionDelayHist(
43110012Snilay@cs.wisc.edu                            MachineType(j)));
43211309Sdavid.hashe@amd.com                    m_IncompleteTimesSeqr[j] +=
4339773Snilay@cs.wisc.edu                        seq->getIncompleteTimes(MachineType(j));
4349773Snilay@cs.wisc.edu                }
4359773Snilay@cs.wisc.edu
4369773Snilay@cs.wisc.edu                // add the per (request, machine) type miss latencies
4379773Snilay@cs.wisc.edu                for (uint32_t j = 0; j < RubyRequestType_NUM; j++) {
4389773Snilay@cs.wisc.edu                    for (uint32_t k = 0; k < MachineType_NUM; k++) {
43911309Sdavid.hashe@amd.com                        m_hitTypeMachLatencyHistSeqr[j][k]->add(
44010012Snilay@cs.wisc.edu                                seq->getHitTypeMachLatencyHist(j,k));
44111309Sdavid.hashe@amd.com                        m_missTypeMachLatencyHistSeqr[j][k]->add(
44210012Snilay@cs.wisc.edu                                seq->getMissTypeMachLatencyHist(j,k));
4439773Snilay@cs.wisc.edu                    }
4449773Snilay@cs.wisc.edu                }
4459773Snilay@cs.wisc.edu            }
44611798Santhony.gutierrez@amd.com#ifdef BUILD_GPU
44711309Sdavid.hashe@amd.com            GPUCoalescer *coal = ctr->getGPUCoalescer();
44811309Sdavid.hashe@amd.com            if (coal != NULL) {
44911309Sdavid.hashe@amd.com                // add all the latencies
45011309Sdavid.hashe@amd.com                m_latencyHistCoalsr.add(coal->getLatencyHist());
45111309Sdavid.hashe@amd.com                m_missLatencyHistCoalsr.add(coal->getMissLatencyHist());
45211309Sdavid.hashe@amd.com
45311309Sdavid.hashe@amd.com                // add the per request type latencies
45411309Sdavid.hashe@amd.com                for (uint32_t j = 0; j < RubyRequestType_NUM; ++j) {
45511309Sdavid.hashe@amd.com                    m_typeLatencyHistCoalsr[j]
45611309Sdavid.hashe@amd.com                        ->add(coal->getTypeLatencyHist(j));
45711309Sdavid.hashe@amd.com                    m_missTypeLatencyHistCoalsr[j]
45811309Sdavid.hashe@amd.com                        ->add(coal->getMissTypeLatencyHist(j));
45911309Sdavid.hashe@amd.com                }
46011309Sdavid.hashe@amd.com
46111309Sdavid.hashe@amd.com                // add the per machine type miss latencies
46211309Sdavid.hashe@amd.com                for (uint32_t j = 0; j < MachineType_NUM; ++j) {
46311309Sdavid.hashe@amd.com                    m_missMachLatencyHistCoalsr[j]
46411309Sdavid.hashe@amd.com                        ->add(coal->getMissMachLatencyHist(j));
46511309Sdavid.hashe@amd.com
46611309Sdavid.hashe@amd.com                    m_IssueToInitialDelayHistCoalsr[j]->add(
46711309Sdavid.hashe@amd.com                        coal->getIssueToInitialDelayHist(MachineType(j)));
46811309Sdavid.hashe@amd.com
46911309Sdavid.hashe@amd.com                    m_InitialToForwardDelayHistCoalsr[j]->add(
47011309Sdavid.hashe@amd.com                        coal->getInitialToForwardDelayHist(MachineType(j)));
47111309Sdavid.hashe@amd.com                    m_ForwardToFirstResponseDelayHistCoalsr[j]->add(coal->
47211309Sdavid.hashe@amd.com                        getForwardRequestToFirstResponseHist(MachineType(j)));
47311309Sdavid.hashe@amd.com
47411309Sdavid.hashe@amd.com                    m_FirstResponseToCompletionDelayHistCoalsr[j]->add(coal->
47511309Sdavid.hashe@amd.com                        getFirstResponseToCompletionDelayHist(
47611309Sdavid.hashe@amd.com                            MachineType(j)));
47711309Sdavid.hashe@amd.com                }
47811309Sdavid.hashe@amd.com
47911309Sdavid.hashe@amd.com                // add the per (request, machine) type miss latencies
48011309Sdavid.hashe@amd.com                for (uint32_t j = 0; j < RubyRequestType_NUM; j++) {
48111309Sdavid.hashe@amd.com                    for (uint32_t k = 0; k < MachineType_NUM; k++) {
48211309Sdavid.hashe@amd.com                        m_missTypeMachLatencyHistCoalsr[j][k]->add(
48311309Sdavid.hashe@amd.com                                coal->getMissTypeMachLatencyHist(j,k));
48411309Sdavid.hashe@amd.com                    }
48511309Sdavid.hashe@amd.com                }
48611309Sdavid.hashe@amd.com            }
48711798Santhony.gutierrez@amd.com#endif
4889773Snilay@cs.wisc.edu        }
4899773Snilay@cs.wisc.edu    }
4906145Snate@binkert.org}
4916145Snate@binkert.org
4927048Snate@binkert.orgvoid
4938174Snilay@cs.wisc.eduProfiler::addAddressTraceSample(const RubyRequest& msg, NodeID id)
4946145Snate@binkert.org{
4958165Snilay@cs.wisc.edu    if (msg.getType() != RubyRequestType_IFETCH) {
4967048Snate@binkert.org        // Note: The following line should be commented out if you
4977048Snate@binkert.org        // want to use the special profiling that is part of the GS320
4987048Snate@binkert.org        // protocol
4996145Snate@binkert.org
5007048Snate@binkert.org        // NOTE: Unless PROFILE_HOT_LINES is enabled, nothing will be
5017048Snate@binkert.org        // profiled by the AddressProfiler
5027048Snate@binkert.org        m_address_profiler_ptr->
5037048Snate@binkert.org            addTraceSample(msg.getLineAddress(), msg.getProgramCounter(),
5047048Snate@binkert.org                           msg.getType(), msg.getAccessMode(), id, false);
5057048Snate@binkert.org    }
5066145Snate@binkert.org}
507