gpt4 book ai didi

profiling - 如何检测 RDTSC 是否返回恒定速率计数器值?

转载 作者:行者123 更新时间:2023-12-03 07:58:15 25 4
gpt4 key购买 nike

似乎来自 AMD 和 Intel 的大多数较新的 CPU 都将 rdtsc 实现为恒定速率计数器,从而避免了由于 TurboBoost 或省电设置等原因导致的频率变化引起的问题。

由于 rdtsc 比 QueryPerformanceCounter 更适合性能测量,因为它的开销要低得多,我想尽可能使用它。

如何可靠地检测 rdtsc 是否为恒定速率计数器?

最佳答案

您可以使用 CPUID告诉你。来自 the docs在 CPUID Fn8000_0007_EDX 位 8 上:

TscInvariant: TSC invariant. The TSC rate is ensured to be invariant across all P-States, C-States, and stop grant transitions (such as STPCLK Throttling); therefore the TSC is suitable for use as a source of time. 0 = No such guarantee is made and software should avoid attempting to use the TSC as a source of time.

关于profiling - 如何检测 RDTSC 是否返回恒定速率计数器值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4509727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com