码迷,mamicode.com
首页 > 其他好文 > 详细

MPICH安装

时间:2014-06-04 17:16:28      阅读:508      评论:0      收藏:0      [点我收藏+]

标签:c   a   http   tar   文件   os   

1. 获得MPI源码;mpich-3.1.tar.gz(从http://www.mpich.org/官网下载)
2. 在目录/home下创建目录mpi/mpich-3.1/src
3. 将mpich-3.1.tar.gz拷贝到/home/mpi/mpich-3.1/src下;
4. 解压mpich-3.1.tar.gz,生成目录mpich-3.1;命令tar –zxvf MPICH-3.1.tar.gz
5. 进入目录mpich-3.1;
6. 配置:./config –prefix=/home/mpi/mpich-3.1  (/home/mpi/mpich-3.1是配置安装目录)
7. 编译:make
8. 安装:make install
9. 打开~/.bash_profile文件;命令:vim ~/.bash_profile
  在文件最后添加以下三行:
   export MPI_ROOT=/home/mpi/mpich-3.1
   export PATH=$MPI_ROOT/bin:$PATH
   export MANPATH=$MPI_ROOT/man:$MANPATH
10. 测试环境变量设置;命令which mpicc 显示mpicc所在刚才安装的目录的bin目录下;例如:
  [root@localhost mpich-3.1]# which mpicc
  /home/mpi/mpich-3.1/bin/mpicc
   [root@localhost mpich-3.1]# which mpirun
   /home/mpi/mpich-3.1/bin/mpirun

11. 测试MPI程序,在刚才解压的mpich-3.1目录下有个examples目录,在exapmle目录下cpi.c文件,此程序是并行计算pi值;
  首先,编译cpi.c文件,生成cpi可执行文件(若目录已经有了cpi则此步骤可省略)

    命令:mpicc cpi.c –o cpi
  然后,执行cpi:
      命令:mpirun -n <number> . /cpi   //<number> 是要启动的进程数,例如8;
执行结果如下:
  【root@localhost exapmles】#mpirun –n 8 ./cpi
  Process 1 of 8 is on localhost
  Process 3 of 8 is on localhost
  Process 4 of 8 is on localhost
  Process 5 of 8 is on localhost
  Process 0 of 8 is on localhost
  Process 2 of 8 is on localhost
  Process 6 of 8 is on localhost
  Process 7 of 8 is on localhost
  Pi is approximately 3.1415926544231265,Error is 0.00000000008333334
  Wall clock time =0.000161

  localhost是主机名,8是启动了8个进程,1是本进程号是1等;
12. 到此完成安装;

MPICH安装,布布扣,bubuko.com

MPICH安装

标签:c   a   http   tar   文件   os   

原文地址:http://www.cnblogs.com/hiuser/p/3764638.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!