gpt4 book ai didi

linux - 怎样才能知道CPU内置的硬件性能计数器的确切数量呢?

转载 作者:太空狗 更新时间:2023-10-29 12:41:18 25 4
gpt4 key购买 nike

在我多次阅读硬件性能计数器之后,我可以声称所有英特尔处理器都支持硬件性能计数器。因此,为了访问这些额外的硬件寄存器,即硬件性能计数器,我使用了经常用于访问和配置这些计数器的 PAPI 基础结构。

当我使用 papi_avail 实用程序报告有关数字硬件计数器的信息时,看到了意外的值,即相对于图,数字硬件计数器:0。可能是吗?

关于我的处理器型号(英特尔酷睿 i7),我认为这是不正确的值。

非常感谢您提供的任何帮助。

最佳答案

如果您需要知道您的 Intel 支持多少个性能计数器CPU,你可以使用cpuid命令(参见man 1 cpuid)。

它非常冗长,因为它会触发 x86 cpuid 指令,该指令会返回有关处理器的许多信息。其中,有详细关于性能监控单元 (PMU)。默认情况下,命令启动所有 CPU 内核上的 cpuid 指令。但如果核心是相同的您可以将显示限制为一个核心。例如,这里是我们如何列出第一个 CPU 的信息:

$ cpuid -1
[...]
Architecture Performance Monitoring Features (0xa/eax):
version ID = 0x3 (3)
number of counters per logical processor = 0x4 (4)
bit width of counter = 0x30 (48)
length of EBX bit vector = 0x7 (7)
Architecture Performance Monitoring Features (0xa/ebx):
core cycle event not available = false
instruction retired event not available = false
reference cycles event not available = false
last-level cache ref event not available = false
last-level cache miss event not avail = false
branch inst retired event not available = false
branch mispred retired event not avail = false
Architecture Performance Monitoring Features (0xa/edx):
number of fixed counters = 0x3 (3)
bit width of fixed counters = 0x30 (48)
anythread deprecation = false
[...]

在上面的显示中,我们可以看到PMU版本是3:

 version ID = 0x3 (3)

每个内核有 4 个可编程计数器:

number of counters per logical processor = 0x4 (4)

每个核心有 3 个固定计数器:

number of fixed counters = 0x3 (3)

计数器都是 48 位长:

bit width of counter        = 0x30 (48)
bit width of fixed counters = 0x30 (48)

PMU 的功能是特定于体系结构的。如果您需要有关英特尔 PC/主板的更多详细信息,则上一个命令显示的第一行提供了 CPU/架构标识。例如:

   [...]
vendor_id = "GenuineIntel"
version information (1/eax):
processor type = primary processor (0)
family = 0x6 (6)
model = 0xa (10)
stepping id = 0x9 (9)
extended family = 0x0 (0)
extended model = 0x3 (3)
(family synth) = 0x6 (6)
(model synth) = 0x3a (58)
(simple synth) = Intel Core (unknown type) (Ivy Bridge E1/N0/L1/P0) {Sandy Bridge}, 22nm
[...]

利用这些信息,您可以引用 Intel documentation .

关于linux - 怎样才能知道CPU内置的硬件性能计数器的确切数量呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43077715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com