AddressProfiler.hh revision 7048:2ab58c54de63
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 "mem/protocol/AccessType.hh"
33#include "mem/protocol/CacheMsg.hh"
34#include "mem/ruby/common/Address.hh"
35#include "mem/ruby/common/Global.hh"
36#include "mem/ruby/common/Histogram.hh"
37#include "mem/ruby/system/NodeID.hh"
38
39class AccessTraceForAddress;
40class Set;
41template <class KEY_TYPE, class VALUE_TYPE> class Map;
42
43class AddressProfiler
44{
45  public:
46    typedef Map<Address, AccessTraceForAddress> AddressMap;
47
48  public:
49    AddressProfiler(int num_of_sequencers);
50    ~AddressProfiler();
51
52    void printStats(ostream& out) const;
53    void clearStats();
54
55    void addTraceSample(Address data_addr, Address pc_addr,
56                        CacheRequestType type, AccessModeType access_mode,
57                        NodeID id, bool sharing_miss);
58    void profileRetry(const Address& data_addr, AccessType type, int count);
59    void profileGetX(const Address& datablock, const Address& PC,
60                     const Set& owner, const Set& sharers, NodeID requestor);
61    void profileGetS(const Address& datablock, const Address& PC,
62                     const Set& owner, const Set& sharers, NodeID requestor);
63
64    void print(ostream& out) const;
65
66    //added by SS
67    void setHotLines(bool hot_lines);
68    void setAllInstructions(bool all_instructions);
69
70  private:
71    // Private copy constructor and assignment operator
72    AddressProfiler(const AddressProfiler& obj);
73    AddressProfiler& operator=(const AddressProfiler& obj);
74
75    int64 m_sharing_miss_counter;
76
77    AddressMap* m_dataAccessTrace;
78    AddressMap* m_macroBlockAccessTrace;
79    AddressMap* m_programCounterAccessTrace;
80    AddressMap* m_retryProfileMap;
81    Histogram m_retryProfileHisto;
82    Histogram m_retryProfileHistoWrite;
83    Histogram m_retryProfileHistoRead;
84    Histogram m_getx_sharing_histogram;
85    Histogram m_gets_sharing_histogram;
86
87    //added by SS
88    bool m_hot_lines;
89    bool m_all_instructions;
90
91    int m_num_of_sequencers;
92};
93
94inline ostream&
95operator<<(ostream& out, const AddressProfiler& obj)
96{
97    obj.print(out);
98    out << flush;
99    return out;
100}
101
102#endif // __MEM_RUBY_PROFILER_ADDRESSPROFILER_HH__
103