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

查看:87
本文介绍了从OS/应用程序分析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?

用另一种方式表达我的Q:从OS/应用程序级别,有什么方法可以知道哪些数据已加载到缓存/内存中?

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英特尔台式机/至强

Operating System Windows or Linux and CPU Intel Desktop/Xeon

推荐答案

您可能需要查看英特尔的PMU,即性能监视单元.有些处理器只有一个.它是一堆特殊用途的寄存器(Intel称为模型专用寄存器,即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和Xeon 5500上的性能分析的文档.

您可能要查看英特尔的 性能计数器监视器 ,它基本上是一些抽象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: perf

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

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

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