AccessTraceForAddress.hh revision 6372:f1a41ea3bbab
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/*
31 * $Id$
32 *
33 * Description:
34 *
35 */
36
37#ifndef ACCESSTRACEFORADDRESS_H
38#define ACCESSTRACEFORADDRESS_H
39
40#include "mem/ruby/common/Global.hh"
41#include "mem/ruby/common/Address.hh"
42#include "mem/protocol/CacheRequestType.hh"
43#include "mem/protocol/AccessModeType.hh"
44#include "mem/ruby/system/NodeID.hh"
45#include "mem/ruby/common/Set.hh"
46class Histogram;
47
48class AccessTraceForAddress {
49public:
50  // Constructors
51  AccessTraceForAddress();
52  explicit AccessTraceForAddress(const Address& addr);
53
54  // Destructor
55  ~AccessTraceForAddress();
56
57  // Public Methods
58
59  void update(CacheRequestType type, AccessModeType access_mode, NodeID cpu, bool sharing_miss);
60  int getTotal() const;
61  int getSharing() const { return m_sharing; }
62  int getTouchedBy() const { return m_touched_by.count(); }
63  const Address& getAddress() const { return m_addr; }
64  void addSample(int value);
65
66  void print(ostream& out) const;
67private:
68  // Private Methods
69
70  // Private copy constructor and assignment operator
71  // AccessTraceForAddress(const AccessTraceForAddress& obj);
72  // AccessTraceForAddress& operator=(const AccessTraceForAddress& obj);
73
74  // Data Members (m_ prefix)
75
76  Address m_addr;
77  uint64 m_loads;
78  uint64 m_stores;
79  uint64 m_atomics;
80  uint64 m_total;
81  uint64 m_user;
82  uint64 m_sharing;
83  Set m_touched_by;
84  Histogram* m_histogram_ptr;
85};
86
87bool node_less_then_eq(const AccessTraceForAddress* n1, const AccessTraceForAddress* n2);
88
89// Output operator declaration
90ostream& operator<<(ostream& out, const AccessTraceForAddress& obj);
91
92// ******************* Definitions *******************
93
94// Output operator definition
95extern inline
96ostream& operator<<(ostream& out, const AccessTraceForAddress& obj)
97{
98  obj.print(out);
99  out << flush;
100  return out;
101}
102
103#endif //ACCESSTRACEFORADDRESS_H
104