windows下如何关闭缓存的预取?

发布于 2024-08-24 11:50:44 字数 37 浏览 5 评论 0原文

在C/C++程序中,如何关闭Windows系统中各核的预取?

In a C/C++ program, how to close the prefetch of each core in the Windows system?

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

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

发布评论

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

评论(2

过度放纵 2024-08-31 11:50:44

有一个 Windows API 调用 FlushInstructionCache()

也许这就是您所需要的?它通常由自修改代码使用,以确保 RAM 中代码的更改对处理器可见。

There is a Windows API call FlushInstructionCache()

Perhaps this is what you need? It is typically used by self modifying code to make sure changes to code in the RAM are visible to the processor.

孤独难免 2024-08-31 11:50:44

我在一些代码中看到过这个技巧,虽然我不能 100% 确定这个技巧是否是您正在寻找的,但是,代码是这样的

Sleep(0);

通过使用 Sleep(0),您可以清除CPU指令并导致上下文切换...现在您确实说了“对于每个核心”,我认为您不能显式选择一个核心来执行此操作,因为您如何知道哪个核心正在运行所需的代码关闭缓存的预取......

I have seen this trick mentioned in some code, although I am not 100% sure if this trick is what you're looking for, however, the code was this

Sleep(0);

By using Sleep(0), you are clearing the CPU instructions and cause a context switch... Now you did say 'for each core', I do not think you can explicitly select a core to do that as how do you know which core is running the code that is need of a closing the pre-fetching of the cache....

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