gem5: 缓存中如何设置writeback dirty cachelines并invalidate该缓存块

经典缓存模型中缓存块操作
本文介绍如何在经典缓存模型中通过Cache::writebackVisitor()和Cache::invalidateVisitor()方法来实现缓存块的回写(writeback)与失效(invalidate),并详细解释了这两种方法的调用过程及注意事项。

参考:MemCmd for CleanInvalid

解决方法:
1.使用classic缓存模型, 在src/mem/cache/cache_impl.hh中有两个方法可以实现缓存块的writeback和invalidate.分别为:Cache::writebackVisistor() 和Cache::invalidateVisitor() ,用法如下:

 BlkType *blk = tags->accessBlock(addr);
 writebackVisitor(*blk);
 invalidateVisitor(*blk);

下文是参考的内容:

Hi Udaya,

The drain() call is used to make sure that there are no transactions pending. The actual writeback and
invalidation is done by memWriteback() and memInvalidate(). The Python world controls draining and
decides what needs to be done. In case of a checkpoint, it will first drain the system (calling drain() and
simulate until all drain() methods return 0, see drain() in src/m5/simulate.py), and then write back
dirty cache lines by calling memWriteback().

In the case of a classic cache, Cache::memWriteback() will call
Cache::writebackVisistor() for each of the blocks in the cache.
Similarly, there is a Cache::invalidateVisitor() that invalidates cache lines.

You will should be able to use the invalidateVisitor right away to invalidate cache lines without writing
them to memory. You could use the writeback visitor to write blocks to memory. It will be functionally
correct, however you won’t get any timing information since it is completely functional (and updates
/all/ copies of the block everywhere in the system). You probably need to implement something similar to
writebackVisitor() that sends an atomic or timing request (the request type depends on the current memory
mode) to the next level in the memory hierarchy.

评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值