gem5 v24.0.0.0
Loading...
Searching...
No Matches
mshr.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2013, 2015-2016, 2018 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2002-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
46#ifndef __MEM_CACHE_MSHR_HH__
47#define __MEM_CACHE_MSHR_HH__
48
49#include <cassert>
50#include <iosfwd>
51#include <list>
52#include <string>
53#include <vector>
54
55#include "base/printable.hh"
56#include "base/trace.hh"
57#include "base/types.hh"
58#include "debug/MSHR.hh"
60#include "mem/packet.hh"
61#include "mem/request.hh"
62#include "sim/cur_tick.hh"
63
64namespace gem5
65{
66
67class BaseCache;
68
74class MSHR : public QueueEntry, public Printable
75{
76
80 template<typename Entry>
81 friend class Queue;
82 friend class MSHRQueue;
83
84 private:
85
88
114
117
120
121 public:
122
125
128
130 {
131 public:
132
139
141
158
159 const bool allocOnFill;
161
162 Target(PacketPtr _pkt, Tick _readyTime, Counter _order,
163 Source _source, bool _markedPending, bool alloc_on_fill)
164 : QueueEntry::Target(_pkt, _readyTime, _order), source(_source),
165 markedPending(_markedPending), allocOnFill(alloc_on_fill)
166 {}
167 };
168
169 class TargetList : public std::list<Target>, public Named
170 {
171
172 public:
182
183 TargetList(const std::string &name = ".unnamedTargetList");
184
193 void updateFlags(PacketPtr pkt, Target::Source source,
194 bool alloc_on_fill);
195
202 void init(Addr blk_addr, Addr blk_size) {
203 blkAddr = blk_addr;
204 blkSize = blk_size;
205 writesBitmap.resize(blk_size);
206
207 resetFlags();
208 }
209
210 void resetFlags() {
211 canMergeWrites = true;
212 std::fill(writesBitmap.begin(), writesBitmap.end(), false);
213
214 needsWritable = false;
215 hasUpgrade = false;
216 allocOnFill = false;
217 hasFromCache = false;
218 }
219
226 void populateFlags();
227
235 void updateWriteFlags(PacketPtr pkt);
236
243 bool isReset() const {
244 return !needsWritable && !hasUpgrade && !allocOnFill &&
246 }
247
261 Target::Source source, bool markPending, bool alloc_on_fill);
262
267 void replaceUpgrades();
268
270 void clearDownstreamPending(iterator begin, iterator end);
272 void print(std::ostream &os, int verbosity,
273 const std::string &prefix) const;
274
282 bool isWholeLineWrite() const
283 {
284 return std::all_of(writesBitmap.begin(), writesBitmap.end(),
285 [](bool i) { return i; });
286 }
287
288 private:
291
294
297
298 // NOTE: std::vector<bool> might not meet satisfy the
299 // ForwardIterator requirement and therefore cannot be used
300 // for writesBitmap.
306 };
307
311 typedef List::iterator Iterator;
312
319 bool needsWritable() const { return targets.needsWritable; }
320
321 bool isCleaning() const {
322 PacketPtr pkt = targets.front().pkt;
323 return pkt->isClean();
324 }
325
326 bool isPendingModified() const {
327 assert(inService); return pendingModified;
328 }
329
330 bool hasPostInvalidate() const {
331 assert(inService); return postInvalidate;
332 }
333
334 bool hasPostDowngrade() const {
335 assert(inService); return postDowngrade;
336 }
337
338 bool sendPacket(BaseCache &cache) override;
339
340 bool allocOnFill() const {
341 return targets.allocOnFill;
342 }
343
349 bool hasFromCache() const {
350 return targets.hasFromCache;
351 }
352
361
368
369 private:
379 void promoteIf(const std::function<bool (Target &)>& pred);
380
386
392
395
397
398 public:
406 bool isWholeLineWrite() const {
407 return targets.isWholeLineWrite();
408 }
409
419 void allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt,
420 Tick when_ready, Counter _order, bool alloc_on_fill);
421
422 void markInService(bool pending_modified_resp);
423
425
429 void deallocate();
430
435 void allocateTarget(PacketPtr target, Tick when, Counter order,
436 bool alloc_on_fill);
437 bool handleSnoop(PacketPtr target, Counter order);
438
440 MSHR(const std::string &name);
441
446 int getNumTargets() const
447 { return targets.size() + deferredTargets.size(); }
448
461 TargetList extractServiceableTargets(PacketPtr pkt);
462
467 bool hasTargets() const { return !targets.empty(); }
468
474 {
475 assert(hasTargets());
476 return &targets.front();
477 }
478
483 {
484 DPRINTF(MSHR, "Force deallocating MSHR targets: %s\n",
485 targets.front().pkt->print());
486 targets.pop_front();
487 }
488
490
499 void promoteReadable();
500
508 void promoteWritable();
509
511
516 void delay(Tick delay_ticks)
517 {
518 assert(readyTime <= curTick());
519 readyTime = curTick() + delay_ticks;
520 }
521
525 void print(std::ostream &os,
526 int verbosity = 0,
527 const std::string &prefix = "") const override;
534 std::string print() const;
535
536 bool matchBlockAddr(const Addr addr, const bool is_secure) const override;
537 bool matchBlockAddr(const PacketPtr pkt) const override;
538 bool conflictAddr(const QueueEntry* entry) const override;
539};
540
541} // namespace gem5
542
543#endif // __MEM_CACHE_MSHR_HH__
#define DPRINTF(x,...)
Definition trace.hh:210
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A basic cache interface.
Definition base.hh:100
A Class for maintaining a list of pending and allocated memory requests.
Definition mshr_queue.hh:62
void updateFlags(PacketPtr pkt, Target::Source source, bool alloc_on_fill)
Use the provided packet and the source to update the flags of this TargetList.
Definition mshr.cc:81
void replaceUpgrades()
Convert upgrades to the equivalent request if the cache line they refer to would have been invalid (U...
Definition mshr.cc:222
void populateFlags()
Goes through the list of targets and uses them to populate the flags of this TargetList.
Definition mshr.cc:109
Addr blkSize
Size of the cache block.
Definition mshr.hh:293
bool trySatisfyFunctional(PacketPtr pkt)
Definition mshr.cc:264
bool isReset() const
Tests if the flags of this TargetList have their default values.
Definition mshr.hh:243
Addr blkAddr
Address of the cache block for this list of targets.
Definition mshr.hh:290
bool allocOnFill
Set when the response should allocate on fill.
Definition mshr.hh:176
std::vector< char > writesBitmap
Track which bytes are written by requests in this target list.
Definition mshr.hh:305
void add(PacketPtr pkt, Tick readyTime, Counter order, Target::Source source, bool markPending, bool alloc_on_fill)
Add the specified packet in the TargetList.
Definition mshr.cc:164
void print(std::ostream &os, int verbosity, const std::string &prefix) const
Definition mshr.cc:277
bool canMergeWrites
Indicates whether we can merge incoming write requests.
Definition mshr.hh:296
void updateWriteFlags(PacketPtr pkt)
Add the specified packet in the TargetList.
Definition mshr.cc:118
TargetList(const std::string &name=".unnamedTargetList")
Definition mshr.cc:73
void clearDownstreamPending(iterator begin, iterator end)
void init(Addr blk_addr, Addr blk_size)
Reset state.
Definition mshr.hh:202
bool isWholeLineWrite() const
Check if this list contains writes that cover an entire cache line.
Definition mshr.hh:282
bool hasFromCache
Determine whether there was at least one non-snooping target coming from another cache.
Definition mshr.hh:181
void clearDownstreamPending()
Definition mshr.cc:257
Target(PacketPtr _pkt, Tick _readyTime, Counter _order, Source _source, bool _markedPending, bool alloc_on_fill)
Definition mshr.hh:162
const bool allocOnFill
Should the response servicing this target list allocate in the cache?
Definition mshr.hh:159
bool markedPending
We use this flag to track whether we have cleared the downstreamPending flag for the MSHR of the cach...
Definition mshr.hh:157
const Source source
Request from cpu, memory, or prefetcher?
Definition mshr.hh:140
Miss Status and handling Register.
Definition mshr.hh:75
bool postInvalidate
Did we snoop an invalidate while waiting for data?
Definition mshr.hh:116
TargetList targets
List of all requests that match the address.
Definition mshr.hh:394
void clearDownstreamPending()
Definition mshr.cc:334
bool wasWholeLineWrite
Track if we sent this as a whole line write or not.
Definition mshr.hh:124
void updateLockedRMWReadTarget(PacketPtr pkt)
Replaces the matching packet in the Targets list with a dummy packet to ensure the MSHR remains alloc...
Definition mshr.cc:786
std::string print() const
A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overhea...
Definition mshr.cc:757
MSHR(const std::string &name)
A simple constructor.
Definition mshr.cc:62
void promoteIf(const std::function< bool(Target &)> &pred)
Promotes deferred targets that satisfy a predicate.
Definition mshr.cc:636
void delay(Tick delay_ticks)
Adds a delay relative to the current tick to the current MSHR.
Definition mshr.hh:516
void markInService(bool pending_modified_resp)
Definition mshr.cc:344
bool downstreamPending
Flag set by downstream caches.
Definition mshr.hh:87
TargetList extractServiceableTargets(PacketPtr pkt)
Extracts the subset of the targets that can be serviced given a received response.
Definition mshr.cc:548
bool isPendingModified() const
Definition mshr.hh:326
List::iterator Iterator
MSHR list iterator.
Definition mshr.hh:311
bool postDowngrade
Did we snoop a read while waiting for data?
Definition mshr.hh:119
bool conflictAddr(const QueueEntry *entry) const override
Check if given entry's packets conflict with this' entries packets.
Definition mshr.cc:779
void promoteReadable()
Promotes deferred targets that do not require writable.
Definition mshr.cc:659
void popTarget()
Pop first target.
Definition mshr.hh:482
bool isCleaning() const
Definition mshr.hh:321
bool pendingModified
Here we use one flag to track both if:
Definition mshr.hh:113
void allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter _order, bool alloc_on_fill)
Allocate a miss to this MSHR.
Definition mshr.cc:304
TargetList deferredTargets
Definition mshr.hh:396
bool sendPacket(BaseCache &cache) override
Send this queue entry as a downstream packet, with the exact behaviour depending on the specific entr...
Definition mshr.cc:725
int getNumTargets() const
Returns the current number of allocated targets.
Definition mshr.hh:446
bool trySatisfyFunctional(PacketPtr pkt)
Definition mshr.cc:710
bool hasPostDowngrade() const
Definition mshr.hh:334
QueueEntry::Target * getTarget() override
Returns a reference to the first target.
Definition mshr.hh:473
Iterator readyIter
Pointer to this MSHR on the ready list.
Definition mshr.hh:385
bool matchBlockAddr(const Addr addr, const bool is_secure) const override
Check if entry corresponds to the one being looked for.
Definition mshr.cc:765
bool handleSnoop(PacketPtr target, Counter order)
Definition mshr.cc:424
bool needsWritable() const
The pending* and post* flags are only valid if inService is true.
Definition mshr.hh:319
bool isForward
True if the entry is just a simple forward from an upper level.
Definition mshr.hh:127
bool hasLockedRMWReadTarget()
Determine if there are any LockedRMWReads in the Targets list.
Definition mshr.cc:794
bool hasFromCache() const
Determine if there are non-deferred requests from other caches.
Definition mshr.hh:349
bool promoteDeferredTargets()
Definition mshr.cc:597
bool isWholeLineWrite() const
Check if this MSHR contains only compatible writes, and if they span the entire cache line.
Definition mshr.hh:406
void allocateTarget(PacketPtr target, Tick when, Counter order, bool alloc_on_fill)
Add a request to the list of targets.
Definition mshr.cc:377
void promoteWritable()
Promotes deferred targets that do not require writable.
Definition mshr.cc:680
bool hasPostInvalidate() const
Definition mshr.hh:330
void deallocate()
Mark this MSHR as free.
Definition mshr.cc:365
Iterator allocIter
Pointer to this MSHR on the allocated list.
Definition mshr.hh:391
std::list< MSHR * > List
A list of MSHRs.
Definition mshr.hh:309
bool allocOnFill() const
Definition mshr.hh:340
bool hasTargets() const
Returns true if there are targets left.
Definition mshr.hh:467
Interface for things with names.
Definition named.hh:39
virtual std::string name() const
Definition named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
bool isClean() const
Definition packet.hh:611
Abstract base class for objects which support being printed to a stream for debugging.
Definition printable.hh:48
A queue entry is holding packets that will be serviced as soon as resources are available.
A queue entry base class, to be used by both the MSHRs and write-queue entries.
Counter order
Order number assigned to disambiguate writes and misses.
bool inService
True if the entry has been sent downstream.
Tick readyTime
Tick when ready to issue.
A high-level queue interface, to be used by both the MSHR queue and the write buffer.
Definition queue.hh:71
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 27, 24 > pred
Definition types.hh:90
Bitfield< 17 > os
Definition misc.hh:838
Bitfield< 3 > addr
Definition types.hh:84
double Counter
All counters are of 64-bit values.
Definition types.hh:46
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Declaration of the Packet class.
Generic queue entry.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0