snoop_filter.hh (12429:beefb9f5f551) | snoop_filter.hh (14005:6cad91d6136c) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2013-2016 ARM Limited | 2 * Copyright (c) 2013-2016,2019 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 --- 29 unchanged lines hidden (view full) --- 40/** 41 * @file 42 * Definition of a snoop filter. 43 */ 44 45#ifndef __MEM_SNOOP_FILTER_HH__ 46#define __MEM_SNOOP_FILTER_HH__ 47 | 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 --- 29 unchanged lines hidden (view full) --- 40/** 41 * @file 42 * Definition of a snoop filter. 43 */ 44 45#ifndef __MEM_SNOOP_FILTER_HH__ 46#define __MEM_SNOOP_FILTER_HH__ 47 |
48#include <bitset> |
|
48#include <unordered_map> 49#include <utility> 50 51#include "mem/packet.hh" 52#include "mem/port.hh" 53#include "mem/qport.hh" 54#include "params/SnoopFilter.hh" 55#include "sim/sim_object.hh" --- 25 unchanged lines hidden (view full) --- 81 * pkt, instead of proper messages through the bus 82 * (3) there are no clean evict messages telling the snoop filter that a local, 83 * upper cache dropped a line, making the snoop filter pessimistic for now 84 * (4) ordering: there is no single point of order in the system. Instead, 85 * requesting MSHRs track order between local requests and remote snoops 86 */ 87class SnoopFilter : public SimObject { 88 public: | 49#include <unordered_map> 50#include <utility> 51 52#include "mem/packet.hh" 53#include "mem/port.hh" 54#include "mem/qport.hh" 55#include "params/SnoopFilter.hh" 56#include "sim/sim_object.hh" --- 25 unchanged lines hidden (view full) --- 82 * pkt, instead of proper messages through the bus 83 * (3) there are no clean evict messages telling the snoop filter that a local, 84 * upper cache dropped a line, making the snoop filter pessimistic for now 85 * (4) ordering: there is no single point of order in the system. Instead, 86 * requesting MSHRs track order between local requests and remote snoops 87 */ 88class SnoopFilter : public SimObject { 89 public: |
90 91 // Change for systems with more than 256 ports tracked by this object 92 static const int SNOOP_MASK_SIZE = 256; 93 |
|
89 typedef std::vector<QueuedSlavePort*> SnoopList; 90 91 SnoopFilter (const SnoopFilterParams *p) : 92 SimObject(p), reqLookupResult(cachedLocations.end()), retryItem{0, 0}, 93 linesize(p->system->cacheLineSize()), lookupLatency(p->lookup_latency), 94 maxEntryCount(p->max_capacity / p->system->cacheLineSize()) 95 { 96 } --- 12 unchanged lines hidden (view full) --- 109 // no need to track this port if it is not snooping 110 if (p->isSnooping()) { 111 slavePorts.push_back(p); 112 localSlavePortIds[p->getId()] = id++; 113 } 114 } 115 116 // make sure we can deal with this many ports | 94 typedef std::vector<QueuedSlavePort*> SnoopList; 95 96 SnoopFilter (const SnoopFilterParams *p) : 97 SimObject(p), reqLookupResult(cachedLocations.end()), retryItem{0, 0}, 98 linesize(p->system->cacheLineSize()), lookupLatency(p->lookup_latency), 99 maxEntryCount(p->max_capacity / p->system->cacheLineSize()) 100 { 101 } --- 12 unchanged lines hidden (view full) --- 114 // no need to track this port if it is not snooping 115 if (p->isSnooping()) { 116 slavePorts.push_back(p); 117 localSlavePortIds[p->getId()] = id++; 118 } 119 } 120 121 // make sure we can deal with this many ports |
117 fatal_if(id > 8 * sizeof(SnoopMask), | 122 fatal_if(id > SNOOP_MASK_SIZE, |
118 "Snoop filter only supports %d snooping ports, got %d\n", | 123 "Snoop filter only supports %d snooping ports, got %d\n", |
119 8 * sizeof(SnoopMask), id); | 124 SNOOP_MASK_SIZE, id); |
120 } 121 122 /** 123 * Lookup a request (from a slave port) in the snoop filter and 124 * return a list of other slave ports that need forwarding of the 125 * resulting snoops. Additionally, update the tracking structures 126 * with new request information. Note that the caller must also 127 * call finishRequest once it is known if the request needs to --- 65 unchanged lines hidden (view full) --- 193 void updateResponse(const Packet *cpkt, const SlavePort& slave_port); 194 195 virtual void regStats(); 196 197 protected: 198 199 /** 200 * The underlying type for the bitmask we use for tracking. This | 125 } 126 127 /** 128 * Lookup a request (from a slave port) in the snoop filter and 129 * return a list of other slave ports that need forwarding of the 130 * resulting snoops. Additionally, update the tracking structures 131 * with new request information. Note that the caller must also 132 * call finishRequest once it is known if the request needs to --- 65 unchanged lines hidden (view full) --- 198 void updateResponse(const Packet *cpkt, const SlavePort& slave_port); 199 200 virtual void regStats(); 201 202 protected: 203 204 /** 205 * The underlying type for the bitmask we use for tracking. This |
201 * limits the number of snooping ports supported per crossbar. For 202 * the moment it is an uint64_t to offer maximum 203 * scalability. However, it is possible to use e.g. a uint16_t or 204 * uint32_to slim down the footprint of the hash map (and 205 * ultimately improve the simulation performance). | 206 * limits the number of snooping ports supported per crossbar. |
206 */ | 207 */ |
207 typedef uint64_t SnoopMask; | 208 typedef std::bitset<SNOOP_MASK_SIZE> SnoopMask; |
208 209 /** 210 * Per cache line item tracking a bitmask of SlavePorts who have an 211 * outstanding request to this line (requested) or already share a 212 * cache line with this address (holder). 213 */ 214 struct SnoopItem { 215 SnoopMask requested; --- 93 unchanged lines hidden (view full) --- 309 ((SnoopMask)1) << localSlavePortIds[port.getId()]; 310} 311 312inline SnoopFilter::SnoopList 313SnoopFilter::maskToPortList(SnoopMask port_mask) const 314{ 315 SnoopList res; 316 for (const auto& p : slavePorts) | 209 210 /** 211 * Per cache line item tracking a bitmask of SlavePorts who have an 212 * outstanding request to this line (requested) or already share a 213 * cache line with this address (holder). 214 */ 215 struct SnoopItem { 216 SnoopMask requested; --- 93 unchanged lines hidden (view full) --- 310 ((SnoopMask)1) << localSlavePortIds[port.getId()]; 311} 312 313inline SnoopFilter::SnoopList 314SnoopFilter::maskToPortList(SnoopMask port_mask) const 315{ 316 SnoopList res; 317 for (const auto& p : slavePorts) |
317 if (port_mask & portToMask(*p)) | 318 if ((port_mask & portToMask(*p)).any()) |
318 res.push_back(p); 319 return res; 320} 321 322#endif // __MEM_SNOOP_FILTER_HH__ | 319 res.push_back(p); 320 return res; 321} 322 323#endif // __MEM_SNOOP_FILTER_HH__ |