stride.hh (13424:1744211c9a65) | stride.hh (13425:00abf35b2f7e) |
---|---|
1/* 2 * Copyright (c) 2012-2013, 2015 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 --- 75 unchanged lines hidden (view full) --- 84 bool isSecure; 85 int stride; 86 int confidence; 87 }; 88 89 class PCTable 90 { 91 public: | 1/* 2 * Copyright (c) 2012-2013, 2015 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 --- 75 unchanged lines hidden (view full) --- 84 bool isSecure; 85 int stride; 86 int confidence; 87 }; 88 89 class PCTable 90 { 91 public: |
92 PCTable(int assoc, int sets, const std::string name) : 93 pcTableAssoc(assoc), pcTableSets(sets), _name(name) {} | 92 /** 93 * Default constructor. Create a table with given parameters. 94 * 95 * @param assoc Associativity of the table. 96 * @param sets Number of sets in the table. 97 * @param name Name of the prefetcher. 98 */ 99 PCTable(int assoc, int sets, const std::string name); |
94 | 100 |
95 std::vector<std::vector<StrideEntry>>& operator[] (int context) { 96 auto it = entries.find(context); 97 if (it != entries.end()) 98 return it->second; | 101 /** 102 * Default destructor. 103 */ 104 ~PCTable(); |
99 | 105 |
100 return allocateNewContext(context); 101 } | 106 /** 107 * Search for an entry in the pc table. 108 * 109 * @param pc The PC to look for. 110 * @param is_secure True if the target memory space is secure. 111 * @return Pointer to the entry. 112 */ 113 StrideEntry* findEntry(Addr pc, bool is_secure); |
102 | 114 |
103 ~PCTable(); | 115 /** 116 * Find a replacement victim to make room for given PC. 117 * 118 * @param pc The PC value. 119 * @return The victimized entry. 120 */ 121 StrideEntry* findVictim(Addr pc); 122 |
104 private: 105 const std::string name() {return _name; } 106 const int pcTableAssoc; 107 const int pcTableSets; 108 const std::string _name; | 123 private: 124 const std::string name() {return _name; } 125 const int pcTableAssoc; 126 const int pcTableSets; 127 const std::string _name; |
109 std::unordered_map<int, std::vector<std::vector<StrideEntry>>> entries; | 128 std::vector<std::vector<StrideEntry>> entries; |
110 | 129 |
111 std::vector<std::vector<StrideEntry>>& allocateNewContext(int context); | 130 /** 131 * PC hashing function to index sets in the table. 132 * 133 * @param pc The PC value. 134 * @return The set to which this PC maps. 135 */ 136 Addr pcHash(Addr pc) const; |
112 }; | 137 }; |
113 PCTable pcTable; | 138 std::unordered_map<int, PCTable> pcTables; |
114 115 /** | 139 140 /** |
116 * Search for an entry in the pc table. | 141 * Try to find a table of entries for the given context. If none is 142 * found, a new table is created. |
117 * | 143 * |
118 * @param pc The PC to look for. 119 * @param is_secure True if the target memory space is secure. 120 * @param master_id The context. 121 * @return Pointer to the entry. | 144 * @param context The context to be searched for. 145 * @return The table corresponding to the given context. |
122 */ | 146 */ |
123 StrideEntry* findEntry(Addr pc, bool is_secure, int master_id); | 147 PCTable* findTable(int context); |
124 | 148 |
125 StrideEntry* pcTableVictim(Addr pc, int master_id); | 149 /** 150 * Create a PC table for the given context. 151 * 152 * @param context The context of the new PC table. 153 * @return The new PC table 154 */ 155 PCTable* allocateNewContext(int context); |
126 | 156 |
127 Addr pcHash(Addr pc) const; | |
128 public: | 157 public: |
129 | |
130 StridePrefetcher(const StridePrefetcherParams *p); 131 132 void calculatePrefetch(const PacketPtr &pkt, 133 std::vector<AddrPriority> &addresses) override; 134}; 135 136#endif // __MEM_CACHE_PREFETCH_STRIDE_HH__ | 158 StridePrefetcher(const StridePrefetcherParams *p); 159 160 void calculatePrefetch(const PacketPtr &pkt, 161 std::vector<AddrPriority> &addresses) override; 162}; 163 164#endif // __MEM_CACHE_PREFETCH_STRIDE_HH__ |