从操作系统/应用程序分析 CPU 缓存/内存? [英] Profiling CPU Cache/Memory from the OS/Application?

查看:31
本文介绍了从操作系统/应用程序分析 CPU 缓存/内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望编写能够基本上分析 CPU 缓存(L2、L3,可能是 L1)和内存的软件,以分析性能.

I wish to write software which could essentially profile the CPU cache (L2,L3, possibly L1) and the memory, to analyze performance.

我是否认为这是不可行的,因为软件无法访问缓存内容?

Am I right in thinking this is un-doable because there is no access for the software to the cache content?

我的问题的另一种表述方式:有没有办法从操作系统/应用程序级别知道哪些数据已加载到缓存/内存中?

Another way of wording my Q: is there any way to know, from the OS/Application level, what data has been loaded into cache/memory?

操作系统 Windows 或 Linux 和 CPU Intel Desktop/Xeon

Operating System Windows or Linux and CPU Intel Desktop/Xeon

推荐答案

您可能想看看英特尔的 PMU,即性能监控单元.一些处理器有一个.它是一堆特殊用途的寄存器(英特尔称之为模型特定寄存器,或 MSR),您可以使用 RDMSRWRMSR 对它们进行编程以计算事件,例如缓存未命中说明.

You might want to look at Intel's PMU i.e. Performance Monitoring Unit. Some processors have one. It is a bunch of special purpose registers (Intel calls them Model Specific Registers, or MSRs) which you can program to count events, like cache misses, using the RDMSR and WRMSR instructions.

这是关于i7 和至强 5500 性能分析的文档.

您可能想查看英特尔的性能Counter Monitor,它基本上是一些抽象 PMU 的例程,您可以在 C++ 应用程序中使用它们来实时测量多个性能指标,包括缓存未命中.它还具有一些独立使用的 GUI/命令行工具.

You might want to check out Intel's Performance Counter Monitor, which is basically some routines that abstract the PMU, which you can use in a C++ application to measure several performance metrics live, including cache misses. It also has some GUI/Commandline tools for standalone use.

显然,Linux 内核有一个工具用于操纵 MSR.

还有其他实用程序/API 也使用 PMU:perfPAPI.

There are other utilities/APIs that also use the PMU: perf, PAPI.

这篇关于从操作系统/应用程序分析 CPU 缓存/内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆