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

来源:互联网 发布:硬盘修复数据恢复 编辑:程序博客网 时间:2024/05/16 02:14

参考: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.

1 0
原创粉丝点击