From 83f88cd1c0f27adb4704b374541bd6aff7e3e3fb Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Thu, 22 Mar 2018 11:24:54 +0100 Subject: [PATCH] mem-cache: Fix FALRU data block seg fault FALRU didn't initialize the blocks' data, causing seg faults. This patch does not make FALRU functional yet. Change-Id: I10cbcf5afc3f8bc357eeb8b7cb46789dec47ba8b Reviewed-on: https://gem5-review.googlesource.com/9302 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/cache/tags/base.cc | 3 ++- src/mem/cache/tags/base.hh | 3 +++ src/mem/cache/tags/base_set_assoc.cc | 1 - src/mem/cache/tags/base_set_assoc.hh | 3 --- src/mem/cache/tags/fa_lru.cc | 5 +++++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc index 8b52b746e..d2d6e8eef 100644 --- a/src/mem/cache/tags/base.cc +++ b/src/mem/cache/tags/base.cc @@ -63,7 +63,8 @@ BaseTags::BaseTags(const Params *p) std::max(p->tag_latency, p->data_latency)), cache(nullptr), warmupBound((p->warmup_percentage/100.0) * (p->size / p->block_size)), - warmedUp(false), numBlocks(p->size / p->block_size) + warmedUp(false), numBlocks(p->size / p->block_size), + dataBlks(new uint8_t[p->size]) // Allocate data storage in one big chunk { } diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh index 74fc7e0d0..3370de284 100644 --- a/src/mem/cache/tags/base.hh +++ b/src/mem/cache/tags/base.hh @@ -94,6 +94,9 @@ class BaseTags : public ClockedObject /** the number of blocks in the cache */ const unsigned numBlocks; + /** The data blocks, 1 per cache block. */ + std::unique_ptr dataBlks; + // Statistics /** * TODO: It would be good if these stats were acquired after warmup. diff --git a/src/mem/cache/tags/base_set_assoc.cc b/src/mem/cache/tags/base_set_assoc.cc index 2475e6fc0..0ab806ee9 100644 --- a/src/mem/cache/tags/base_set_assoc.cc +++ b/src/mem/cache/tags/base_set_assoc.cc @@ -57,7 +57,6 @@ using namespace std; BaseSetAssoc::BaseSetAssoc(const Params *p) :BaseTags(p), assoc(p->assoc), allocAssoc(p->assoc), blks(p->size / p->block_size), - dataBlks(new uint8_t[p->size]), // Allocate data storage in one big chunk numSets(p->size / (p->block_size * p->assoc)), sequentialAccess(p->sequential_access), sets(p->size / (p->block_size * p->assoc)), diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index f7b386a92..3bc275b28 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -76,7 +76,6 @@ class BaseSetAssoc : public BaseTags /** Typedef the set type used in this tag store. */ typedef CacheSet SetType; - protected: /** The associativity of the cache. */ const unsigned assoc; @@ -85,8 +84,6 @@ class BaseSetAssoc : public BaseTags /** The cache blocks. */ std::vector blks; - /** The data blocks, 1 per cache block. */ - std::unique_ptr dataBlks; /** The number of sets in the cache. */ const unsigned numSets; diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc index a38d0bf34..1f2909e31 100644 --- a/src/mem/cache/tags/fa_lru.cc +++ b/src/mem/cache/tags/fa_lru.cc @@ -80,10 +80,12 @@ FALRU::FALRU(const Params *p) head->prev = nullptr; head->next = &(blks[1]); head->inCache = cacheMask; + head->data = &dataBlks[0]; tail->prev = &(blks[numBlocks-2]); tail->next = nullptr; tail->inCache = 0; + tail->data = &dataBlks[(numBlocks-1)*blkSize]; unsigned index = (1 << 17) / blkSize; unsigned j = 0; @@ -100,6 +102,9 @@ FALRU::FALRU(const Params *p) blks[i].next = &(blks[i+1]); blks[i].set = 0; blks[i].way = i; + + // Associate a data chunk to the block + blks[i].data = &dataBlks[blkSize*i]; } assert(j == numCaches); assert(index == numBlocks); -- 2.30.2