在gem5中打印文件中的所有cache_blocks
Printing all cache_blocks in a file in gem5
我需要在我定义的文本文件中,在每个预定的Tick(例如,每10000 Tick(打印所有cache_blocks及其关联集。有人知道我该怎么做吗?
关于经典的缓存模型,假设您的本地gem5副本与gem5-v19.0.0.0没有太大差异,您将不得不创建一个每X次发生的事件,并调用一个函数将您需要的内容打印到文件中。
您可能会使用BaseSetAssoc作为标记,但为了使其在下面的演练中具有通用性,我假设您已经实现了ExampleTags,这是一个继承自BaseTags的特殊标记类。
您必须将事件包装器添加到src/mem/cache/tags/example_tags.hh以及此包装器将调用的函数:
class ExampleTags : public BaseTags
{
protected:
EventFunctionWrapper snapshotEvent;
void takeSnapshot();
/** Whatever else is needed for this class. */
}
现在,转到src/mem/cache/tags/example_tags.cc。您的标签构造函数应该用它必须调用的函数初始化事件:
ExampleTags::ExampleTags(const Params *p)
: BaseTags(p),
/** ... Initialization of other members ... */
snapshotInterval(p->snapshot_interval),
snapshotEvent([this]{ takeSnapshot(); }, name())
{
// Constructor contents
}
然而,由于gem5初始化事物的方式,第一个事件不应该在构造函数中调度,而应该在startup((函数中调度,该函数必须从SimObject类重写。这是非常重要的,因为如果你是检查点,否则事情就会中断(curTick((在构造函数中有一个不正确的值(:
void
ExampleTags::startup()
{
BaseTags::startup();
// We can only store relevant block information after the blocks have
// been initialized
schedule(snapshotEvent, curTick() + snapshotInterval);
}
最后,快照函数包含您在此间隔内想要做的任何事情:
void
ExampleTags::takeSnapshot()
{
// You can even use the tags' forEachBlk()
for (const auto& blk : blks) {
// Print what you need to the file. The blk.print() function
// can satisfy your needs
}
// Schedule next snapshot
schedule(snapshotEvent, curTick() + snapshotInterval);
}
snapshot_interval将在标签的等效python声明中声明,在src/mem/cache/tags/tags.py中:
class ExampleTags(BaseTags):
# ... Other parameters of these tags ...
snapshot_interval = Param.Unsigned(10000,
"Number of ticks between snapshots")
相关文章:
- 如何更改输出的位置或光标在输出处,以便在"Code Blocks"中C++
- 从Turbo转移到Code :: Blocks
- 我可以删除 *.o文件(代码:: blocks)
- wxTimer 在启动时运行.需要在需要时启动它.(wxWidgets, Code::Blocks, C++)
- 是否可以将"non-static blocks"代码放在类定义中?
- 在 Code::Blocks 中使用自定义安装目录在 Windows 上链接 SDL-bgi
- 在 Linux Mint 中使用 Code::Blocks 设置C++
- 代码:: blocks printf double windows中的固定精度
- CACHE在C 中遗忘的矩阵换位实现
- ofstream在极其简单的程序(GCC/Code::Blocks)中首次输出时崩溃
- 如何在代码中使用 Rcpp::Blocks IDE
- IWebBrowser2 blocks IFileDialog
- 代码::blocks无法从 sdl 库中找到SDL_FreeTexture命令
- 代码:: Blocks Console黑屏?没有错误
- C++ Builder 10.2: Thread blocks WaitForInputIdle
- pthread_mutex_lock blocks but __lock = 0
- wxSmith Code::Blocks Hello World errors
- 保留所有处理器资源、Core和Cache
- C++编译和运行在Geany中,而不是在Netbeans,Eclipse,Code::Blocks中。为什么?
- 在 "Code Blocks" IDE 中混合编程语言?