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

限于喜欢 提交于 2019-12-25 07:33:07

问题


I wrote an Openmp Program, running it on a two core machine.

When I changed the thread number from 1 to 2 and from 2 to 4, I couldn't get the 2x speed up.

2 threads to 4 threads, that's the hyperthreads. Hyperthreads generally can't get 2x speed up because of resources limitation.

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.

When I use 2 threads, does Openmp static schedule arrange 2 threads into 1 core or 2 core?

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.

Thanks for help.


回答1:


Can use thread affinity with proc_bind:

Close

Spread

Master

I hope this will help you choose the appropriate option to work.



来源:https://stackoverflow.com/questions/41486134/openmp-thread-affinity-set-2-threads-in-the-program-how-many-cores-are-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!