简体   繁体   English

Openmp线程关联性:在程序中设置2个线程,正在运行多少个内核?

[英]Openmp thread affinity: Set 2 threads in the program, how many cores are running?

I wrote an Openmp Program, running it on a two core machine. 我编写了一个Openmp程序,在两核计算机上运行它。

When I changed the thread number from 1 to 2 and from 2 to 4, I couldn't get the 2x speed up. 当我将线程号从1更改为2并将线程号从2更改为4时,我无法获得2倍的速度。

2 threads to 4 threads, that's the hyperthreads. 2个线程到4个线程,即超线程。 Hyperthreads generally can't get 2x speed up because of resources limitation. 由于资源限制,超线程通常无法达到2倍的速度。

However, 1 threads to 2 threads, still can't get the 2x speed up, I feel confused about this.I searched and found the CPU affinity concept, but I can't figure out how Openmp works. 但是,从1线程到2线程,仍然无法达到2倍的速度,对此我感到困惑。我搜索并找到了CPU亲和力概念,但我不知道Openmp是如何工作的。

When I use 2 threads, does Openmp static schedule arrange 2 threads into 1 core or 2 core? 当我使用2个线程时,Openmp静态调度会将2个线程安排为1个内核还是2个内核?

omp_get_thread_num() function can't tell me the answer since the return value is 0 or 1, but I don't know they are running on 1 core or 2. omp_get_thread_num()函数无法告诉我答案,因为返回值为0或1,但我不知道它们是在1核还是2核上运行。

Thanks for help. 感谢帮助。

Can use thread affinity with proc_bind : 可以对proc_bind使用线程关联:

Close 在此处输入图片说明

Spread 传播 在此处输入图片说明

Master 在此处输入图片说明

I hope this will help you choose the appropriate option to work. 希望这可以帮助您选择合适的选项来工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM