gem5 classic memory实现cache sampling set
来源:互联网 发布:南京软件测试工资待遇 编辑:程序博客网 时间:2024/06/07 12:56
问题: 如何实现缓存set的抽样呢?比如2MB的LLC,cache line 64Byte, 32-way,那么拥有1024个set。现在要抽取其中的32个set,该set独立于LLC,但访问行为与LLC一致,如第0个,第32个,第64个……等,该抽样的set仅仅保留tag即可。那么如何实现呢?
思路:
- 与此部分相关的内容主要集中在gem5/src/mem/cache/目录下的cache_impl.hh和tags目录下的cacheset.hh和lru.cc等文件;
- cache_impl.hh是对缓存访问行为控制的文件,与访问lru的set一样,需要访问我们的sampling set;
- 由于lru.cc访问的cacheset都使用的是cacheset.hh这个模板文件,实际上set的个数及管理也是由lru.cc来控制的,那么这32个set就可以由自定义的mylru.cc来控制;
方法:
1、首先搭建sample set的样子,即该set的管理方法,生成samplelru.hh和samplelru.cc;
cp lru.cc samplelru.cccp lru.hh samplelru.hh
2、 为了能访问samplelru,需要修改gem5/src/mem/cache下的BaseCache.py,得到新的tags;
sampletags = Param.BaseTags(SampleLRU(), "Tag Store for SampleLRU caches")
3、在cache_impl.hh中修改初始化函数。
template<class TagStore>Cache<TagStore>::Cache(const Params *p) : BaseCache(p), //tags(dynamic_cast<TagStore*>(p->tags)), tags(Cache<LRU>(p->tags)), //将tags固定为LRU sampletags(p->sampletags), // new add prefetcher(p->prefetcher), doFastWrites(true), prefetchOnAccess(p->prefetch_on_access)// 同时在access函数中增加对samplelru.cc中accessBlock方法的调用BlkType *sampblk; sampblk = sampletags->accessBlock(pkt->getAddr(), lat, id); //由于初始化没有使用dynamic_cast<TagStore*>,那么需要将src/mem/cache/base.cc最后一个函数注释掉BaseCache *BaseCacheParams::create(){//下面的内容注释掉/** unsigned numSets = size / (assoc * system->cacheLineSize()); assert(tags); if (dynamic_cast<FALRU*>(tags)) { if (numSets != 1) fatal("Got FALRU tags with more than one set\n"); return new Cache<FALRU>(this); } else if (dynamic_cast<LRU*>(tags)) { if (numSets == 1) warn("Consider using FALRU tags for a fully associative cache\n"); return new Cache<LRU>(this); } else { fatal("No suitable tags selected\n"); }*/return NULL;}
4、修改samplelru.cc和samplelru.hh,将里面的LRU全部替换为SampleLRU;
5、修改SConscript文件,添加:
Source('samplelru.cc')
6、修改Tags.py,添加:
class SampleLRU(BaseTags): type = 'SampleLRU' cxx_class = 'SampleLRU' cxx_header = "mem/cache/tags/samplelru.hh" assoc = Param.Int(Parent.assoc, "associativity") part = Param.Int(Parent.part, "partition")
经过上述修改后,编译下scons build/ALPHA/gem5.debug,会有如下错误:
build/ALPHA/mem/cache/cache_impl.hh: In constructor 'Cache<TagStore>::Cache(const Params*)':build/ALPHA/mem/cache/cache_impl.hh:73:7: error: class 'Cache<TagStore>' does not have any field named 'sampletags'build/ALPHA/mem/cache/cache_impl.hh: In member function 'bool Cache<TagStore>::access(PacketPtr, Cache<TagStore>::BlkType*&, Cycles&, PacketList&)':build/ALPHA/mem/cache/cache_impl.hh:333:15: error: 'sampletags' was not declared in this scopescons: *** [build/ALPHA/mem/cache/cache.do] Error 1
7、修改cache.hh和cache.cc,添加:
//在cache.hh/** SampleTag and data Storage */ TagStore *sampletags; //在cache.cc#include "mem/cache/tags/samplelru.hh"//注释掉如下两行//template class Cache<SampleLRU>;//template class Cache<SampleLRU>;
0 0
- gem5 classic memory实现cache sampling set
- gem5: classic缓存模型下多bank实现 - mem: model data array bank in classic cache
- [代码阅读]gem5 classic cache初步(2)
- [代码阅读]gem5 classic cache初步(3)
- [代码阅读]gem5中的classic cache 初步(1)
- gem5: the trace of cache set and cache line write hit counters
- 基于gem5模拟trace的cache模拟器的实现
- gem5 模拟exclusive cache
- classic memory layout & flexible memory layout
- Memory cache
- Cache Memory
- Memory Cache
- classic memory layout&…
- classic memory layout&…
- buffer cache和 cache memory
- memory cache 和 disk cache
- Gibbs Sampling实现LDA
- gem5
- Apache 和 nginx 之间的配置
- Winsdows黑客技术入门---简介
- Office 365 IT Professional——利用PowerShell更改Password 永不过期时间和提醒时间
- 根据STL 学习数据结构
- 板子启动ubuntu无法进入命令行
- gem5 classic memory实现cache sampling set
- 说老的平凡故事
- Android 多线程处理之多线程用法大集合 第2页
- dojo的TabContainer竖排摆放tab标签
- 大数据
- hdu 1875 畅通工程再续
- [算法] 洗牌算法&随机算法
- MapReduce手册(官网)
- Eclipse一些操作