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
| 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
|
30/* 31 * $Id$ 32 * 33 */ 34 35#include "mem/ruby/profiler/StoreTrace.hh"
| |
36#include "mem/ruby/eventqueue/RubyEventQueue.hh"
| 29#include "mem/ruby/eventqueue/RubyEventQueue.hh"
|
| 30#include "mem/ruby/profiler/StoreTrace.hh"
|
37
| 31
|
38bool StoreTrace::s_init = false; // Total number of store lifetimes of all lines 39int64 StoreTrace::s_total_samples = 0; // Total number of store lifetimes of all lines
| 32bool StoreTrace::s_init = false; // Total number of store lifetimes of 33 // all lines 34int64 StoreTrace::s_total_samples = 0; // Total number of store 35 // lifetimes of all lines
|
40Histogram* StoreTrace::s_store_count_ptr = NULL; 41Histogram* StoreTrace::s_store_first_to_stolen_ptr = NULL; 42Histogram* StoreTrace::s_store_last_to_stolen_ptr = NULL; 43Histogram* StoreTrace::s_store_first_to_last_ptr = NULL; 44
| 36Histogram* StoreTrace::s_store_count_ptr = NULL; 37Histogram* StoreTrace::s_store_first_to_stolen_ptr = NULL; 38Histogram* StoreTrace::s_store_last_to_stolen_ptr = NULL; 39Histogram* StoreTrace::s_store_first_to_last_ptr = NULL; 40
|
45StoreTrace::StoreTrace(const Address& addr) : 46 m_store_count(-1), m_store_first_to_stolen(-1), m_store_last_to_stolen(-1), m_store_first_to_last(-1)
| 41StoreTrace::StoreTrace(const Address& addr) 42 : m_store_count(-1), m_store_first_to_stolen(-1), 43 m_store_last_to_stolen(-1), m_store_first_to_last(-1)
|
47{
| 44{
|
48 StoreTrace::initSummary(); 49 m_addr = addr; 50 m_total_samples = 0; 51 m_last_writer = -1; // Really -1 isn't valid, so this will trigger the initilization code 52 m_stores_this_interval = 0;
| 45 StoreTrace::initSummary(); 46 m_addr = addr; 47 m_total_samples = 0; 48 49 // Really -1 isn't valid, so this will trigger the initilization code 50 m_last_writer = -1; 51 m_stores_this_interval = 0;
|
53} 54 55StoreTrace::~StoreTrace() 56{ 57} 58
| 52} 53 54StoreTrace::~StoreTrace() 55{ 56} 57
|
59void StoreTrace::print(ostream& out) const
| 58void 59StoreTrace::print(ostream& out) const
|
60{
| 60{
|
61 out << m_addr; 62 out << " total_samples: " << m_total_samples << endl; 63 out << "store_count: " << m_store_count << endl; 64 out << "store_first_to_stolen: " << m_store_first_to_stolen << endl; 65 out << "store_last_to_stolen: " << m_store_last_to_stolen << endl; 66 out << "store_first_to_last: " << m_store_first_to_last << endl;
| 61 out << m_addr 62 << " total_samples: " << m_total_samples << endl 63 << "store_count: " << m_store_count << endl 64 << "store_first_to_stolen: " << m_store_first_to_stolen << endl 65 << "store_last_to_stolen: " << m_store_last_to_stolen << endl 66 << "store_first_to_last: " << m_store_first_to_last << endl;
|
67} 68
| 67} 68
|
69// Class method 70void StoreTrace::initSummary()
| 69void 70StoreTrace::initSummary()
|
71{
| 71{
|
72 if (!s_init) { 73 s_total_samples = 0; 74 s_store_count_ptr = new Histogram(-1); 75 s_store_first_to_stolen_ptr = new Histogram(-1); 76 s_store_last_to_stolen_ptr = new Histogram(-1); 77 s_store_first_to_last_ptr = new Histogram(-1); 78 } 79 s_init = true;
| 72 if (!s_init) { 73 s_total_samples = 0; 74 s_store_count_ptr = new Histogram(-1); 75 s_store_first_to_stolen_ptr = new Histogram(-1); 76 s_store_last_to_stolen_ptr = new Histogram(-1); 77 s_store_first_to_last_ptr = new Histogram(-1); 78 } 79 s_init = true;
|
80} 81
| 80} 81
|
82// Class method 83void StoreTrace::printSummary(ostream& out)
| 82void 83StoreTrace::printSummary(ostream& out)
|
84{
| 84{
|
85 out << "total_samples: " << s_total_samples << endl; 86 out << "store_count: " << (*s_store_count_ptr) << endl; 87 out << "store_first_to_stolen: " << (*s_store_first_to_stolen_ptr) << endl; 88 out << "store_last_to_stolen: " << (*s_store_last_to_stolen_ptr) << endl; 89 out << "store_first_to_last: " << (*s_store_first_to_last_ptr) << endl;
| 85 out << "total_samples: " << s_total_samples << endl; 86 out << "store_count: " << (*s_store_count_ptr) << endl; 87 out << "store_first_to_stolen: " << (*s_store_first_to_stolen_ptr) << endl; 88 out << "store_last_to_stolen: " << (*s_store_last_to_stolen_ptr) << endl; 89 out << "store_first_to_last: " << (*s_store_first_to_last_ptr) << endl;
|
90} 91
| 90} 91
|
92// Class method 93void StoreTrace::clearSummary()
| 92void 93StoreTrace::clearSummary()
|
94{
| 94{
|
95 StoreTrace::initSummary(); 96 s_total_samples = 0; 97 s_store_count_ptr->clear(); 98 s_store_first_to_stolen_ptr->clear(); 99 s_store_last_to_stolen_ptr->clear(); 100 s_store_first_to_last_ptr->clear();
| 95 StoreTrace::initSummary(); 96 s_total_samples = 0; 97 s_store_count_ptr->clear(); 98 s_store_first_to_stolen_ptr->clear(); 99 s_store_last_to_stolen_ptr->clear(); 100 s_store_first_to_last_ptr->clear();
|
101} 102
| 101} 102
|
103void StoreTrace::store(NodeID node)
| 103void 104StoreTrace::store(NodeID node)
|
104{
| 105{
|
105 Time current = g_eventQueue_ptr->getTime();
| 106 Time current = g_eventQueue_ptr->getTime();
|
106
| 107
|
107 assert((m_last_writer == -1) || (m_last_writer == node));
| 108 assert((m_last_writer == -1) || (m_last_writer == node));
|
108
| 109
|
109 m_last_writer = node; 110 if (m_last_writer == -1) { 111 assert(m_stores_this_interval == 0); 112 }
| 110 m_last_writer = node; 111 if (m_last_writer == -1) { 112 assert(m_stores_this_interval == 0); 113 }
|
113
| 114
|
114 if (m_stores_this_interval == 0) { 115 // A new proessor just wrote the line, so reset the stats 116 m_first_store = current; 117 }
| 115 if (m_stores_this_interval == 0) { 116 // A new proessor just wrote the line, so reset the stats 117 m_first_store = current; 118 }
|
118
| 119
|
119 m_last_store = current; 120 m_stores_this_interval++;
| 120 m_last_store = current; 121 m_stores_this_interval++;
|
121} 122
| 122} 123
|
123void StoreTrace::downgrade(NodeID node)
| 124void 125StoreTrace::downgrade(NodeID node)
|
124{
| 126{
|
125 if (node == m_last_writer) { 126 Time current = g_eventQueue_ptr->getTime(); 127 assert(m_stores_this_interval != 0); 128 assert(m_last_store != 0); 129 assert(m_first_store != 0); 130 assert(m_last_writer != -1);
| 127 if (node == m_last_writer) { 128 Time current = g_eventQueue_ptr->getTime(); 129 assert(m_stores_this_interval != 0); 130 assert(m_last_store != 0); 131 assert(m_first_store != 0); 132 assert(m_last_writer != -1);
|
131
| 133
|
132 // Per line stats 133 m_store_first_to_stolen.add(current - m_first_store); 134 m_store_count.add(m_stores_this_interval); 135 m_store_last_to_stolen.add(current - m_last_store); 136 m_store_first_to_last.add(m_last_store - m_first_store); 137 m_total_samples++;
| 134 // Per line stats 135 m_store_first_to_stolen.add(current - m_first_store); 136 m_store_count.add(m_stores_this_interval); 137 m_store_last_to_stolen.add(current - m_last_store); 138 m_store_first_to_last.add(m_last_store - m_first_store); 139 m_total_samples++;
|
138
| 140
|
139 // Global stats 140 assert(s_store_first_to_stolen_ptr != NULL); 141 s_store_first_to_stolen_ptr->add(current - m_first_store); 142 s_store_count_ptr->add(m_stores_this_interval); 143 s_store_last_to_stolen_ptr->add(current - m_last_store); 144 s_store_first_to_last_ptr->add(m_last_store - m_first_store); 145 s_total_samples++;
| 141 // Global stats 142 assert(s_store_first_to_stolen_ptr != NULL); 143 s_store_first_to_stolen_ptr->add(current - m_first_store); 144 s_store_count_ptr->add(m_stores_this_interval); 145 s_store_last_to_stolen_ptr->add(current - m_last_store); 146 s_store_first_to_last_ptr->add(m_last_store - m_first_store); 147 s_total_samples++;
|
146
| 148
|
147 // Initilize for next go round 148 m_stores_this_interval = 0; 149 m_last_store = 0; 150 m_first_store = 0; 151 m_last_writer = -1; 152 }
| 149 // Initilize for next go round 150 m_stores_this_interval = 0; 151 m_last_store = 0; 152 m_first_store = 0; 153 m_last_writer = -1; 154 }
|
153}
| 155}
|
154 155bool node_less_then_eq(const StoreTrace* n1, const StoreTrace* n2) 156{ 157 return (n1->getTotal() > n2->getTotal()); 158}
| |
| |