安装
##
wget http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
tar zxf mpich-3.2.tar.gz
cd mpich-3.2
./configure -prefix=/home/mpi/mpich-install/ --disable-fortran 2>&1 | tee c.txt
make 2>&1 | tee m.txt
make install PACKAGE=mpich-3.2 2>&1 | tee mi.txt
## 添加 mpi PATH:
[mpi@shark1 ~]$ tail -3 ~/.bashrc
## add mpi path
PATH=/home/mpi/mpich-install/bin:$PATH
## 检查安装是否成功
. ~/.bashrc
which mpicc
~/mpich-install/bin/mpicc
which mpiexec
~/mpich-install/bin/mpiexec
测试mpich自带example
[mpi@shark1 mpich-3.2]$ echo localhost > machinefile
[mpi@shark1 mpich-3.2]$ mpiexec -n 1 -f machinefile ./examples/cpi
Process 0 of 1 is on shark1
pi is approximately 3.1415926544231341, Error is 0.0000000008333410
wall clock time = 0.000621
[mpi@shark1 mpich-3.2]$ mpiexec -n 5 -f machinefile ./examples/cpi
Process 0 of 5 is on shark1
Process 3 of 5 is on shark1
Process 1 of 5 is on shark1
Process 2 of 5 is on shark1
Process 4 of 5 is on shark1
pi is approximately 3.1415926544231230, Error is 0.0000000008333298
wall clock time = 0.023467
## 可以在 machinefile 中添加几台装有mpi的机器并配好ssh,重新运行上面的 cpi, 会显示进程所在节点
测试MPI程序
先安装缺少的库
缺少log4cpp库
[root@shark1 opt]# yum install log4cpp.x86_64
[root@shark1 opt]# yum install log4cpp-devel.x86_64
解决 mpi_model.cpp:38: error: ‘memset’ was not declared in this scope
// 添加头文件
include <cstring>
/usr/bin/ld: cannot find -lcrypto 错误.
[root@shark1 opt]# ll /usr/lib64/libss*
lrwxrwxrwx. 1 root root 16 Jun 9 2014 /usr/lib64/libssh2.so.1 -> libssh2.so.1.0.1
-rwxr-xr-x. 1 root root 164504 Feb 22 2013 /usr/lib64/libssh2.so.1.0.1
-rwxr-xr-x. 1 root root 224328 Feb 23 2013 /usr/lib64/libssl3.so
lrwxrwxrwx. 1 root root 16 Jun 11 2014 /usr/lib64/libssl.so.10 -> libssl.so.1.0.1e
-rwxr-xr-x. 1 root root 444040 Jun 5 2014 /usr/lib64/libssl.so.1.0.1e
lrwxrwxrwx. 1 root root 21 Jun 9 2014 /usr/lib64/libsss_idmap.so.0 -> libsss_idmap.so.0.0.1
-rwxr-xr-x. 1 root root 17216 Feb 23 2013 /usr/lib64/libsss_idmap.so.0.0.1
[root@shark1 opt]#
[root@shark1 opt]# ll /usr/lib64/libcryp*
lrwxrwxrwx. 1 root root 19 Jun 11 2014 /usr/lib64/libcrypto.so.10 -> libcrypto.so.1.0.1e
-rwxr-xr-x. 1 root root 1953536 Jun 5 2014 /usr/lib64/libcrypto.so.1.0.1e
lrwxrwxrwx. 1 root root 25 Jun 10 2014 /usr/lib64/libcrypt.so -> ../../lib64/libcrypt.so.1
lrwxrwxrwx. 1 root root 19 Jun 9 2014 /usr/lib64/libcryptui.so.0 -> libcryptui.so.0.0.0
-rwxr-xr-x. 1 root root 78312 Aug 23 2010 /usr/lib64/libcryptui.so.0.0.0
[root@shark1 opt]# ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so
[root@shark1 opt]# ln -s /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so
/usr/bin/ld: cannot find -lz 错误
[root@shark1 opt]# yum install zlib.x86_64 zlib-devel.x86_64
测试程序
// TODO: