MPICH2的安装过程.docx
《MPICH2的安装过程.docx》由会员分享,可在线阅读,更多相关《MPICH2的安装过程.docx(20页珍藏版)》请在冰豆网上搜索。
MPICH2的安装过程
MPICH2的安装过程
经测试MPICH2的性能非常优越:
具有方便的管理操作实现对多核的支持(推荐)
From:
MPICH2软件包的安装
MPICH2是与MPI-2相对应的MPICH实现版本,包含了MPI-2相对于MPI-1扩充后的一些功能,比如动态任务管理,并行I/O等。
当前最新版本是MPICH2-1.0.2.
(1) 下载MPICH2源程序包mpich2-1.0.2p1.tar.gz(http:
//www-unix.mcs.anl.gov/mpi/mpich2/)。
(2) 解压源程序包到当前目录下:
tarzxfmpich2-1.0.2p1.tar.gz,此时会得到一个名为mpich2-1.0的子文件夹。
(3) 创建一个安装目录(比如/home/transim/mpich2,默认为/usr/local/bin),为了以后使用方便,可以将此安装目录共享到其他所有将要运行mpich2的节点机上;否则就需要分别在其他机器上安装mpich2。
如果不创建安装目录,则在下面的configure步骤中会自动创建安装目录。
(4) 选择一个编译目录,最好将编译目录与源代码目录分离开,以便能保持一个干净的源代码用来在其他机器上重新安装。
比如将源代码拷贝到/tmp/mpich2下。
(5) 配置MPICH2,指定安装目录,并在编译目录下运行configure脚本。
如:
cd/tmp/mpich2
./configure–prefix=/home/transim/mpich22>&1|teeconfigure.log
(6)编译链接MPICH2:
make2>1&|teemake.log
(1)安装MPICH2:
makeinstall2>1&|teeinstall.log
(2)将安装目录中子目录bin加入到环境变量PATH中:
setenvPATH/home/transim/mpich2/bin:
$PATH (csh或tcsh)
exportPATH=/home/transim/mpich2/bin:
$PATH (bash或sh)
用以下命令检查安装是否成功:
whichmpd
whichmpicc
whichmpiexec
whichmpirun
所有以上的命令都应该指向安装目录的bin子目录。
此外,如果没有用NFS来共享安装目录,则需要将bin子目录拷贝到其他每台机器上。
(9)与MPICH不同的是,MPICH2使用一个外部进程管理器来启动MPI任务,默认管理器为MPD。
为了安全考虑,MPD需要搜索用户主目录下的文件.mpd.conf,文件中包含:
secretword=,其中secretword应该是一个只有用户知道的字符串(最好不要与用户密码相同),将此文件权限设置为只有所有者可读及可写。
(10)用以下命令检查测试MPICH2在本机是否已正确安装并可以启动:
Mpd& (启动mpd)
Mpdtrace (输出应该是本机机器名)
Mpdallexit (退出mpd)
(11) 在mpd下运行非mpi程序测试:
mpd&
mpiexec–n1/bin/hostname (输出本机机器名)
mpdallexit
(12)配置所有机器,使用机器间采用rsh或ssh互相访问时不需要输入密码。
配置完后可用以下命令进行测试:
sshhostnamedate 或 rshhostnamedate
(13)使用mpd.hosts文件来启动文件所列机器上的mpd:
mpdboot–n-fmpd.hosts
在以上命令行中所要启动的机器数量必须小于等于mpd.hosts文件中所列的机器数,即使同一台机器名在文件中出现多次,默认情况下在每台机器上只启动一个mpd。
在各台机器启动mpd后,运行mpdtrace,应该输出每台机器的机器名称。
若不能启动所有机器上的mpd,可采用手动方法来启动,方法如下:
在本地机器上运行:
mpd& (启动本地mpd守护进程)
mpdtrace–l (输出本地mpd守护进程的主机名及端口号)
然后登录到其他机器,运行:
mpd–h-p&
hostname及port都为刚才输出的本地机器名及端口号。
可以用mpdtrace命令检查哪些机器已经加入到mpd环中。
(14)用mpdtrace命令检查是否所有机器都已启动mpd,然后用mpdringtest命令测试在环中传递一个消息,如:
mpdringtest100
mpdringtest1000
(15)有环中测试运行多进程任务:
mpdrun–nhostname
其中number不一定非要等于机器数。
(16)用mpiexec命令运行MPI任务,可以用程序包自带的cpi例子:
mpiexec–n5cpi
关于mpiexec命令更多选项可运行mpiexec--help来查看。
MPI2与MPI1的不同之处:
原来在MPI1中configure命令的一些选项参数在MPI2中必须用环境变量的形式来定义,比如选项参数-cc=必须改为setenvcc。
原来在MPICH1中不以--enable或--with开关的选项参数在MPICH2中都要定义成环境变量的形式。
此外,在进程管理器的处理及通信设备的选择上也有所不同。
MPICH2中的进程管理器
在MPICH2中用一种叫做PMI的接口将MPICH2的代码库与进程管理器分离开来,有三种进程管理器可供选择:
mpd,smpd及gforker。
mpd是默认的进程管理器,它由一个守护进程环组成。
smpd支持windows和linux版本,它是在windows版本的MPICH2中所唯一包含的进程管理器。
gforker在一台单独的机器上启动所有的进程,对调试程序及共享存储的多处理器主机上较有用。
Configure命令中的两个选项参数:
--enable-thread=multiple (使用多线程)
--enable-cxx (使用c++语言绑定)
--enable-timing=none/all/runtime (定义是否加入计时功能)
MPICH2中程序的编译与链接
在MPICH2中,C、C++、FORTRAN77、FORTRAN90对应的默认编译命令分别是mpicc、mpicxx、mpif77、mpif90,可以通过设置MPICH_CC、MPICH_CXX、MPI_F77、MPICH_F90的值来指定编译器。
由于在stdio.h及mpi的C++接口中都定义了SEEK_SET,SEEK_CUR,SEEK_END,所以在编译采用mpi的c++程序时会出错,解决方法是在源代码中,#include之前取消以下宏定义:
#undefSEEK_SET
#undefSEEK_CUR
#undefSEEK_END
另一种方法就是在命令行中加入:
-DMPICH_IGNORE_CXX_SEEK选项。
MPICH2中程序的调试
可以在mpiexec命令中加入-gdb选项来使用调试器gdb调试程序,用-gdba选项来将一个正在运行的程序附加到调试器中。
若使用totalview来调试程序,需要使用选项参数-tv。
MPICH2Release1.0.5(README)
MPICH2Release1.0.5
MPICH2isanall-newimplementationofMPIfromthegroupatArgonneNationalLaboratory. ItsharesmanygoalswiththeoriginalMPICHbutnoactualcode. Itisaportable,high-performanceimplementationoftheentireMPI-2standard. ThisreleasehasallMPI-2functionsandfeaturesrequiredbythestandardwiththeexceptionofsupportforthe
"external32"portableI/Oformat.
Thedistributionhasbeentestedbyusonavarietyofmachinesinourownenvironments.Ifyouhaveproblems,pleasereportthemto[email]mpich2-maint@mcs.anl.gov[/email].
ThisREADMEfileshouldcontainenoughinformationtogetyoustartedwithMPICH2. Moreextensiveinstallationanduserguidescanbefoundinthedoc/installguide/install.pdfanddoc/userguide/user.pdffilesrespectively. AdditionalinformationregardingthecontentsofthereleasecanbefoundattheendofthisREADMEunder"StatusofMPI-2
FeaturesinMPICH2",intheCHANGESfileinthetop-leveldirectory,andintheRELEASE_NOTESfile,wherecertainrestrictionsaredetailed.
Finally,theMPICH2website,http:
//www.mcs.anl.gov/mpi/mpich2,containsinformationonbugfixesandnewreleases.
WindowsusersshouldseethefileREADME.windowsinthisdirectory.
GettingStarted
===============
Thefollowinginstructionstakeyouthroughasequenceofstepstogetthedefaultconfiguration(TCPcommunication,MPDprocessmanagement)ofMPICH2upandrunning. Alternateconfigurationoptionsaredescribedlater,inthesection"Alternativeconfigurations".
1. Youwillneedthefollowingprerequisites.
-Thistarfilempich2-1.0.5.tar.gz
-ACcompiler(gccissufficient)
-AFortrancompilerifFortranapplicationsaretobeused(g77is
sufficient)
-AC++compilerfortheC++MPIbindings(g++issufficient)
-Python2.2orlater(forthedefaultMPDprocessmanager)
-IfaFortran90compilerisfound,bydefaultMPICH2willattempttobuildabasicMPImodule. ThismodulecontainstheMPIroutinesthatdonotcontain"choice"arguments;i.e.,themoduledoesnotcontainanyofthecommunicationroutines,suchasMPI_Send,thatcantakeargumentsofdifferenttype. Youmaystillusethoseroutines,however,theMPImoduledoesnotcontaininterfacespecificationsforthem.IfyouhavetroublewiththeconfigurationstepanddonotneedFortran90,configurewith--disable-f90.
Configurewillcheckfortheseprerequisitesandtrytoworkarounddeficienciesifpossible. (Ifyoudon'thaveFortran,youwillstillbeabletouseMPICH2,justnotwithFortranapplications.)
2. Unpackthetarfileandgotothetopleveldirectory:
tarxfzmpich2.tar.gz
cdmpich2-1.0.5
Ifyourtardoesn'tacceptthezoption,use
gunzipmpich2.tar.gz
tarxfmpich2.tar
cdmpich2-1.0.5
3. Chooseaninstallationdirectory(thedefaultis/usr/local/bin):
mkdir/home/you/mpich2-install
Itwillbemostconvenientifthisdirectoryissharedbyallofthemachineswhereyouintendtorunprocesses. Ifnot,youwillhavetoduplicateitontheothermachinesafterinstallation.
4. ConfigureMPICH2,specifyingtheinstallationdirectory:
./configure-prefix=/home/you/mpich2-install|&teeconfigure.log
(Onshanditsderivatives,use"2>&1|teeconfigure.log"insteadof"|&teeconfigure.log"). Otherconfigureoptionsaredescribedbelow. YoumightalsoprefertodoaVPATHbuild(seebelow).
Checktheconfigure.logfiletomakesureeverythingwentwill.Problemsshouldbeself-explanatory,butifnot,sentconfigure.logto[email]mpich2-maint@mcs.anl.gov[/email].
5. BuildMPICH2:
make|&teemake.log
Thisstepshouldsucceediftherewerenoproblemswiththe
precedingstep. Checkmake.log. Iftherewereproblems,send
make.logto[email]mpich2-maint@mcs.anl.gov[/email].
6. InstalltheMPICH2commands:
makeinstall|&teeinstall.log
Thisstepcollectsallrequiredexecutablesandscriptsinthebin
subdirectoryofthedirectoryspecifiedbytheprefixargumentto
configure.
7. Addthebinsubdirectoryoftheinstallationdirectorytoyourpath:
forcshandtcsh:
setenvPATH/home/you/mpich2-install/bin:
$PATH
forbashandsh:
exportPATH=/home/you/mpich2-install/bin:
$PATH
Checkthateverythingisinorderatthispointbydoing
whichmpd
whichmpiexec
whichmpirun
Allshouldrefertothecommandsinthebinsubdirectoryofyour
installdirectory. Itisatthispointthatyouwillneedto
duplicatethisdirectoryonyourothermachinesifitisnot
inasharedfilesystemsuchasNFS.
8. MPICH2,unlikeMPICH,usesanexternalprocessmanagerforscalable
startupoflargeMPIjobs. Thedefaultprocessmanageriscalled
MPD,whichisaringofdaemonsonthemachineswhereyouwillrun
yourMPIprograms. Inthenextfewsteps,youwillgethisringup
andtested. MoredetailsoninteractingwithMPDcanbefoundin
theREADMEfileinmpich2-1.0.5/src/pm/mpd,suchashowtolist
runningjobs,kill,suspend,orotherwisesignalthem,andhowto
debugprogramswith"mpiexec-gdb".
IfyouhaveproblemsgettingtheMPDringestablished,seethe
InstallationGuideforinstructionsonhowtodiagnoseproblems
withyoursystemconfigurationthatmaybepreventingit. Also
seethatguideifyouplantorunMPDasrootonbehalfofusers.
PleasebeawarethatwedonotrecommendrunningMPDasrootuntil
youhavedonetestingtomakesurethatalliswell.
Beginbyplacinginyourhomedirectoryafilenamed.mpd.conf
(/etc/mpd.confifroot),containingtheline
secretword=
whereisastringknownonlytoyourself. Itshould
NOTbeyournormalUnixpassword. Makethisfilereadableand
writableonlybyyou:
chmod600.mpd.conf
9. Thefirstsanitycheckconsistsofbringinguparingofonempdon
thelocalmachine,testingonempdcommand,andbringingthe"ring"
down.
mpd&
mpdtrace
mpdallexit
Theoutputofmpdtraceshouldbethehostnameofthemachineyouare
runningon. Thempdallexitcausesthempddaemontoexit.
Ifyouhaveproblemsgettingthempdringestablished,see