57 turnPolicy(
p.qos_turnaround_policy),
59 _numPriorities(
p.qos_priorities),
60 qosPriorityEscalation(
p.qos_priority_escalation),
61 qosSyncroScheduler(
p.qos_syncro_scheduler),
62 totalReadQueueSize(0), totalWriteQueueSize(0),
63 busState(READ), busStateNext(READ),
99 "qos::MemCtrl::logRequest REQUESTOR %s [id %d] address %#x"
100 " prio %d this requestor q packets %d"
101 " - queue size %d - requested entries %d\n",
109 }
else if (dir ==
WRITE) {
115 for (
auto j = 0; j < entries; ++j) {
131 "qos::MemCtrl::logRequest REQUESTOR %s [id %d]"
132 " registering priority distance %d for priority %d"
140 "qos::MemCtrl::logRequest REQUESTOR %s [id %d] prio %d "
141 "this requestor q packets %d - new queue size %d\n",
149 Addr addr, uint64_t entries,
double delay)
152 "Logging response with invalid requestor\n");
155 "qos::MemCtrl::logResponse REQUESTOR %s [id %d] address %#x prio"
156 " %d this requestor q packets %d"
157 " - queue size %d - requested entries %d\n",
165 }
else if (dir ==
WRITE) {
171 "qos::MemCtrl::logResponse requestor %s negative packets "
176 for (
auto j = 0; j < entries; ++j) {
179 "qos::MemCtrl::logResponse requestor %s unmatched response "
183 uint64_t requestTime = it->second.front();
186 it->second.pop_front();
189 if (it->second.empty()) {
193 double latency = (double) (
curTick() + delay - requestTime)
210 "qos::MemCtrl::logResponse REQUESTOR %s [id %d] prio %d "
211 "this requestor q packets %d - new queue size %d\n",
223 "qos::MemCtrl::schedule requestor id [%d] "
224 "data received [%d], but QoS scheduler not initialized\n",
238 DPRINTF(QOS,
"qos::MemCtrl::schedule Packet received [Qv %d], "
239 "but QoS scheduler not initialized\n",
252 "qos::MemCtrl::selectNextBusState running policy %s\n",
258 "qos::MemCtrl::selectNextBusState running "
259 "default bus direction selection policy\n");
281 "qos::MemCtrl::addRequestor registering"
282 " Requestor %s [id %d]\n",
288 : statistics::
Group(&mc),
291 ADD_STAT(avgPriority, statistics::units::Count::get(),
292 "Average QoS priority value for accepted requests"),
293 ADD_STAT(avgPriorityDistance, statistics::units::Count::get(),
294 "Average QoS priority distance between assigned and queued "
297 ADD_STAT(priorityMinLatency, statistics::units::Second::get(),
298 "per QoS priority minimum request to response latency"),
299 ADD_STAT(priorityMaxLatency, statistics::units::Second::get(),
300 "per QoS priority maximum request to response latency"),
301 ADD_STAT(numReadWriteTurnArounds, statistics::units::Count::get(),
302 "Number of turnarounds from READ to WRITE"),
303 ADD_STAT(numWriteReadTurnArounds, statistics::units::Count::get(),
304 "Number of turnarounds from WRITE to READ"),
305 ADD_STAT(numStayReadState, statistics::units::Count::get(),
306 "Number of times bus staying in READ state"),
307 ADD_STAT(numStayWriteState, statistics::units::Count::get(),
308 "Number of times bus staying in WRITE state")
317 using namespace statistics;
321 const auto num_priorities = memCtrl.numPriorities();
325 .init(max_requestors)
331 .init(max_requestors)
336 .init(num_priorities)
341 .init(num_priorities)
345 for (
int i = 0;
i < max_requestors;
i++) {
347 avgPriority.subname(
i,
name);
348 avgPriorityDistance.subname(
i,
name);
351 for (
int j = 0; j < num_priorities; ++j) {
352 priorityMinLatency.subname(j, std::to_string(j));
353 priorityMaxLatency.subname(j, std::to_string(j));
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
RequestPtr req
A pointer to the original request.
std::string getRequestorName(RequestorID requestor_id)
Get the name of an object for a given request id.
RequestorID maxRequestors()
Get the number of requestors registered in the system.
The qos::MemCtrl is a base class for Memory objects which support QoS - it provides access to a set o...
BusState getBusState() const
Gets the current bus state.
void logResponse(BusState dir, RequestorID id, uint8_t _qos, Addr addr, uint64_t entries, double delay)
Called upon receiving a response, updates statistics and updates queues status.
std::vector< uint64_t > writeQueueSizes
Write request packets queue length in #packets, per QoS priority.
uint64_t totalWriteQueueSize
Total write request packets queue length in #packets.
void recordTurnaroundStats(BusState busState, BusState busStateNext)
Record statistics on turnarounds based on busStateNext and busState values.
std::vector< Tick > serviceTick
Vector of QoS priorities/last service time.
std::unordered_map< RequestorID, std::vector< uint64_t > > packetPriorities
Hash of requestors - number of packets queued per priority.
std::vector< uint64_t > readQueueSizes
Read request packets queue length in #packets, per QoS priority.
const std::unique_ptr< Policy > policy
QoS Policy, assigns QoS priority to the incoming packets.
const std::unique_ptr< QueuePolicy > queuePolicy
QoS Queue Policy: selects packet among same-priority queue.
MemCtrl(const QoSMemCtrlParams &)
QoS Memory base class.
BusState selectNextBusState()
Returns next bus direction (READ or WRITE) based on configured policy.
const std::unique_ptr< TurnaroundPolicy > turnPolicy
QoS Bus Turnaround Policy: selects the bus direction (READ/WRITE)
bool hasRequestor(RequestorID id) const
hasRequestor returns true if the selected requestor(ID) has been registered in the memory controller,...
uint8_t numPriorities() const
Gets the total number of priority levels in the QoS memory controller.
uint64_t getTotalWriteQueueSize() const
Gets the total combined WRITE queues size.
const uint8_t _numPriorities
Number of configured QoS priorities.
void addRequestor(const RequestorID id)
Initializes dynamically counters and statistics for a given Requestor.
BusState busState
Bus state used to control the read/write switching and drive the scheduling of the next request.
System * _system
Pointer to the System object.
uint64_t totalReadQueueSize
Total read request packets queue length in #packets.
std::unordered_map< RequestorID, std::unordered_map< uint64_t, std::deque< uint64_t > > > requestTimes
Hash of requestors - address of request - queue of times of request.
gem5::memory::qos::MemCtrl::MemCtrlStats stats
System * system() const
read the system pointer
BusState busStateNext
bus state for next request event triggered
uint8_t schedule(RequestorID id, uint64_t data)
uint64_t getTotalReadQueueSize() const
Gets the total combined READ queues size.
std::unordered_map< RequestorID, const std::string > requestors
Hash of requestor ID - requestor name.
void logRequest(BusState dir, RequestorID id, uint8_t _qos, Addr addr, uint64_t entries)
Called upon receiving a request or updates statistics and updates queues status.
void value(VCounter &vec) const
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
virtual void regStats()
Callback to set stat parameters.
double s
These variables equal the number of ticks in the unit of time they're named after in a double.
const FlagsType nonan
Don't print if this is NAN.
const FlagsType nozero
Don't print if this is zero.
Copyright (c) 2024 Arm Limited All rights reserved.
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
statistics::VectorStandardDeviation avgPriorityDistance
per-requestor average QoS distance between assigned and queued values
statistics::VectorStandardDeviation avgPriority
per-requestor average QoS priority
statistics::Vector priorityMaxLatency
per-priority maximum latency
statistics::Vector priorityMinLatency
per-priority minimum latency
statistics::Scalar numStayReadState
Count the number of times bus staying in READ state.
MemCtrlStats(MemCtrl &mc)
statistics::Scalar numReadWriteTurnArounds
Count the number of turnarounds READ to WRITE.
void regStats() override
Callback to set stat parameters.
statistics::Scalar numStayWriteState
Count the number of times bus staying in WRITE state.
statistics::Scalar numWriteReadTurnArounds
Count the number of turnarounds WRITE to READ.