AccessTraceForAddress.hh revision 11025:4872dbdea907
11689SN/A/*
22316SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
31689SN/A * All rights reserved.
41689SN/A *
51689SN/A * Redistribution and use in source and binary forms, with or without
61689SN/A * modification, are permitted provided that the following conditions are
71689SN/A * met: redistributions of source code must retain the above copyright
81689SN/A * notice, this list of conditions and the following disclaimer;
91689SN/A * redistributions in binary form must reproduce the above copyright
101689SN/A * notice, this list of conditions and the following disclaimer in the
111689SN/A * documentation and/or other materials provided with the distribution;
121689SN/A * neither the name of the copyright holders nor the names of its
131689SN/A * contributors may be used to endorse or promote products derived from
141689SN/A * this software without specific prior written permission.
151689SN/A *
161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu */
282665Ssaidi@eecs.umich.edu
292965Sksewell@umich.edu#ifndef __MEM_RUBY_PROFILER_ACCESSTRACEFORADDRESS_HH__
301689SN/A#define __MEM_RUBY_PROFILER_ACCESSTRACEFORADDRESS_HH__
311689SN/A
322733Sktlim@umich.edu#include <iostream>
332733Sktlim@umich.edu
342733Sktlim@umich.edu#include "mem/protocol/RubyAccessMode.hh"
352292SN/A#include "mem/protocol/RubyRequestType.hh"
362329SN/A#include "mem/ruby/common/Address.hh"
372292SN/A#include "mem/ruby/common/Set.hh"
382292SN/A
391060SN/Aclass Histogram;
402292SN/A
411717SN/Aclass AccessTraceForAddress
422292SN/A{
432292SN/A  public:
442790Sktlim@umich.edu    AccessTraceForAddress()
452790Sktlim@umich.edu        : m_loads(0), m_stores(0), m_atomics(0), m_total(0), m_user(0),
462790Sktlim@umich.edu          m_sharing(0), m_histogram_ptr(NULL)
472790Sktlim@umich.edu    { }
481061SN/A    ~AccessTraceForAddress();
492292SN/A
502292SN/A    void setAddress(Addr addr) { m_addr = addr; }
512292SN/A    void update(RubyRequestType type, RubyAccessMode access_mode, NodeID cpu,
521060SN/A                bool sharing_miss);
532292SN/A    int getTotal() const;
541060SN/A    int getSharing() const { return m_sharing; }
551060SN/A    int getTouchedBy() const { return m_touched_by.count(); }
561061SN/A    Addr getAddress() const { return m_addr; }
571060SN/A    void addSample(int value);
582292SN/A
591062SN/A    void print(std::ostream& out) const;
602316SN/A
612316SN/A    static inline bool
622292SN/A    less_equal(const AccessTraceForAddress* n1,
632292SN/A        const AccessTraceForAddress* n2)
642292SN/A    {
652292SN/A        return n1->getTotal() <= n2->getTotal();
662292SN/A    }
672292SN/A
682292SN/A  private:
692292SN/A    Addr m_addr;
702292SN/A    uint64 m_loads;
712292SN/A    uint64 m_stores;
722292SN/A    uint64 m_atomics;
732292SN/A    uint64 m_total;
742669Sktlim@umich.edu    uint64 m_user;
752292SN/A    uint64 m_sharing;
762292SN/A    Set m_touched_by;
772292SN/A    Histogram* m_histogram_ptr;
782292SN/A};
792292SN/A
802292SN/Ainline std::ostream&
812307SN/Aoperator<<(std::ostream& out, const AccessTraceForAddress& obj)
822843Sktlim@umich.edu{
832316SN/A    obj.print(out);
842874Sktlim@umich.edu    out << std::flush;
852292SN/A    return out;
862292SN/A}
872292SN/A
882980Sgblack@eecs.umich.edu#endif // __MEM_RUBY_PROFILER_ACCESSTRACEFORADDRESS_HH__
892292SN/A