在Mac上超线程 - 没有加快速度

时间:2013-07-03 17:01:38

标签: c++ macos openmp processor hyperthreading

我使用openMP在C ++中实现了一个Convex hull算法。

可以在此处找到代码:http://codepad.org/VVQdSdfM

Below are the results when tested in my Mac Book Pro:
      Processor Name:   Intel Core i5
      Processor Speed:  2.5 GHz
      Number of Processors: 1
      Total Number of Cores:    2
      L2 Cache (per Core):  256 KB
      L3 Cache: 3 MB
      Memory:   4 GB

处理器运行代码的时间:

With two Threads:
(here size represents the number of points in the input and time in Seconds)

Average Sequential Time Elapsed in seconds for size:10=8.29697e-06
Average Parallel Time Elapsed in seconds for size:10=5.0807e-05

Average Sequential Time Elapsed in seconds for size:100=5.18084e-05
Average Parallel Time Elapsed in seconds for size:100=8.13007e-05

Average Sequential Time Elapsed in seconds for size:1000=0.000471377
Average Parallel Time Elapsed in seconds for size:1000=0.000283003

Average Sequential Time Elapsed in seconds for size:10000=0.00483506
Average Parallel Time Elapsed in seconds for size:10000=0.0032198

Average Sequential Time Elapsed in seconds for size:100000=0.0471328
Average Parallel Time Elapsed in seconds for size:100000=0.0333489

Average Sequential Time Elapsed in seconds for size:1000000=0.460131
Average Parallel Time Elapsed in seconds for size:1000000=0.267305


With four threads:

Average Sequential Time Elapsed in seconds for size:10=1.00136e-05
Average Parallel Time Elapsed in seconds for size:10=0.000106597

Average Sequential Time Elapsed in seconds for size:100=5.91993e-05
Average Parallel Time Elapsed in seconds for size:100=0.000114727

Average Sequential Time Elapsed in seconds for size:1000=0.000503755
Average Parallel Time Elapsed in seconds for size:1000=0.000302839

Average Sequential Time Elapsed in seconds for size:10000=0.00478158
Average Parallel Time Elapsed in seconds for size:10000=0.00235724

Average Sequential Time Elapsed in seconds for size:100000=0.0465738
Average Parallel Time Elapsed in seconds for size:100000=0.0223478

Average Sequential Time Elapsed in seconds for size:1000000=0.466074
Average Parallel Time Elapsed in seconds for size:1000000=0.221905

我在我的活动监视器中找到了四个用于CPU的插槽,我开始知道这个版本的intel处理器支持超线程。

如果是这种情况,当使用4个线程时,我不应该加速4吗?

请提供任何可以帮助我使用英特尔处理器中的超线程功能的指针。

谢谢, 维杰

1 个答案:

答案 0 :(得分:4)

在HPC(高性能计算)环境中使用超线程时,您不应期望在性能方面有太大改进。事实上,你最好在BIOS级别切换超线程。超线程给出了额外内核的印象,可以在许多进程在同一CPU上运行但不为CPU密集型MPI应用程序增加价值的情况下提高性能。