启用超theading的系统上的CPU编号 [英] CPU Numbering on a hypertheading enabled system

查看:101
本文介绍了启用超theading的系统上的CPU编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出在启用了超线程的环境中,操作系统(Windows,Linux)如何将数字分配给逻辑cpus. ?

I am trying to find out how an OS (Windows, linux) assigns numbers to logical cpus in a Hyper threading enabled environment. ?

两个OS是否先为物理CPU顺序分配编号,然后开始为逻辑CPU编号,还是遵循其他规则?例如在具有超线程的2个物理cpu系统中,操作系统是否将数字0,2分配给第一个物理cpu,然后将1,3分配给第二个物理cpu ..?

Does both the OSs first serially assign numbers to the Physical CPUs and then start numbering the logical cpus or is there some other rule followed.. ? e.g. in 2 physical cpu system with hyper threading , does an OS assign number 0,2 to the first physical cpu and then 1,3 to second physical cpu .. ?

任何参考文献将不胜感激.

Any references would be really appreciated.

谢谢.

关于-杰伊.

回答Alan的问题:我需要知道这一点,因为,在我的工作中,我需要将各种线程绑定到特定的CPU以避免上下文切换,并且我想确保将某些Tasks(THreads)绑定到分开物理cpus.谢谢

Responding to Alan's question : I need to know this because, In my work I need to bind various threads to specific CPUs to avoid context switches and I want to make sure that certain Tasks( THreads ) are bound to separate physical cpus. Thanks

推荐答案

据我所知,这取决于CPU如何公开其核心.启用HT时,没有裸露的物理CPU,而是每个物理CPU两个逻辑CPU,因此,如果您在两个逻辑CPU上运行线程都没有区别.唯一重要的是每个物理CPU属于哪些逻辑CPU对.

From what I know, it depends on how the CPU exposes his cores. When HT is enabled, there are no exposed physical CPUs, but rather two logical CPUs per physical CPU, so there is no difference if you run a thread on either logical CPU. The only thing that does matter is what pairs of logical CPUs belong to each physical CPU.

对于单核处理器(例如带有HT的奔腾4),这非常简单,因为您只有一对-因此为(0,1).对于四核处理器(如Nehalem),逻辑核对为(0,4),(1,5),(2,6)和(3,7).每对具有所有前半部分,然后使所有后半部分与未来具有更多核的CPU保持比例的模式.

With single core processors (like the Pentium 4 with HT), it's pretty straight forward, since you only have one pair - so it's (0, 1). With quad core processors (like Nehalem), the logical cores pairs are (0,4), (1,5), (2,6) and (3,7). The pattern of having all the first halves of each pair then having all the second halves shuold scale with future CPUs that have even more cores.

真正的问题是,为什么您需要知道配对的安排?让操作系统的调度程序为正确的线程选择正确的核心-它做得相当不错.

The real question is why do you need to know the pair arrangement? Let the OS's scheduler pick the right cores for the right threads - it does a pretty decent job.

这篇关于启用超theading的系统上的CPU编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆