AddressProfiler.hh revision 8165:5955406f7ed0
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#ifndef __MEM_RUBY_PROFILER_ADDRESSPROFILER_HH__ 30#define __MEM_RUBY_PROFILER_ADDRESSPROFILER_HH__ 31 32#include <iostream> 33 34#include "base/hashmap.hh" 35#include "mem/protocol/AccessType.hh" 36#include "mem/protocol/CacheMsg.hh" 37#include "mem/ruby/common/Address.hh" 38#include "mem/ruby/common/Global.hh" 39#include "mem/ruby/common/Histogram.hh" 40#include "mem/ruby/profiler/AccessTraceForAddress.hh" 41#include "mem/ruby/system/NodeID.hh" 42 43class Set; 44 45class AddressProfiler 46{ 47 public: 48 typedef m5::hash_map<Address, AccessTraceForAddress> AddressMap; 49 50 public: 51 AddressProfiler(int num_of_sequencers); 52 ~AddressProfiler(); 53 54 void printStats(std::ostream& out) const; 55 void clearStats(); 56 57 void addTraceSample(Address data_addr, Address pc_addr, 58 RubyRequestType type, RubyAccessMode access_mode, 59 NodeID id, bool sharing_miss); 60 void profileRetry(const Address& data_addr, AccessType type, int count); 61 void profileGetX(const Address& datablock, const Address& PC, 62 const Set& owner, const Set& sharers, NodeID requestor); 63 void profileGetS(const Address& datablock, const Address& PC, 64 const Set& owner, const Set& sharers, NodeID requestor); 65 66 void print(std::ostream& out) const; 67 68 //added by SS 69 void setHotLines(bool hot_lines); 70 void setAllInstructions(bool all_instructions); 71 72 private: 73 // Private copy constructor and assignment operator 74 AddressProfiler(const AddressProfiler& obj); 75 AddressProfiler& operator=(const AddressProfiler& obj); 76 77 int64 m_sharing_miss_counter; 78 79 AddressMap m_dataAccessTrace; 80 AddressMap m_macroBlockAccessTrace; 81 AddressMap m_programCounterAccessTrace; 82 AddressMap m_retryProfileMap; 83 Histogram m_retryProfileHisto; 84 Histogram m_retryProfileHistoWrite; 85 Histogram m_retryProfileHistoRead; 86 Histogram m_getx_sharing_histogram; 87 Histogram m_gets_sharing_histogram; 88 89 //added by SS 90 bool m_hot_lines; 91 bool m_all_instructions; 92 93 int m_num_of_sequencers; 94}; 95 96inline std::ostream& 97operator<<(std::ostream& out, const AddressProfiler& obj) 98{ 99 obj.print(out); 100 out << std::flush; 101 return out; 102} 103 104#endif // __MEM_RUBY_PROFILER_ADDRESSPROFILER_HH__ 105