命令mpirun -help会给出全部可用的选项, 适当地使用这些选项能更好地运行应用程序,
并改善系统运行状况。
mpirun的基本格式为:
mpirun [mpirun-options…] [options…]
其中 [mpirun-options…], 主要选项如下:
-np 要加载的进程个数。
-p4pg 按照pgfile文件中的要求加载用户进程。pgfile文件描述用户在那些结点上加载什么样的用户进程。该文件的格式为:
第一行: <0>
第二行: <1>
......
第n行: <1>
其中n为用户要加载进程的个数。结点名可以相同,也可以不同。且用户使用此选项后, -np选项无效。
最简单的运行一个MPI应用程序的例子是:
% mpirun -np 4 a.out,它将在并行机上加载4个用户执行程序 --a.out。
一般情况下最好用-p4pg选项,pgfile文件包含有关进程在哪些节点上运行的信息。如你已登录到节点node1,
并用4个节点执行你的并行程序 a. out, 执行文件的全路径是:/public/user1/example/a.out,
则pgfile内容如下:
node1 0 /public/user1/example/a.out
node2 1 /public/user1/example/a.out
node3 1 /public/user1/example/a.out
node4 1 /public/user1/example/a.out
这时的执行命令为:
% mpirun -p4pg pgfile a.out
你也可以在一个节点(如node1)上模拟多进程并行程序的执行, 这时pgfile的一个例子是:
node1 0 /public/user1/example/a.out
node1 1 /public/user1/example/a.out
node1 1 /public/user1/example/a.out
node1 1 /public/user1/example/a.out
2.程序的直接执行
用户也可以不用mpirun, 而直接运行目标程序(a.out),但此时需用pgfile,其命令格式如下:
% a.out -p4pg pgfile