标签:
参考文档:Linux下MPI并行编程环境搭建配置
MPI是一种并行计算架构,MPICH是MPI的一种实现,本集群使用虚拟机安装,操作系统是ubuntu14.04,使用三台机器,用户名都是ubuntu,机器名分别是ub0, ub1, ub2
$ tar -xzvf soft/mpich-3.0.4.tar.gz $ cd mpich-3.0.4/ $ ./configure --prefix=/usr/local/mpich $ make && sudo make install
安装后加入环境变量到/etc/profile文件,并执行 source /etc/profile,追加内容到/etc/profile
PATH=$PATH:/usr/local/mpich/bin MANPATH=$MANPATH:/usr/local/mpich/man export PATH MANPATH
cp -r examples/ /usr/local/mpich
执行
mpirun -np 10 ./examples/cpi
输出结果如下:
Process 0 of 10 is on ub0 Process 9 of 10 is on ub0 Process 1 of 10 is on ub0 Process 4 of 10 is on ub0 Process 5 of 10 is on ub0 Process 7 of 10 is on ub0 Process 2 of 10 is on ub0 Process 3 of 10 is on ub0 Process 6 of 10 is on ub0 Process 8 of 10 is on ub0 pi is approximately 3.1415926544231256, Error is 0.0000000008333325 wall clock time = 0.020644
$ ssh-keygen -t rsa
一路enter就行了
$ cat id_rsa.pub >> authorized_keys
scp -r mpich ub1:/usr/local/ scp -r mpich ub2:/usr/local/
192.168.0.2 ub0 192.168.0.3 ub1 192.168.0.4 ub2
注意,三台机器的/etc/hosts都要追加
ub0:2 ub1:2 ub2:2
$ mpiexec -n 10 -f servers ./cpi
你就可以看到下面的结果
Process 0 of 10 is on ub0 Process 1 of 10 is on ub1 Process 4 of 10 is on ub0 Process 5 of 10 is on ub2 Process 6 of 10 is on ub1 Process 7 of 10 is on ub2 Process 8 of 10 is on ub0 Process 9 of 10 is on ub1 Process 2 of 10 is on ub2 Process 3 of 10 is on ub1 pi is approximately 3.1415926544231256, Error is 0.0000000008333325
wall clock time = 0.018768
标签:
原文地址:http://www.cnblogs.com/goingmyway/p/5296002.html