gem5: 在缓存代码中如何识别缓存是L1,L2还是L3呢?

来源:互联网 发布:mac webpack 编辑:程序博客网 时间:2024/06/05 06:42

参考:Checking Cache Levels

问题描述:有时候我们需要知道cpu当前在访问缓存的哪一级,然后针对性的作出信息统计,那么如何知道是L几呢?

方法:
If you want to know which level the target cache is at, I can tell you a simple approach that I used.

(1) Add a member variable in the BaseCache class in both .cc and .py called cache-level.
a.在BaseCache.py中加入cache_level.

cache_level = Param.Int("The cache level of this cache")

b.在base.hh中定义cache_level

const int cacheLevel;

c.在base.cc中初始化cache_level

cacheLevel(p->cache_level),

(2) Pass the cache level information to the python constructor function of L1 and L2 caches in config/example/se.py or whatever.
a.在configs/common/CacheConfig.py中加入对应的缓存加上级别设置,即

cache_level=1

(3) in the constructor function of C++ Caches, assign the python variable value to the C++ variable value.

(4) use the cache level information in your source code.

2 0
原创粉丝点击