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