16145Snate@binkert.org/*
26145Snate@binkert.org * Copyright (c) 1999-2008 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/*
306284Snate@binkert.org   This file has been modified by Kevin Moore and Dan Nussbaum of the
316284Snate@binkert.org   Scalable Systems Research Group at Sun Microsystems Laboratories
326284Snate@binkert.org   (http://research.sun.com/scalable/) to support the Adaptive
336284Snate@binkert.org   Transactional Memory Test Platform (ATMTP).
346145Snate@binkert.org
356284Snate@binkert.org   Please send email to atmtp-interest@sun.com with feedback, questions, or
366284Snate@binkert.org   to request future announcements about ATMTP.
376145Snate@binkert.org
386284Snate@binkert.org   ----------------------------------------------------------------------
396145Snate@binkert.org
406284Snate@binkert.org   File modification date: 2008-02-23
416145Snate@binkert.org
426284Snate@binkert.org   ----------------------------------------------------------------------
436145Snate@binkert.org*/
446145Snate@binkert.org
457048Snate@binkert.org#ifndef __MEM_RUBY_PROFILER_PROFILER_HH__
467048Snate@binkert.org#define __MEM_RUBY_PROFILER_PROFILER_HH__
476145Snate@binkert.org
487455Snate@binkert.org#include <map>
497055Snate@binkert.org#include <string>
507454Snate@binkert.org#include <vector>
517055Snate@binkert.org
5210012Snilay@cs.wisc.edu#include "base/callback.hh"
5310012Snilay@cs.wisc.edu#include "base/statistics.hh"
5410301Snilay@cs.wisc.edu#include "mem/ruby/common/MachineID.hh"
5514184Sgabeblack@google.com#include "mem/ruby/protocol/AccessType.hh"
5614184Sgabeblack@google.com#include "mem/ruby/protocol/PrefetchBit.hh"
5714184Sgabeblack@google.com#include "mem/ruby/protocol/RubyAccessMode.hh"
5814184Sgabeblack@google.com#include "mem/ruby/protocol/RubyRequestType.hh"
5910012Snilay@cs.wisc.edu#include "params/RubySystem.hh"
606876Ssteve.reinhardt@amd.com
618174Snilay@cs.wisc.educlass RubyRequest;
626145Snate@binkert.orgclass AddressProfiler;
636145Snate@binkert.org
6410012Snilay@cs.wisc.educlass Profiler
657048Snate@binkert.org{
667048Snate@binkert.org  public:
6710920Sbrandon.potter@amd.com    Profiler(const RubySystemParams *params, RubySystem *rs);
687048Snate@binkert.org    ~Profiler();
696145Snate@binkert.org
7010920Sbrandon.potter@amd.com    RubySystem *m_ruby_system;
7110920Sbrandon.potter@amd.com
727048Snate@binkert.org    void wakeup();
7310012Snilay@cs.wisc.edu    void regStats(const std::string &name);
7410012Snilay@cs.wisc.edu    void collateStats();
756145Snate@binkert.org
767048Snate@binkert.org    AddressProfiler* getAddressProfiler() { return m_address_profiler_ptr; }
777048Snate@binkert.org    AddressProfiler* getInstructionProfiler() { return m_inst_profiler_ptr; }
786145Snate@binkert.org
798174Snilay@cs.wisc.edu    void addAddressTraceSample(const RubyRequest& msg, NodeID id);
806145Snate@binkert.org
817048Snate@binkert.org    // added by SS
8211172Snilay@cs.wisc.edu    bool getHotLines() const { return m_hot_lines; }
8311172Snilay@cs.wisc.edu    bool getAllInstructions() const { return m_all_instructions; }
846145Snate@binkert.org
857048Snate@binkert.org  private:
867048Snate@binkert.org    // Private copy constructor and assignment operator
877048Snate@binkert.org    Profiler(const Profiler& obj);
887048Snate@binkert.org    Profiler& operator=(const Profiler& obj);
896145Snate@binkert.org
907048Snate@binkert.org    AddressProfiler* m_address_profiler_ptr;
917048Snate@binkert.org    AddressProfiler* m_inst_profiler_ptr;
926145Snate@binkert.org
9310012Snilay@cs.wisc.edu    Stats::Histogram delayHistogram;
9410012Snilay@cs.wisc.edu    std::vector<Stats::Histogram *> delayVCHistogram;
956145Snate@binkert.org
9610012Snilay@cs.wisc.edu    //! Histogram for number of outstanding requests per cycle.
9711309Sdavid.hashe@amd.com    Stats::Histogram m_outstandReqHistSeqr;
9811309Sdavid.hashe@amd.com    Stats::Histogram m_outstandReqHistCoalsr;
996145Snate@binkert.org
10010012Snilay@cs.wisc.edu    //! Histogram for holding latency profile of all requests.
10111309Sdavid.hashe@amd.com    Stats::Histogram m_latencyHistSeqr;
10211309Sdavid.hashe@amd.com    Stats::Histogram m_latencyHistCoalsr;
10311309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_typeLatencyHistSeqr;
10411309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_typeLatencyHistCoalsr;
1056145Snate@binkert.org
10610012Snilay@cs.wisc.edu    //! Histogram for holding latency profile of all requests that
10710012Snilay@cs.wisc.edu    //! hit in the controller connected to this sequencer.
10811309Sdavid.hashe@amd.com    Stats::Histogram m_hitLatencyHistSeqr;
10911309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_hitTypeLatencyHistSeqr;
11010012Snilay@cs.wisc.edu
11110012Snilay@cs.wisc.edu    //! Histograms for profiling the latencies for requests that
11210012Snilay@cs.wisc.edu    //! did not required external messages.
11311309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_hitMachLatencyHistSeqr;
11411309Sdavid.hashe@amd.com    std::vector< std::vector<Stats::Histogram *> > m_hitTypeMachLatencyHistSeqr;
11510012Snilay@cs.wisc.edu
11610012Snilay@cs.wisc.edu    //! Histogram for holding latency profile of all requests that
11710012Snilay@cs.wisc.edu    //! miss in the controller connected to this sequencer.
11811309Sdavid.hashe@amd.com    Stats::Histogram m_missLatencyHistSeqr;
11911309Sdavid.hashe@amd.com    Stats::Histogram m_missLatencyHistCoalsr;
12011309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_missTypeLatencyHistSeqr;
12111309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_missTypeLatencyHistCoalsr;
12210012Snilay@cs.wisc.edu
12310012Snilay@cs.wisc.edu    //! Histograms for profiling the latencies for requests that
12410012Snilay@cs.wisc.edu    //! required external messages.
12511309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_missMachLatencyHistSeqr;
12611309Sdavid.hashe@amd.com    std::vector< std::vector<Stats::Histogram *> > m_missTypeMachLatencyHistSeqr;
12711309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_missMachLatencyHistCoalsr;
12811309Sdavid.hashe@amd.com    std::vector< std::vector<Stats::Histogram *> > m_missTypeMachLatencyHistCoalsr;
12910012Snilay@cs.wisc.edu
13010012Snilay@cs.wisc.edu    //! Histograms for recording the breakdown of miss latency
13111309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_IssueToInitialDelayHistSeqr;
13211309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_InitialToForwardDelayHistSeqr;
13311309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_ForwardToFirstResponseDelayHistSeqr;
13411309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_FirstResponseToCompletionDelayHistSeqr;
13511309Sdavid.hashe@amd.com    Stats::Scalar m_IncompleteTimesSeqr[MachineType_NUM];
13611309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_IssueToInitialDelayHistCoalsr;
13711309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_InitialToForwardDelayHistCoalsr;
13811309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_ForwardToFirstResponseDelayHistCoalsr;
13911309Sdavid.hashe@amd.com    std::vector<Stats::Histogram *> m_FirstResponseToCompletionDelayHistCoalsr;
1406896SBrad.Beckmann@amd.com
1417048Snate@binkert.org    //added by SS
14211172Snilay@cs.wisc.edu    const bool m_hot_lines;
14311172Snilay@cs.wisc.edu    const bool m_all_instructions;
14411172Snilay@cs.wisc.edu    const uint32_t m_num_vnets;
1456145Snate@binkert.org};
1466145Snate@binkert.org
1477048Snate@binkert.org#endif // __MEM_RUBY_PROFILER_PROFILER_HH__
148