Sequencer.hh (9117:49116b947194) Sequencer.hh (9171:ae88ecf37145)
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_SYSTEM_SEQUENCER_HH__
30#define __MEM_RUBY_SYSTEM_SEQUENCER_HH__
31
32#include <iostream>
33
34#include "base/hashmap.hh"
35#include "mem/protocol/GenericMachineType.hh"
36#include "mem/protocol/RubyRequestType.hh"
37#include "mem/protocol/SequencerRequestType.hh"
38#include "mem/ruby/common/Address.hh"
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_SYSTEM_SEQUENCER_HH__
30#define __MEM_RUBY_SYSTEM_SEQUENCER_HH__
31
32#include <iostream>
33
34#include "base/hashmap.hh"
35#include "mem/protocol/GenericMachineType.hh"
36#include "mem/protocol/RubyRequestType.hh"
37#include "mem/protocol/SequencerRequestType.hh"
38#include "mem/ruby/common/Address.hh"
39#include "mem/ruby/common/Consumer.hh"
39#include "mem/ruby/system/CacheMemory.hh"
40#include "mem/ruby/system/RubyPort.hh"
40#include "mem/ruby/system/RubyPort.hh"
41#include "params/RubySequencer.hh"
41
42class DataBlock;
42
43class DataBlock;
43class CacheMemory;
44
44
45struct RubySequencerParams;
46
47struct SequencerRequest
48{
49 PacketPtr pkt;
50 RubyRequestType m_type;
51 Time issue_time;
52
53 SequencerRequest(PacketPtr _pkt, RubyRequestType _m_type, Time _issue_time)
54 : pkt(_pkt), m_type(_m_type), issue_time(_issue_time)
55 {}
56};
57
58std::ostream& operator<<(std::ostream& out, const SequencerRequest& obj);
59
45struct SequencerRequest
46{
47 PacketPtr pkt;
48 RubyRequestType m_type;
49 Time issue_time;
50
51 SequencerRequest(PacketPtr _pkt, RubyRequestType _m_type, Time _issue_time)
52 : pkt(_pkt), m_type(_m_type), issue_time(_issue_time)
53 {}
54};
55
56std::ostream& operator<<(std::ostream& out, const SequencerRequest& obj);
57
60class Sequencer : public RubyPort, public Consumer
58class Sequencer : public RubyPort
61{
62 public:
63 typedef RubySequencerParams Params;
64 Sequencer(const Params *);
65 ~Sequencer();
66
67 // Public Methods
68 void wakeup(); // Used only for deadlock detection
69
70 void printProgress(std::ostream& out) const;
71
72 void writeCallback(const Address& address, DataBlock& data);
73
74 void writeCallback(const Address& address,
75 GenericMachineType mach,
76 DataBlock& data);
77
78 void writeCallback(const Address& address,
79 GenericMachineType mach,
80 DataBlock& data,
81 Time initialRequestTime,
82 Time forwardRequestTime,
83 Time firstResponseTime);
84
85 void readCallback(const Address& address, DataBlock& data);
86
87 void readCallback(const Address& address,
88 GenericMachineType mach,
89 DataBlock& data);
90
91 void readCallback(const Address& address,
92 GenericMachineType mach,
93 DataBlock& data,
94 Time initialRequestTime,
95 Time forwardRequestTime,
96 Time firstResponseTime);
97
98 RequestStatus makeRequest(PacketPtr pkt);
99 bool empty() const;
100 int outstandingCount() const { return m_outstanding_count; }
101 bool
102 isDeadlockEventScheduled() const
103 {
104 return deadlockCheckEvent.scheduled();
105 }
106
107 void
108 descheduleDeadlockEvent()
109 {
110 deschedule(deadlockCheckEvent);
111 }
112
113 void print(std::ostream& out) const;
114 void printStats(std::ostream& out) const;
115 void checkCoherence(const Address& address);
116
117 void markRemoved();
118 void removeRequest(SequencerRequest* request);
119 void evictionCallback(const Address& address);
120
121 void recordRequestType(SequencerRequestType requestType);
122
123 private:
124 void issueRequest(PacketPtr pkt, RubyRequestType type);
125
126 void hitCallback(SequencerRequest* request,
127 GenericMachineType mach,
128 DataBlock& data,
129 bool success,
130 Time initialRequestTime,
131 Time forwardRequestTime,
132 Time firstResponseTime);
133
134 RequestStatus insertRequest(PacketPtr pkt, RubyRequestType request_type);
135
136 bool handleLlsc(const Address& address, SequencerRequest* request);
137
138 // Private copy constructor and assignment operator
139 Sequencer(const Sequencer& obj);
140 Sequencer& operator=(const Sequencer& obj);
141
142 private:
143 int m_max_outstanding_requests;
144 int m_deadlock_threshold;
145
146 CacheMemory* m_dataCache_ptr;
147 CacheMemory* m_instCache_ptr;
148
149 typedef m5::hash_map<Address, SequencerRequest*> RequestTable;
150 RequestTable m_writeRequestTable;
151 RequestTable m_readRequestTable;
152 // Global outstanding request count, across all request tables
153 int m_outstanding_count;
154 bool m_deadlock_check_scheduled;
155
156 int m_store_waiting_on_load_cycles;
157 int m_store_waiting_on_store_cycles;
158 int m_load_waiting_on_store_cycles;
159 int m_load_waiting_on_load_cycles;
160
161 bool m_usingNetworkTester;
162
163 class SequencerWakeupEvent : public Event
164 {
165 private:
166 Sequencer *m_sequencer_ptr;
167
168 public:
169 SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {}
170 void process() { m_sequencer_ptr->wakeup(); }
171 const char *description() const { return "Sequencer deadlock check"; }
172 };
173
174 SequencerWakeupEvent deadlockCheckEvent;
175};
176
177inline std::ostream&
178operator<<(std::ostream& out, const Sequencer& obj)
179{
180 obj.print(out);
181 out << std::flush;
182 return out;
183}
184
185#endif // __MEM_RUBY_SYSTEM_SEQUENCER_HH__
59{
60 public:
61 typedef RubySequencerParams Params;
62 Sequencer(const Params *);
63 ~Sequencer();
64
65 // Public Methods
66 void wakeup(); // Used only for deadlock detection
67
68 void printProgress(std::ostream& out) const;
69
70 void writeCallback(const Address& address, DataBlock& data);
71
72 void writeCallback(const Address& address,
73 GenericMachineType mach,
74 DataBlock& data);
75
76 void writeCallback(const Address& address,
77 GenericMachineType mach,
78 DataBlock& data,
79 Time initialRequestTime,
80 Time forwardRequestTime,
81 Time firstResponseTime);
82
83 void readCallback(const Address& address, DataBlock& data);
84
85 void readCallback(const Address& address,
86 GenericMachineType mach,
87 DataBlock& data);
88
89 void readCallback(const Address& address,
90 GenericMachineType mach,
91 DataBlock& data,
92 Time initialRequestTime,
93 Time forwardRequestTime,
94 Time firstResponseTime);
95
96 RequestStatus makeRequest(PacketPtr pkt);
97 bool empty() const;
98 int outstandingCount() const { return m_outstanding_count; }
99 bool
100 isDeadlockEventScheduled() const
101 {
102 return deadlockCheckEvent.scheduled();
103 }
104
105 void
106 descheduleDeadlockEvent()
107 {
108 deschedule(deadlockCheckEvent);
109 }
110
111 void print(std::ostream& out) const;
112 void printStats(std::ostream& out) const;
113 void checkCoherence(const Address& address);
114
115 void markRemoved();
116 void removeRequest(SequencerRequest* request);
117 void evictionCallback(const Address& address);
118
119 void recordRequestType(SequencerRequestType requestType);
120
121 private:
122 void issueRequest(PacketPtr pkt, RubyRequestType type);
123
124 void hitCallback(SequencerRequest* request,
125 GenericMachineType mach,
126 DataBlock& data,
127 bool success,
128 Time initialRequestTime,
129 Time forwardRequestTime,
130 Time firstResponseTime);
131
132 RequestStatus insertRequest(PacketPtr pkt, RubyRequestType request_type);
133
134 bool handleLlsc(const Address& address, SequencerRequest* request);
135
136 // Private copy constructor and assignment operator
137 Sequencer(const Sequencer& obj);
138 Sequencer& operator=(const Sequencer& obj);
139
140 private:
141 int m_max_outstanding_requests;
142 int m_deadlock_threshold;
143
144 CacheMemory* m_dataCache_ptr;
145 CacheMemory* m_instCache_ptr;
146
147 typedef m5::hash_map<Address, SequencerRequest*> RequestTable;
148 RequestTable m_writeRequestTable;
149 RequestTable m_readRequestTable;
150 // Global outstanding request count, across all request tables
151 int m_outstanding_count;
152 bool m_deadlock_check_scheduled;
153
154 int m_store_waiting_on_load_cycles;
155 int m_store_waiting_on_store_cycles;
156 int m_load_waiting_on_store_cycles;
157 int m_load_waiting_on_load_cycles;
158
159 bool m_usingNetworkTester;
160
161 class SequencerWakeupEvent : public Event
162 {
163 private:
164 Sequencer *m_sequencer_ptr;
165
166 public:
167 SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {}
168 void process() { m_sequencer_ptr->wakeup(); }
169 const char *description() const { return "Sequencer deadlock check"; }
170 };
171
172 SequencerWakeupEvent deadlockCheckEvent;
173};
174
175inline std::ostream&
176operator<<(std::ostream& out, const Sequencer& obj)
177{
178 obj.print(out);
179 out << std::flush;
180 return out;
181}
182
183#endif // __MEM_RUBY_SYSTEM_SEQUENCER_HH__