5

Note: exhaustive system details are given at the end of the question.

I am trying to get my development machine to have a very stable CPU frequency so that I can get precise benchmarks of some linear algebra codes - however, it still displays significant frequency fluctuations.

I have set scaling governor to performance mode:

echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

I have also locked everything in the C0 state:

sudo cpupower idle-set -D 0

However, using i7z, I still observe CPU frequency fluctuations >5%. I would very much appreciate guidance regarding whether there are further steps I should take to constrain the CPU frequency to a fixed value, or whether it is not possible to obtain a more precise frequency constraint.

Appendix:

My processor is an Intel Core i7-9750H:

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

It has 12 logical CPUs and 6 physical cores:

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

I am running 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
Sam Manzer
  • 1,220
  • 10
  • 23
  • When you say frequency fluctations, do you mean going down from max frequency in this case? Have you checked that this is not a result of thermal throttling for safety? – viraptor Aug 25 '19 at 23:16
  • Step back a bit. What precisely are you trying to time and why. Are your assumptions correct? – hookenz Aug 25 '19 at 23:30
  • 1
    @Matt first, I'm trying to reproduce some of Agner Fog's instruction latencies using bits of assembler code, then going to use this data to tune some linear algebra code – Sam Manzer Aug 26 '19 at 00:01

1 Answers1

5

One case not mentioned in your post is Intel's turbo boost. You can disable it by writing 1 to /sys/devices/system/cpu/intel_pstate/no_turbo. This setting is also available in BIOS, but I'm not sure if the effects are 100% equivalent.

viraptor
  • 33,322
  • 10
  • 107
  • 191
  • 2
    this worked - the frequency reported by i7z is now stable to within 1MHz. It looks like disabling turbo is a recommended benchmarking tip, good to know: https://llvm.org/docs/Benchmarking.html – Sam Manzer Aug 26 '19 at 00:03