StoreTrace.hh revision 11031:3815437cb231
11689SN/A/* 21689SN/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 292665Ssaidi@eecs.umich.edu#ifndef __MEM_RUBY_PROFILER_STORETRACE_HH__ 301689SN/A#define __MEM_RUBY_PROFILER_STORETRACE_HH__ 311689SN/A 322292SN/A#include <iostream> 332292SN/A 341060SN/A#include "base/types.hh" 352165SN/A#include "mem/ruby/common/Address.hh" 362669Sktlim@umich.edu#include "mem/ruby/common/Histogram.hh" 371681SN/A 381858SN/Aclass StoreTrace 391717SN/A{ 401060SN/A public: 411858SN/A StoreTrace() { } 421681SN/A explicit StoreTrace(Addr addr); 431681SN/A ~StoreTrace(); 441681SN/A 451063SN/A void store(NodeID node); 462292SN/A void downgrade(NodeID node); 471060SN/A int getTotal() const { return m_total_samples; } 482292SN/A static void initSummary(); 492292SN/A static void printSummary(std::ostream& out); 502669Sktlim@umich.edu static void clearSummary(); 512669Sktlim@umich.edu 522292SN/A void print(std::ostream& out) const; 531061SN/A 541060SN/A private: 551060SN/A static bool s_init; 562107SN/A static int64_t s_total_samples; // Total number of store lifetimes 572107SN/A // of all lines 582107SN/A static Histogram* s_store_count_ptr; 592669Sktlim@umich.edu static Histogram* s_store_first_to_stolen_ptr; 602107SN/A static Histogram* s_store_last_to_stolen_ptr; 612159SN/A static Histogram* s_store_first_to_last_ptr; 622159SN/A 632669Sktlim@umich.edu Addr m_addr; 642669Sktlim@umich.edu NodeID m_last_writer; 652669Sktlim@umich.edu Tick m_first_store; 662669Sktlim@umich.edu Tick m_last_store; 671060SN/A int m_stores_this_interval; 682292SN/A 692292SN/A int64_t m_total_samples; // Total number of store lifetimes of this line 701060SN/A Histogram m_store_count; 712292SN/A Histogram m_store_first_to_stolen; 722292SN/A Histogram m_store_last_to_stolen; 731060SN/A Histogram m_store_first_to_last; 742733Sktlim@umich.edu}; 751060SN/A 762292SN/Ainline bool 772292SN/Anode_less_then_eq(const StoreTrace* n1, const StoreTrace* n2) 782292SN/A{ 792292SN/A return n1->getTotal() > n2->getTotal(); 801060SN/A} 811060SN/A 821060SN/Ainline std::ostream& 831060SN/Aoperator<<(std::ostream& out, const StoreTrace& obj) 841060SN/A{ 851060SN/A obj.print(out); 861060SN/A out << std::flush; 871060SN/A return out; 882292SN/A} 891060SN/A 901060SN/A#endif // __MEM_RUBY_PROFILER_STORETRACE_HH__ 911061SN/A