StoreTrace.hh revision 11031:3815437cb231
12SN/A/* 21762SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A */ 282665SN/A 292SN/A#ifndef __MEM_RUBY_PROFILER_STORETRACE_HH__ 302SN/A#define __MEM_RUBY_PROFILER_STORETRACE_HH__ 312SN/A 322SN/A#include <iostream> 332SN/A 342SN/A#include "base/types.hh" 3511263Sandreas.sandberg@arm.com#include "mem/ruby/common/Address.hh" 3611263Sandreas.sandberg@arm.com#include "mem/ruby/common/Histogram.hh" 372SN/A 382SN/Aclass StoreTrace 392SN/A{ 402SN/A public: 414981SN/A StoreTrace() { } 4212056Sgabeblack@google.com explicit StoreTrace(Addr addr); 4311263Sandreas.sandberg@arm.com ~StoreTrace(); 4411263Sandreas.sandberg@arm.com 4511263Sandreas.sandberg@arm.com void store(NodeID node); 4612056Sgabeblack@google.com void downgrade(NodeID node); 4712056Sgabeblack@google.com int getTotal() const { return m_total_samples; } 4812056Sgabeblack@google.com static void initSummary(); 4912056Sgabeblack@google.com static void printSummary(std::ostream& out); 5012056Sgabeblack@google.com static void clearSummary(); 5112056Sgabeblack@google.com 5212054Sgabeblack@google.com void print(std::ostream& out) const; 5356SN/A 5456SN/A private: 552SN/A static bool s_init; 561872SN/A static int64_t s_total_samples; // Total number of store lifetimes 5712055Sgabeblack@google.com // of all lines 5812055Sgabeblack@google.com static Histogram* s_store_count_ptr; 5912055Sgabeblack@google.com static Histogram* s_store_first_to_stolen_ptr; 6012055Sgabeblack@google.com static Histogram* s_store_last_to_stolen_ptr; 6112055Sgabeblack@google.com static Histogram* s_store_first_to_last_ptr; 6212055Sgabeblack@google.com 6312055Sgabeblack@google.com Addr m_addr; 6412055Sgabeblack@google.com NodeID m_last_writer; 6512055Sgabeblack@google.com Tick m_first_store; 6612055Sgabeblack@google.com Tick m_last_store; 6712055Sgabeblack@google.com int m_stores_this_interval; 6812055Sgabeblack@google.com 6912055Sgabeblack@google.com int64_t m_total_samples; // Total number of store lifetimes of this line 7012055Sgabeblack@google.com Histogram m_store_count; 7112055Sgabeblack@google.com Histogram m_store_first_to_stolen; 7212055Sgabeblack@google.com Histogram m_store_last_to_stolen; 7312055Sgabeblack@google.com Histogram m_store_first_to_last; 7412055Sgabeblack@google.com}; 7512055Sgabeblack@google.com 7612055Sgabeblack@google.cominline bool 7712055Sgabeblack@google.comnode_less_then_eq(const StoreTrace* n1, const StoreTrace* n2) 7812055Sgabeblack@google.com{ 7912055Sgabeblack@google.com return n1->getTotal() > n2->getTotal(); 8012055Sgabeblack@google.com} 8112055Sgabeblack@google.com 8212055Sgabeblack@google.cominline std::ostream& 8312055Sgabeblack@google.comoperator<<(std::ostream& out, const StoreTrace& obj) 8412055Sgabeblack@google.com{ 8512055Sgabeblack@google.com obj.print(out); 8612055Sgabeblack@google.com out << std::flush; 8712055Sgabeblack@google.com return out; 8812055Sgabeblack@google.com} 8912055Sgabeblack@google.com 9012055Sgabeblack@google.com#endif // __MEM_RUBY_PROFILER_STORETRACE_HH__ 9112055Sgabeblack@google.com