c - 为什么英特尔 SpeedStep 会影响执行周期数?

标签 c visual-studio intel

我目前正在测量一段要执行的 C 代码的循环计数。代码每 10 毫秒在 Windows API 的 _beginthreadex() 生成的额外线程中执行一次。周期测量是使用 QueryThreadCycleTimes() 进行的,以避免计算中断或其他东西的滴答声。

当我在我的机器上单独执行这段代码时,循环计数在 550 000 和 1 800 000 之间变化,每次调用几次 (5-10) 之后。

经过一些研究后,我发现在关闭 Intel SpeedStep 的情况下,循环计数的中位数为 580 000,偏差约为 10 000 个滴答。可以接受! 所以我现在的问题是,SpeedStep 如何影响执行所需的周期数。正如我所想,它只是通过降低功耗来降低处理器的频率,这应该不会影响循环计数,但是达到这个循环计数所需的时间?也许有人知道是否对其他重要的硬件部件或 CPU Cache 有影响?

提前致谢。问候 萨沙

系统属性:

英特尔至强 E5 - 1620 处理器

Visual Studio 2013

最佳答案

QueryThreadCycleTime 函数 manual page状态:

This function uses timer services provided by the CPU, which can vary in implementation. For example, some CPUs will vary the frequency of the timer when changing the frequency at which the CPU runs and others will leave it at a fixed rate. The behavior of each CPU is described in the documentation provided by the CPU vendor.

我试图找到有关英特尔至强处理器如何工作的信息,但我的搜索业力与我无关。

关于c - 为什么英特尔 SpeedStep 会影响执行周期数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36983523/

相关文章:

c# - 调试在启动时崩溃的 C# 可执行文件

assembly - 使用监控/等待指令

intel - 了解 Intel Intrinsics Guide 中的代码示例

在外部服务器上编译代码(我没有根访问权限)

c - 接受输入数组并输出指向数组中所有偶数的指针的函数

c++ - 在 Mac 上的 Visual Studio Community 2017 中使用 C++?

visual-studio - 消除Roslyn代码分析器的问题

assembly - 64位汇编介绍

c++ - 迁移到 64 位时,内存使用量可能会增长多少?

c - C 函数中的奇怪行为,字符串未保留