Openmp线程关联性:在程序中设置2个线程,正在运行多少个内核? [英] Openmp thread affinity: Set 2 threads in the program, how many cores are running?

查看:137
本文介绍了Openmp线程关联性:在程序中设置2个线程,正在运行多少个内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Openmp程序,在两核计算机上运行它.

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

当我将线程号从1更改为2,并将线程号从2更改为4时,我无法获得2倍的速度.

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

2个线程到4个线程,即超线程.由于资源限制,超线程通常无法达到2倍的速度.

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

但是,从1个线程到2个线程,仍然无法达到2倍的速度,对此我感到困惑.我搜索并找到了CPU相似性概念,但是我不知道Openmp是如何工作的.

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.

当我使用2个线程时,Openmp静态调度会将2个线程安排为1个内核还是2个内核?

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

omp_get_thread_num()函数不能告诉我答案,因为返回值为0或1,但我不知道它们是在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.

感谢您的帮助.

推荐答案

可以与 proc_bind 使用线程相似性:

Can use thread affinity with proc_bind:

关闭

传播

大师

我希望这会帮助您选择合适的选项来工作.

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

这篇关于Openmp线程关联性:在程序中设置2个线程,正在运行多少个内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆