MPICH2安装使用简记

安装

1 到MPICH官方网站下载源代码包,解压缩

#tar -zxvf mpich2-1.0.8.tar.gz

2 进入mpich2解压目录

#cd mpich2-1.0.8

3 设置安装目录

#./configure --prefix=/usr/loca/mpich

4 编译

#make

5 安装

#make install

6 修改PATH环境变量

   PATH="$PATH:/usr/local/mpich/bin" 

7  测试环境变量设置

#which mpd

#which mpicc

#which mpiexec

#which mpirun

所有以上的命令都应该指向安装目录的bin子目录。此外,如果没有用NFS来共享安装目录,则需要将bin子目录拷贝到其他每台机器上。

8 修改/etc/mpd.conf文件,内容为secretword=myword

#vi /etc/mpd.conf

设置文件读取权限为只有自己能读写

#chmod 600 /etc/mpd.conf

非root用户在家目录创建内容相同的.mpd.conf

9 创建主机名称集合文件/root/mpd.hosts

#vi mpd.hosts

文件内容如下:

station1

station3

station6

station8

 

使用

MPICH2采用mpd服务来对进程进行管理,使用mpiexec运行mpi程序。

 

MPD

启动单机上的mpd服务

# mpd &

查看mpd服务

# mpdtrace  查看主机名

#mpdtrace –l  查看主机名和端口号

关闭mpd进程管理

#mpdallexit

 

启动集群上的mpd服务

# mpdboot –n process-num –f  mpd.hosts

启动 process-num个进程,mpd.hosts是前面创建的文件。

mpich2默认是使用ssh来登陆集群里的其他机器,也可以使用rsh来登陆集群里的其他机器来启动mpd服务

只要使用-rsh选项就可以指定用ssh或rsh

#mpdboot -rsh=rsh –n process-num –f  hostfile

或#mpdboot -rsh=ssh –n process-num –f  hostfile

关闭mpd服务

#mpdallexit

 

mpiexec

使用MPIEXEC来执行mpi任务

 

#mpiexec –np 3  ./cpi

或mpiexec –machinefile filename –np 4 ./cpi

 

在PBS任务管理系统中使用MPICH

只要将

sort -u $PBS_NODEFILE > mpd.hosts
mpdboot -f mpd.hosts -n $NNODES --rsh=/usr/bin/rsh
mpiexec -machinefile $PBS_NODEFILE -np $NNODES $RUNJOB -i $WORK_AREA/$PREFILE/$PREFILE.in -dim 2 -n 100000 -d 10000 > $PREFILE.log
mpdallexit
写入pbs的script中就可以了
实际上包含了一个完整使用集群的过程,只不过是提交给了任务管理系统PBS而已。

 

MPD in the PBS environment


PBS specifies the machines allocated to a particular job in the file $PBS NODEFILE.
But the format used by PBS is different from that of MPD. Specifically, PBS
lists each node on a single line; if a node (n0) has two processors, it is listed
twice. MPD on the other hand uses an identifier (ncpus) to describe how
many processors a node has. So, if n0 has two processors, it is listed as n0:2.
One way to convert the node file to the MPD format is as follows:
sort $PBS NODEFILE | uniq -C | awk ’{ printf(”%s:%s”, $2, $1); }’ >
mpd.nodes
Once the PBS node file is converted, MPD can be normally started
within the PBS job script using mpdboot and torn down using mpdallexit.

mpdboot -f mpd.hosts -n [NUM NODES REQUESTED]
mpiexec -n [NUM PROCESSES] ./my test program
mpdallexit

一些问题

1. 我们的集群上有两套网络,一个是百兆的一个是千兆的,mpich2是采用什么那个一来进行信息交换的?

posted @ 2010-06-01 21:04  Walter L  阅读(7001)  评论(0编辑  收藏  举报