问题描述:有时候我们需要知道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.
CPU缓存层级检测

本文介绍了一种在软件层面检测CPU缓存层级的方法。通过在BaseCache类中添加cache_level成员变量,并将其传递给Python构造函数,使得可以针对特定层级的缓存进行统计和优化。
87

被折叠的 条评论
为什么被折叠?



