AccessTraceForAddress.cc (6145:15cca6ab723a) AccessTraceForAddress.cc (6154:6bb54dcb940e)
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
30/*
31 * $Id$
32 *
33 */
34
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
30/*
31 * $Id$
32 *
33 */
34
35#include "AccessTraceForAddress.hh"
36#include "Histogram.hh"
35#include "mem/ruby/profiler/AccessTraceForAddress.hh"
36#include "mem/ruby/common/Histogram.hh"
37
38AccessTraceForAddress::AccessTraceForAddress()
39{
40 m_histogram_ptr = NULL;
41}
42
43AccessTraceForAddress::AccessTraceForAddress(const Address& addr)
44{
45 m_addr = addr;
46 m_total = 0;
47 m_loads = 0;
48 m_stores = 0;
49 m_atomics = 0;
50 m_user = 0;
51 m_sharing = 0;
52 m_histogram_ptr = NULL;
53}
54
55AccessTraceForAddress::~AccessTraceForAddress()
56{
57 if (m_histogram_ptr != NULL) {
58 delete m_histogram_ptr;
59 m_histogram_ptr = NULL;
60 }
61}
62
63void AccessTraceForAddress::print(ostream& out) const
64{
65 out << m_addr;
66
67 if (m_histogram_ptr == NULL) {
68 out << " " << m_total;
69 out << " | " << m_loads;
70 out << " " << m_stores;
71 out << " " << m_atomics;
72 out << " | " << m_user;
73 out << " " << m_total-m_user;
74 out << " | " << m_sharing;
75 out << " | " << m_touched_by.count();
76 } else {
77 assert(m_total == 0);
78 out << " " << (*m_histogram_ptr);
79 }
80}
81
82void AccessTraceForAddress::update(CacheRequestType type, AccessModeType access_mode, NodeID cpu, bool sharing_miss)
83{
84 m_touched_by.add(cpu);
85 m_total++;
86 if(type == CacheRequestType_ATOMIC) {
87 m_atomics++;
88 } else if(type == CacheRequestType_LD){
89 m_loads++;
90 } else if (type == CacheRequestType_ST){
91 m_stores++;
92 } else {
93 // ERROR_MSG("Trying to add invalid access to trace");
94 }
95
96 if (access_mode == AccessModeType_UserMode) {
97 m_user++;
98 }
99
100 if (sharing_miss) {
101 m_sharing++;
102 }
103}
104
105int AccessTraceForAddress::getTotal() const
106{
107 if (m_histogram_ptr == NULL) {
108 return m_total;
109 } else {
110 return m_histogram_ptr->getTotal();
111 }
112}
113
114void AccessTraceForAddress::addSample(int value)
115{
116 assert(m_total == 0);
117 if (m_histogram_ptr == NULL) {
118 m_histogram_ptr = new Histogram;
119 }
120 m_histogram_ptr->add(value);
121}
122
123bool node_less_then_eq(const AccessTraceForAddress* n1, const AccessTraceForAddress* n2)
124{
125 return (n1->getTotal() > n2->getTotal());
126}
37
38AccessTraceForAddress::AccessTraceForAddress()
39{
40 m_histogram_ptr = NULL;
41}
42
43AccessTraceForAddress::AccessTraceForAddress(const Address& addr)
44{
45 m_addr = addr;
46 m_total = 0;
47 m_loads = 0;
48 m_stores = 0;
49 m_atomics = 0;
50 m_user = 0;
51 m_sharing = 0;
52 m_histogram_ptr = NULL;
53}
54
55AccessTraceForAddress::~AccessTraceForAddress()
56{
57 if (m_histogram_ptr != NULL) {
58 delete m_histogram_ptr;
59 m_histogram_ptr = NULL;
60 }
61}
62
63void AccessTraceForAddress::print(ostream& out) const
64{
65 out << m_addr;
66
67 if (m_histogram_ptr == NULL) {
68 out << " " << m_total;
69 out << " | " << m_loads;
70 out << " " << m_stores;
71 out << " " << m_atomics;
72 out << " | " << m_user;
73 out << " " << m_total-m_user;
74 out << " | " << m_sharing;
75 out << " | " << m_touched_by.count();
76 } else {
77 assert(m_total == 0);
78 out << " " << (*m_histogram_ptr);
79 }
80}
81
82void AccessTraceForAddress::update(CacheRequestType type, AccessModeType access_mode, NodeID cpu, bool sharing_miss)
83{
84 m_touched_by.add(cpu);
85 m_total++;
86 if(type == CacheRequestType_ATOMIC) {
87 m_atomics++;
88 } else if(type == CacheRequestType_LD){
89 m_loads++;
90 } else if (type == CacheRequestType_ST){
91 m_stores++;
92 } else {
93 // ERROR_MSG("Trying to add invalid access to trace");
94 }
95
96 if (access_mode == AccessModeType_UserMode) {
97 m_user++;
98 }
99
100 if (sharing_miss) {
101 m_sharing++;
102 }
103}
104
105int AccessTraceForAddress::getTotal() const
106{
107 if (m_histogram_ptr == NULL) {
108 return m_total;
109 } else {
110 return m_histogram_ptr->getTotal();
111 }
112}
113
114void AccessTraceForAddress::addSample(int value)
115{
116 assert(m_total == 0);
117 if (m_histogram_ptr == NULL) {
118 m_histogram_ptr = new Histogram;
119 }
120 m_histogram_ptr->add(value);
121}
122
123bool node_less_then_eq(const AccessTraceForAddress* n1, const AccessTraceForAddress* n2)
124{
125 return (n1->getTotal() > n2->getTotal());
126}