linux下使用intel mpi

1.下载安装,这个大家都会,就不说了
2.启动
运行你安装目录下的intel64/bin/mpivars.sh脚本(配置mpi environment)
打开host文件:cat ./hosts
并向host文件中写入所有mpi节点名称
下面是intel提供的一个例子:

$ cat ./hosts 
# this line is ignored 
clusternode1 
clusternode2 
clusternode3
clusternode4

启动一个无需密码的ssh
你可以使用intel提供的sshconnectivity.exp脚本自动完成此步骤(这个脚本位于

/opt/intel/parallel_studio_xe_<version>.<update>.<package>/bin

目录下
3.编译和链接
假如不确定你是否有intel c compile,可以输入命令行测试:

$ which icc

如果返回未找到此命令,在PATH中添加intel编译器的完整目录,你可以运行compilervars.[c] sh脚本来设置所需的环境变量
运行mpivars.[c]sh脚本来启动正确的MPI环境。

$ . <installdir>/bin64/mpivars.sh

编译程序,下面是一个示例:

$ mpiicc myprog.c -o myprog

也可以编译MPI/openmp程序,下面是一个示例:

$ mpiicc -qopenmp test.c -o testc

4.一些常见的编译和链接参数:
默认是动态链接,你也可以通过-static_mpi参数改为静态链接

$ mpiicc -static_mpi test.c -o testc

添加debug信息:

$ mpiicc -g test.c -o testc

测试mpi程序:
程序在

<installdir>/test

下,installdir默认为

/opt/intel/compilers_and_libraries_<version>.x.xxx/linux/mpi

5.正式运行:
运行mpi程序
用mpirun命令运行. 语法如下:

$ mpirun -n <# of processes> -ppn <# of processes per node> -f <hostfile> ./myprog

下面是一个示例:

$ mpirun -n 4 -ppn 2 -f hosts ./myprog

-n sets the number of MPI processes to launch; if the option is not specified, the process manager pulls the host list from a job scheduler, or uses the number of cores on the machine.
-ppn sets the number of processes to launch on each node; if the option is not specified, processes are assigned to the physical cores on the first node; if the number of cores is exceeded, the next node is used.
-f specifies the path to the host file listing the cluster nodes; alternatively, you can use the -hosts option to specify a comma-separated list of nodes; if hosts are not specified, the local node is used.
myprog is the name of your MPI program
你也可以用mpiexec.hydra命令,不过intel不推荐这样做。

运行mpi/openmp程序:
运行之前,先确认线程安全选项是开启的。(默认是开启的)
你也可以使用以下命令打开它

$ source mpivars.sh release_mt

使用I_MPI_PIN_DOMAIN来启用omp,你可以使用以下命令完成该过程:

$ export I_MPI_PIN_DOMAIN=omp

像运行一个正常的MPI应用来运行它,如下:

$ mpirun -n 4 -genv OMP_NUM_THREADS=4 -genv I_MPI_PIN_DOMAIN=omp ./myprog

MPMD运行模式(multiple programs, multiple data):
一个比较简单的方法就是新建一个设置文件然后使用-configfile选项来调用它,一个设置文件应该包含mpirun的相应参数,如下:

$ cat ./mpmd_config 
-n 1 -host node1 ./io <io_args> 
-n 4 -host node2 ./compute <compute_args_1> 
-n 4 -host node3 ./compute <compute_args_2> 
$ mpirun -configfile mpmd_config
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值