【问题标题】:mpirun --cpu-set vs. --rankfile (Open MPI) 1.4.5mpirun --cpu-set 与 --rankfile (Open MPI) 1.4.5
【发布时间】:2013-06-01 18:02:09
【问题描述】:

我想将我的 MPI 进程准确地固定到(物理)内核列表中。我参考了 mpirun --help 输出的以下几点:

   -cpu-set|--cpu-set <arg0>  
                         Comma-separated list of ranges specifying logical
                         cpus allocated to this job [default: none]

...

   -rf|--rankfile <arg0>  
                         Provide a rankfile file

我的处理器的拓扑如下:

-------------------------------------------------------------
CPU type:       Intel Core Bloomfield processor 
*************************************************************
Hardware Thread Topology
*************************************************************
Sockets:        1 
Cores per socket:       4 
Threads per core:       2 
-------------------------------------------------------------
HWThread        Thread          Core            Socket
0               0               0               0
1               0               1               0
2               0               2               0
3               0               3               0
4               1               0               0
5               1               1               0
6               1               2               0
7               1               3               0
-------------------------------------------------------------
Socket 0: ( 0 4 1 5 2 6 3 7 )
-------------------------------------------------------------

现在,如果我使用 mpirun -np 2 --cpu-set 0,1 --report-bindings ./solver 启动我的程序,程序会正常启动,但不考虑 - -cpu-set 我提供的参数。另一方面,使用 mpirun -np 2 --rankfile rankfile --report-bindings ./solver 启动我的程序会给我以下输出:

[neptun:14781] [[16333,0],0] odls:default:fork binding child [[16333,1],0] to slot_list 0
[neptun:14781] [[16333,0],0] odls:default:fork binding child [[16333,1],1] to slot_list 1

确实检查 top 告诉我,mpirun 实际上使用了指定的内核。但是我应该如何解释这个输出呢?除了主机 (neptun) 和指定的插槽 (0,1) 我没有任何线索。与我尝试过的其他命令相同:

$mpirun --np 2 --bind-to-core --report-bindings ./solver
[neptun:15166] [[15694,0],0] odls:default:fork binding child [[15694,1],0] to cpus 0001
[neptun:15166] [[15694,0],0] odls:default:fork binding child [[15694,1],1] to cpus 0002

$mpirun --np 2 --bind-to-socket --report-bindings ./solver
[neptun:15188] [[15652,0],0] odls:default:fork binding child [[15652,1],0] to socket 0 cpus 000f
[neptun:15188] [[15652,0],0] odls:default:fork binding child [[15652,1],1] to socket 0 cpus 000f

--bind-to-core top 命令再次显示使用了核心 0 和 1,但为什么输出 cpus 0001 0002--bind-to-socket 导致更多混乱:2x 000f?

我用最后一段来总结我的实验中提出的问题:
- 为什么我的 --cpu-set 命令不起作用?
- 我应该如何解释 --report-bindings 输出的输出?

亲切的问候

【问题讨论】:

    标签: mpi openmpi pinning


    【解决方案1】:

    在这两种情况下,输出都与您告诉 Open MPI 所做的完全匹配。 cpus ... 中的十六进制数字显示进程允许的 CPU(关联掩码)。这是一个位域,每个位代表一个逻辑 CPU。

    使用--bind-to-core,每个 MPI 进程都绑定到自己的 CPU 内核。等级 0 ([...,0]) 的关联掩码设置为 0001,这意味着逻辑 CPU 0。等级 1 ([...,1]) 的关联掩码设置为 0002,这意味着逻辑 CPU 1。逻辑 CPU 编号可能匹配带有拓扑信息的输出中的 HWThread 标识符。

    使用--bind-to-socket,每个 MPI 进程都绑定到套接字的所有核心。在您的特定情况下,亲和力掩码设置为000f,或二进制的0000000000001111,它对应于套接字中的所有四个核心。每个内核只分配一个超线程。

    您可以进一步指导 Open MPI 如何选择多套接字节点上的套接字。使用--bysocket,套接字以循环方式选择,即第一个列放在第一个套接字上,下一个列放在下一个套接字上,依此类推,直到每个套接字有一个进程,然后是下一个列再次放在第一个插座上,依此类推。使用--bycore,每个套接字接收的连续排名与该套接字中的内核数一样多。

    我建议您阅读 Open MPI 1.4.x 的 mpirun 手册,尤其是 Process Binding 部分。那里有一些示例说明不同的绑定选项如何相互交互。手册中没有提到--cpu-set 选项,尽管 Jeff Squyres 在processor affinity features in Open MPI 上写了一个很好的页面(它是关于 v1.5,但如果不是全部,它也适用于 v1.4)。

    【讨论】:

    • 这样就解决了,谢谢!不错的链接,我已经在这两个页面上花费了很多时间,但是我找不到关于不起作用的 cpu-set 选项的解释...
    • @Zboson,出于某种原因,我提供了一个指向 Open MPI 的德国镜像的链接,该镜像已消失。固定。
    猜你喜欢
    • 2013-02-11
    • 2017-03-14
    • 2012-04-20
    • 2014-10-06
    • 2013-04-03
    • 2015-12-18
    • 1970-01-01
    • 2015-10-19
    • 1970-01-01
    相关资源
    最近更新 更多