用于基准测试的 CPU 频率应该有多稳定?

Sam*_*zer 5 linux cpu benchmarking microbenchmark

注意:问题末尾给出了详尽的系统详细信息。

我试图让我的开发机器具有非常稳定的 CPU 频率,以便我可以获得一些线性代数代码的精确基准 - 然而,它仍然显示出明显的频率波动。

我已将缩放调节器设置为performance模式:

echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Run Code Online (Sandbox Code Playgroud)

我还锁定了C0状态中的所有内容:

sudo cpupower idle-set -D 0
Run Code Online (Sandbox Code Playgroud)

然而,使用 时i7z,我仍然观察到 CPU 频率波动 >5%。我非常感谢有关我是否应该采取进一步步骤将 CPU 频率限制为固定值,或者是否无法获得更精确的频率限制的指导。

附录:

我的处理器是 Intel Core i7-9750H:

cat /proc/cpuinfo | grep 'model name' 
model name  : Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
...
Run Code Online (Sandbox Code Playgroud)

它有 12 个逻辑 CPU 和 6 个物理核心:

lscpu -a -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ    MINMHZ
0   0    0      0    0:0:0:0       yes    4500.0000 800.0000
1   0    0      1    1:1:1:0       yes    4500.0000 800.0000
2   0    0      2    2:2:2:0       yes    4500.0000 800.0000
3   0    0      3    3:3:3:0       yes    4500.0000 800.0000
4   0    0      4    4:4:4:0       yes    4500.0000 800.0000
5   0    0      5    5:5:5:0       yes    4500.0000 800.0000
6   0    0      0    0:0:0:0       yes    4500.0000 800.0000
7   0    0      1    1:1:1:0       yes    4500.0000 800.0000
8   0    0      2    2:2:2:0       yes    4500.0000 800.0000
9   0    0      3    3:3:3:0       yes    4500.0000 800.0000
10  0    0      4    4:4:4:0       yes    4500.0000 800.0000
11  0    0      5    5:5:5:0       yes    4500.0000 800.0000
Run Code Online (Sandbox Code Playgroud)

我运行的是 Ubuntu 18.04:

~ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Run Code Online (Sandbox Code Playgroud)

vir*_*tor 5

您的帖子中未提及的一种情况是英特尔的睿频加速。您可以通过写入1来禁用它/sys/devices/system/cpu/intel_pstate/no_turbo。BIOS中也有此设置,但我不确定效果是否100%等效。

  • 这很有效 - i7z 报告的频率现在稳定在 1MHz 以内。看起来禁用 Turbo 是推荐的基准测试技巧,很高兴知道:https://llvm.org/docs/Benchmarking.html (2认同)