超线程有效吗?
我在我的 PC 上运行一些相当处理器密集型的东西,并注意到我的 CPU 使用情况看起来很奇怪。我的电脑是四核 i7-870,据说有八个虚拟核心。
我在 .NET 4 中使用任务并行库,因此期望所有核心都能得到很好的利用,但我从进程监视器中获取如下信息:
核心 6 和 8 几乎没有受到影响,除了短暂的突发之外,核心 4 也没有受到影响。
这是我应该期待的吗?
I'm running some fairly processor-intensive stuff on my PC, and notice my CPU usage looks pretty odd. My PC is a quad-core i7-870, which supposedly has eight virtual cores.
I'm using the Task Parallel library in .NET 4, so expect all cores to be nicely utilised, but am getting information like this from Process Monitor:
Cores 6 and 8 are hardly getting touched, and apart from a brief burst, 4 isn't either.
Is this what I should expect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在大多数情况下,是的,我认为这看起来很合理。请记住,超线程实际上只是伪造两个核心。每个物理核心都有两个前端,因此它可以并行读取两个指令流。但它们仍然共享相同的执行单元。因此,当一个 HT 核心繁忙时,执行单元就会被占用,因此它的“双”核心将能够完成很少的工作。
这似乎就是您在前两个核心上看到的情况(特别是第二个核心,这一点非常明显)
除此之外,您几乎永远无法获得完美的 CPU 利用率。有时,核心必须停止等待内存。有时它会执行成本高昂的非流水线指令,从而有效地阻塞该物理核心上的执行单元可能数十甚至数百个周期。
有时,指令之间的依赖关系可能仅仅意味着您没有任何东西可供一个或多个内核执行。
除此之外,您会看到 8 个图表,而您只有 4 个核心,所以是的,超线程当然正在工作。 ;)
For the most part, yes, I think this looks reasonable. Keep in mind that hyperthreading really just fakes two cores. Each physical core is given two frontends, so it can read two streams of instructions in parallel. But they still share the same execution units. So when one HT core is busy, the execution units are taken, and so its "twin" core will be able to do very little work.
That seems to be what you're seeing on the first two cores (the second in particular makes it very obvious)
Apart from this, you'll almost never be able to get perfect CPU utilization. Sometimes, a core just has to stall waiting for memory. Sometimes it's executing a costly non-pipelined instruction, effectively blocking the execution units on that physical core for perhaps tens or even hundreds of cycles.
And sometimes, dependencies between instructions might just mean that you don't have anything for one or more cores to execute.
Apart from that, you see 8 graphs, and you only have 4 cores, so yes, of course hyperthreading is working. ;)
简而言之
List<>
也将在内部使用数组并优化对于结构元素类型)0.02 美元
In short
List<>
will also use an Array internally and optimize for struct element types)$0.02
这一切都取决于您的算法实现。 TPL 将根据算法中的数据依赖性使用适当数量的内核
It all depends on your algorithm implementation. TPL will use proper number of cores depending upon the data dependency in your algorithm