StoreTrace.hh revision 6145:15cca6ab723a
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 StoreTrace_H
38#define StoreTrace_H
39
40#include "Global.hh"
41#include "RubyConfig.hh"
42#include "Address.hh"
43#include "Histogram.hh"
44
45class StoreTrace {
46public:
47  // Constructors
48  StoreTrace() { }
49  explicit StoreTrace(const Address& addr);
50
51  // Destructor
52  ~StoreTrace();
53
54  // Public Methods
55  void store(NodeID node);
56  void downgrade(NodeID node);
57  int getTotal() const { return m_total_samples; }
58  static void initSummary();
59  static void printSummary(ostream& out);
60  static void clearSummary();
61
62  void print(ostream& out) const;
63private:
64  // Private Methods
65
66  // Private copy constructor and assignment operator
67  //  StoreTrace(const StoreTrace& obj);
68  //  StoreTrace& operator=(const StoreTrace& obj);
69
70  // Class Members (s_ prefix)
71  static bool s_init;
72  static int64 s_total_samples; // Total number of store lifetimes of all lines
73  static Histogram* s_store_count_ptr;
74  static Histogram* s_store_first_to_stolen_ptr;
75  static Histogram* s_store_last_to_stolen_ptr;
76  static Histogram* s_store_first_to_last_ptr;
77
78  // Data Members (m_ prefix)
79
80  Address m_addr;
81  NodeID m_last_writer;
82  Time m_first_store;
83  Time m_last_store;
84  int m_stores_this_interval;
85
86  int64 m_total_samples; // Total number of store lifetimes of this line
87  Histogram m_store_count;
88  Histogram m_store_first_to_stolen;
89  Histogram m_store_last_to_stolen;
90  Histogram m_store_first_to_last;
91};
92
93bool node_less_then_eq(const StoreTrace* n1, const StoreTrace* n2);
94
95// Output operator declaration
96ostream& operator<<(ostream& out, const StoreTrace& obj);
97
98// ******************* Definitions *******************
99
100// Output operator definition
101extern inline
102ostream& operator<<(ostream& out, const StoreTrace& obj)
103{
104  obj.print(out);
105  out << flush;
106  return out;
107}
108
109#endif //StoreTrace_H
110