I would like to have any direct control of CPU core clocks. Is this possible on new MacBooks and macOS ?
I use Intel Power Gadget and Macs Fan Control tools for monitoring the CPU and fans speeds on MacBook Pro 2018 with i9.
Underclocking in Mathematica
While running some specific calculations in Mathematica it happens that the CPU gets underclocked from 2.9G to 2.3G in serial and even to 1.5G during parallel computations. This might be Mathematica related, but so far I see no reason for underclocking so heavily. At the start of computation the Turbo Boost is acting, the clock speed is higher and then after about a minute it abruptly reduces, simultaneously after the CPU temperature touches 100C. The average temperature is probably 80C, but with Turbo Boost adjusting the clock, at some point temperature touches 100C and the CPU gets underclocked. The temperature reduces to ~60C, but until the end of computation this process never gets higher CPU nor Turbo Boost. After some more time (5-10 minutes) it will underclock for the second time, although the temperature is stable.
However, if I run another application on the side, the Intel Power Gadget can read higher core frequency (it shows just the average or the maximum, not per core/thread). Also the total core power increases, but only while this second process is running, as if the Mathematica process is forbidden to use CPU on higher clock. It's like the OS does not allow higher CPU frequency for the "dangerous" thread, although the temperature can decrease eventually to <50C.
Mathematica task is long but does not change in nature, it multiplies big matrices over and over again just with different numbers.
All of this is followed with fans running on higher than default speeds, because I increase them with the Control tool. I am absolutely sure the system could support higher CPU frequency during this, but it does not go for it. My suspicion is on OS, since CPU does not even reach to throttle and there is a clear process preference. Increasing the process' priority did not make a change.
I am not sure about what is happening here, which is the reason I give longer description of the problem. Also because there might be a different solution to it other than changing the frequency manually, especially if this is impossible to do.
Best Answer
There are a few variables of unknown quality and quantity.
The i9 MacBook Pros were known to provide strange behaviour due to potentially high power consumption, temperature but not performance output, throttling. Not only the machines are new, so is the OS Mojave. All this can then be amplified by a bug in the software to run. Even Mathematica is not perfect. In this case it seems that the task is single-threaded and pretty taxing for the one core that has to handle this. Internal management of the Intel chip may then take over what is not in Apple's control, given the hardware conditions and designs chosen.
While there might be some reason to hope for further updates to the MacBook Pro's firmware, the macOS Mojave's handling of this or Mathematica to squish bugs or provide workarounds, that is unsatisfying as it does not provide you to try something on your own.
Some fixes are said to have been delivered for this as of 10.3.6 supplemental update and presumably also rolled into 10.14. As it is unclear whether these are installed or not, make sure you have the latest versions of all software. Although presently these fixes are known to improve things generally and considerably, they fail to deliver improvements for exactly Mathematica.
Even if mentioning disasterous thermal design will attract downvotes, this is just another case. Case, cooling system and an i9 just are not he perfect mix.
The generally known ways to tinker with these settings –– although in no way a guaranteed fix for the current problem at hand –– are the following options:
Background:
Unfortunately, Mathematica is the exception: