【发布时间】:2021-04-17 20:16:24
【问题描述】:
为了衡量程序中缓存未命中的影响,我想将缓存未命中引起的延迟延迟到用于实际计算的周期。
我使用perf stat 来测量程序中的周期、L1 负载、L1 未命中、LLC 负载和 LLC 未命中。这是一个示例输出:
467 769,70 msec task-clock # 1,000 CPUs utilized
1 234 063 672 432 cycles # 2,638 GHz (62,50%)
572 761 379 098 instructions # 0,46 insn per cycle (75,00%)
129 143 035 219 branches # 276,083 M/sec (75,00%)
6 457 141 079 branch-misses # 5,00% of all branches (75,00%)
195 360 583 052 L1-dcache-loads # 417,643 M/sec (75,00%)
33 224 066 301 L1-dcache-load-misses # 17,01% of all L1-dcache hits (75,00%)
20 620 655 322 LLC-loads # 44,083 M/sec (50,00%)
6 030 530 728 LLC-load-misses # 29,25% of all LL-cache hits (50,00%)
那么我的问题是: 如何将缓存未命中数转换为“丢失”时钟周期数? 或者,获取数据所花费的时间比例是多少?
我认为构造函数应该知道这个因素。我的处理器是 Intel Core i7-10810U,我无法在 specifications 和 list 的基准 CPU 中找到此信息。
related problem 描述了如何测量缓存未命中中丢失的周期数,但有没有办法将其作为硬件信息获取?理想情况下,输出应该是这样的:
L1-hit: 3 cycles
L2-hit: 10 cycles
LLC-hit: 30 cycles
RAM: 300 cycles
【问题讨论】:
标签: performance cpu-architecture latency cpu-cache perf