Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
1093 Discussions

Real value of the CPU frequency when changed with IA32_CLOCK_MODULATION MSR

medinad
Beginner
838 Views
Hello,

I am working with MaRTE OS (a Hard RTOS with a Minimal RT POSIX.13 subset [marte webpage] ) and at a low level programing.

I use IA32_CLOCK_MODULATION MSR to change the CPU frecuency. It allows to me to modulate the dutycycle of the on-demand clock. The dutycycle field encoding is 3 bits. Then, I have a set of fixed dutycycle values.

There is a table whit the theoretical values in the specification vol 3A Chap 13 page 13-16 . And two ways to get the real working-frequency. A) get the time that a well-defined loop take to complete at different frequencies, and B) use IA32_MPERF MSR and IA32_APERF MSR (Chap 13, page 13-2) which division is the ratio of the processor frequency.

But I find significant differencies between both methods and the theoretical values (show in table below). I trust more in tsc than in aperf/mperf ratio. But I would like to use last method because it involve less time to know the ratio.

On the other hand, I do not sure that the ratio provided by APERF/MPERF division is really of the frequency. And I need to know the frequency as accuracy as possible due to real time purposes.

How should I get the working-frequency??? Are there other methods?
I am a little cofused.

Thank you.
Daniel M.


theoretical - APERF/MPERF - TSC
1.000 - 1.000 - 1.000
0.875 - 0.877 - 0.853
0.750 - 0.760 - 0.708
0.625 - 0.638 - 0.568
0.500 - 0.538 - 0.448
0.375 - 0.434 - 0.325
0.250 - 0.363 - 0.239
0.125 - 0.270 - 0.132
0 Kudos
1 Reply
EnioPineda
Beginner
838 Views
Quoting - medinad
Hello,

I am working with MaRTE OS (a Hard RTOS with a Minimal RT POSIX.13 subset [marte webpage] ) and at a low level programing.

I use IA32_CLOCK_MODULATION MSR to change the CPU frecuency. It allows to me to modulate the dutycycle of the on-demand clock. The dutycycle field encoding is 3 bits. Then, I have a set of fixed dutycycle values.

There is a table whit the theoretical values in the specification vol 3A Chap 13 page 13-16 . And two ways to get the real working-frequency. A) get the time that a well-defined loop take to complete at different frequencies, and B) use IA32_MPERF MSR and IA32_APERF MSR (Chap 13, page 13-2) which division is the ratio of the processor frequency.

But I find significant differencies between both methods and the theoretical values (show in table below). I trust more in tsc than in aperf/mperf ratio. But I would like to use last method because it involve less time to know the ratio.

On the other hand, I do not sure that the ratio provided by APERF/MPERF division is really of the frequency. And I need to know the frequency as accuracy as possible due to real time purposes.

How should I get the working-frequency??? Are there other methods?
I am a little cofused.

Thank you.
Daniel M.


theoretical - APERF/MPERF - TSC
1.000 - 1.000 - 1.000
0.875 - 0.877 - 0.853
0.750 - 0.760 - 0.708
0.625 - 0.638 - 0.568
0.500 - 0.538 - 0.448
0.375 - 0.434 - 0.325
0.250 - 0.363 - 0.239
0.125 - 0.270 - 0.132

I could be wrong, but I don't think the APERF/MPERF ratio is a frequency ratio. It's more like actual processor performance over the measurement interval. If the ratio is < 1 then the processor is operating at less than its rated performance. If the ratio is == 1 then the processor is operating at its rated performance. If the ratio is > 1 then the processor is operating at higher than its rated performance.

In your case, if you know the nominal frequency then you can calculate the actual frequency:
frequency = duty_cycle * nominal_frequency.
For example, if the nominal frequency is 1GHz and you've set IA32_CLOCK_MODULATION to achieve a .750 duty cycle then the actual frequency should be 750MHz.

Of course, as soon as the processor is idle (C1 or higher) the frequency goes to zero. Things like Intel Dynamic Acceleration and Turbo Boost (if enabled) can increase the frequency if conditions allow it. Things like Thermal Monitoring can reduce the frequency when needed.

Unless all power management mechanisms in the processor are turned off, it is almost impossible to know the actual frequency at any given point in time. That's why the APERF/MPERF ratio is useful - you can observe the actual performance over a period of time and adjust it up or down (via P-State or throttling) to meet the required performance target.

Enio.
0 Kudos
Reply