CPU核心与线程
我的 MacBookPro 运行 BootCamp,配备 Intel i7-640M 处理器,有 2 个内核。与所有其他 i7 芯片一样,每个核心都是超线程的,因此最多可以有 4 个线程。使用 Visual Studio 2010 c/c++ 来确定这些:
coresAvailable = omp_get_num_procs ( );
threadsAvailable = omp_get_max_threads ( ) ;
正如预期的那样,“threadsAvailable”返回的值为 4。但“coresAvailable”也被报告为 4。
我错过了什么?
My MacBookPro, running BootCamp, has an Intel i7-640M processor, which has 2 cores. Like all the other i7 chips, each core is hyperthreaded, so you can have up to 4 threads. Using Visual Studio 2010 c/c++ to determine these:
coresAvailable = omp_get_num_procs ( );
threadsAvailable = omp_get_max_threads ( ) ;
The "threadsAvailable" comes back with a value of 4, as expected. But "coresAvailable" also is reported as 4.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
omp_get_num_procs
返回操作系统报告的 CPU 数量,由于超线程核心将自身报告为 2 个 CPU,因此双核超线程芯片将自身报告为 4 个处理器。omp_get_max_threads
返回将在并行代码区域中使用的最多线程,因此它使用的最多线程将是可用 CPU 的数量是有道理的。omp_get_num_procs
returns the number of CPUs the OS reports, and since a hyperthreaded core reports itself as 2 CPUs, a dual-core hyperthreaded chip will report itself as 4 processors.omp_get_max_threads
returns the most threads that will be used in a parallel region of code, so it makes sense that the most threads it will use will be the number of CPUs available.