问题
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