Skip to content

Commit c927d4e

Browse files
author
Hasan Hassan
committed
fixing the bug in the cache hierarchy, issue #52;
1 parent 7d2e723 commit c927d4e

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/Cache.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ bool Cache::send(Request req) {
185185

186186
// Send the request to next level;
187187
if (!is_last_level) {
188-
lower_cache->send(req);
188+
if(!lower_cache->send(req)) {
189+
retry_list.push_back(req);
190+
}
189191
} else {
190192
cachesys->wait_list.push_back(
191193
make_pair(cachesys->clk + latency[int(level)], req));
@@ -382,6 +384,18 @@ void Cache::callback(Request& req) {
382384
}
383385
}
384386

387+
void Cache::tick() {
388+
389+
if(!lower_cache->is_last_level)
390+
lower_cache->tick();
391+
392+
for (auto it = retry_list.begin(); it != retry_list.end(); it++) {
393+
if(lower_cache->send(*it))
394+
it = retry_list.erase(it);
395+
}
396+
397+
}
398+
385399
void CacheSystem::tick() {
386400
debug("clk %ld", clk);
387401

src/Cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class Cache {
5353
Cache(int size, int assoc, int block_size, int mshr_entry_num,
5454
Level level, std::shared_ptr<CacheSystem> cachesys);
5555

56+
void tick();
57+
5658
// L1, L2, L3 accumulated latencies
5759
int latency[int(Level::MAX)] = {4, 4 + 12, 4 + 12 + 31};
5860
int latency_each[int(Level::MAX)] = {4, 12, 31};
@@ -81,6 +83,7 @@ class Cache {
8183
unsigned int tag_offset;
8284
unsigned int mshr_entry_num;
8385
std::vector<std::pair<long, std::list<Line>::iterator>> mshr_entries;
86+
std::list<Request> retry_list;
8487

8588
std::map<int, std::list<Line> > cache_lines;
8689

src/Processor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ Core::Core(const Config& configs, int coreid,
164164
caches[0]->concatlower(llc);
165165
}
166166
caches[1]->concatlower(caches[0].get());
167+
168+
first_level_cache = caches[1].get();
167169
}
168170
if (no_core_caches) {
169171
more_reqs = trace.get_filtered_request(
@@ -210,6 +212,9 @@ void Core::tick()
210212
{
211213
clk++;
212214

215+
if(first_level_cache != nullptr)
216+
first_level_cache->tick();
217+
213218
retired += window.retire();
214219

215220
if (expected_limit_insts == 0 && !more_reqs) return;

src/Processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class Core {
106106
bool more_reqs;
107107
long last = 0;
108108

109+
Cache* first_level_cache = nullptr;
110+
109111
ScalarStat memory_access_cycles;
110112
ScalarStat cpu_inst;
111113
MemoryBase& memory;

0 commit comments

Comments
 (0)