如何击败缓存?

发布于 2024-11-19 11:21:03 字数 219 浏览 4 评论 0原文

我本周的作业中有这个问题,我不明白如何击败缓存,或者如何用汇编程序显示它。有人能指出我正确的方向吗?

通过汇编程序示例展示如何击败两种不同的缓存(关联和直接映射)。解释为什么会发生这种情况以及如何解决它。用于破坏缓存的相同程序是否相同?

注意:这是家庭作业。不要只为我回答问题,这无助于我理解材料。

I have this question on my assignment this week, and I don't understand how the caches can be defeated, or how I can show it with an assembly program.. Can someone point me in the right direction?

Show, with assembly program examples, how the two different caches (Associative and Direct Mapping) can be defeated. Explain why this occurs and how it can be fixed. Are the same programs used to defeat the caches the same?

Note: This is homework. Don't just answer the question for me, it won't help me to understand the material.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

内心激荡 2024-11-26 11:21:03

缓存是为了提高性能。因此,击败缓存意味着找到一种内存访问模式,该模式会降低性能(在存在缓存的情况下)而不是提高性能。

请记住,缓存的大小是有限的(例如,小于主内存),因此通常要破坏缓存就需要填充缓存,以便它在您访问数据之前丢弃您即将访问的数据。

A cache is there to increase performance. So defeating a cache means finding a pattern of memory accesses that decreases performance (in the presence of the cache) rather than increases it.

Bear in mind that the cache is limited in size (smaller than main memory, for instance) so typically defeating the cache involves filling it up so that it throws away the data you're just about to access, just before you access it.

心头的小情儿 2024-11-26 11:21:03

如果您正在寻找提示,请考虑将数据字拆分到 2 个缓存行。

(如果您也在寻找答案,x264 开发人员也遇到了类似的问题 - 可用的更多信息 此处此处 的链接内容丰富,我强烈建议您使用。即使你找到了答案,也要阅读它们。)

If you're looking for a hint, think about splitting a data word across 2 cache lines.

(In case you're also looking for the answer, a similar problem was encountered by the x264 developers -- more information available here and here. The links are highly informative, and I really suggest you read them even after you've found your answer.)

我还不会笑 2024-11-26 11:21:03

另一件需要记住的事情是您处理的缓存是虚拟的还是物理的索引/标记。在某些变体中,即使缓存本身没有完全填满,缓存别名也会强制进行行替换。在其他变体中,缓存/页面着色冲突可能会导致驱逐。最后,在某些工作负载下的多处理器系统中,缓存行迁移(不同 CPU 的缓存之间)可能会限制 CPU 缓存的有用性。

Another thing to keep in mind is whether the caches you deal with are virtually or physically indexed / tagged. In some variants, cache aliasing forces line replacements even if the cache as such isn't completely filled. In other variants, cache/page coloring collisions might cause evictions. Finally, in multiprocessor systems under certain workloads, cacheline migrations (between the caches of different CPUs) may limit the usefulness of CPU caches.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文