首页 > 解决方案 > 如何将英特尔 PCM 数据缩小到单个进程?

问题描述

我正在尝试使用英特尔性能计数器监视器 (PCM) 来了解我的代码中的 L3 缓存未命中和其他一些性能标准。

我不确定如何从我得到的数字中理解并希望得到一些见解。

理想情况下,我希望从以下代码中读取 0 个字节,但是我得到的数字接近 240KB 读取。如果我尝试运行其他进程,240KB 的数字会波动(不会单调上升/下降,它只是有有意义的波动(先上升然后下降))。

    volatile SystemCounterState before_sstate = getSystemCounterState();
    volatile SystemCounterState after_sstate = getSystemCounterState();

    cout << "Instructions per clock: "  << getIPC( before_sstate, after_sstate )
         << ", L3 Cache hit ratio: "    << getL3CacheHitRatio( before_sstate, after_sstate )
         << ", L3 Missed Cycles: "         << getCyclesLostDueL3CacheMisses(before_sstate, after_sstate )
         << ", Bytes read: "            << getBytesReadFromMC( before_sstate, after_sstate )
         << ", L3 Occupancy: "          << getL3CacheOccupancy( after_sstate ) << endl;

这是我得到的输出:

尝试使用 Linux 性能事件...

使用 Linux perf 成功编程核心 PMU

每时钟指令数:0.637448,L3 缓存命中率:0.820139,错过周期:0.075492,读取字节数:263488,L3 占用率:0

有谁知道为什么我读取了 240KB,尽管我实际上没有读取代码中的任何内容?它是否与其他进程共享计算资源并可能从其他进程中捕获统计信息?如果是这种情况,我如何确保捕获的信息与正在运行的代码/进程隔离?

标签: intelperformancecountercpu-cacheintel-pmu

解决方案


推荐阅读