News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

rdtsc turbo mode

Started by v0xX, November 21, 2023, 05:17:08 PM

Previous topic - Next topic

HSE

So far I understand, no CPU can read its own frequency.

What CPU does is to access the clock, but that depend on frequency, and the clock.

Then, at best, only it's posible to obtain an estimation between 2 access to the clock. And because that look random must be measured several times.

No?
Equations in Assembly: SmplMath

LiaoMi

#16
A simple library to sample the frequency on single CPU cores. The frequency is sampled by computing the ratio of actual performed cycles to the cycles that have passed in base frequency according to rdtsc.
https://github.com/intel/intel-cpu-frequency-library

New CPUs have "constant timestamp counter frequency" feature. This means that the timer which is queried by rdtsc instruction doesn't change its frequency when CPU cores are overclocked or downlocked by turboboost. It also means that you can not detect current CPU frequency by comparing rdtsc progress to HPET progress.

Monitoring TurboBoost frequency tool
https://github.com/shimada-k/turbofreq

Acquiring high-resolution time stamps
https://learn.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps

daydreamer

Running old games on my new laptop i use energy setting with disabled turbo ,because the old games are made to run as fast as possible

Wouldnt that be alternative measure with and without turbo and compare ?
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

InfiniteLoop

Quote from: v0xX on November 25, 2023, 08:54:48 PMon amd u can read the freq through  SystemHypervisorSharedPageInformation
That code doesn't make sense. Hmm let me adjust it.
No joy. Its zero.
//SystemHypervisorSharedPageInformation = 0xC5 = 197
NTSTATUS(*GetInfo)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);

HMODULE hh = LoadLibraryA("Ntdll.dll");
if (hh != INVALID_HANDLE_VALUE)
{
GetInfo = (NTSTATUS(*)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG))GetProcAddress(hh, "ZwQuerySystemInformation");
}
else
std::cout << "bad handle \r\n";
if (GetInfo == nullptr)
{
std::cout << "bad address\r\n";
}
else
{
unsigned long long* info;
unsigned int l = 0;
LARGE_INTEGER p;
NTSTATUS t;
t = GetInfo((SYSTEM_INFORMATION_CLASS)197, info, 0, (PULONG)&l);
if (t  > 0x7FFFFFFF)
std::cout << t << " error A\r\n";
else if (l > 0)
{
info = (unsigned long long*)_aligned_malloc(8 * l, 64);
for(int i = 0; i < l; i++)
info[i] = 0;
t = GetInfo((SYSTEM_INFORMATION_CLASS)197, info, l, nullptr);
if (t > 0x7FFFFFFF)
std::cout << t << " error B\r\n";
else
{
unsigned long long tsc = info[1];
std::cout << "TSC Frequ " << tsc << "\r\n";
}
_aligned_free(info);
}
}
CloseHandle(hh);

v0xX

after some research here little fix for it :) disable intelppm.sys disable performance boost mode enable speedstep/turbo in bios intelppm not use the turbo of speedstep / only speedshift use it then set Attributes to 2 on HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\be337238-0d82-4146-a960-4f3749d470c7 key rdtsc cycle correctly with  turbo without any issue  :skrewy: