Ubuntu11.10下并行程序设计MPI的安装方法和使用

1.安装MPICH
新立得软件包管理器 键入mpi,选择mpich2、mpich2-doc、libmpich2-dev等标记安装应用(貌似libmpich2-3也会被安装)

最新版本为1.4-1

which mpicc 可查找安装路径

2.测试安装
$ touch hello.c
键入以下内容到hello.c:


#include <mpi.h> 
#include <stdio.h>
int main(int argc, char *argv[]) 

int npes, myrank; 
MPI_Init(&argc, &argv); 
MPI_Comm_size(MPI_COMM_WORLD, &npes); 
MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 
printf("From process %d out of %d, Hello World!\n", myrank, npes); 
MPI_Finalize();
 }


$ mpicc -o hello hello.c
$ mpirun -np 4 ./hello #应该会输出

From process 2 out of 4, Hello World!
From process 0 out of 4, Hello World!
From process 1 out of 4, Hello World!
From process 3 out of 4, Hello World!


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

第二种安装方法:官网下载源码包,自己编译。

mpich2-1.3.2pl.tar.gz下载与安装  

自己并没有验证,大家可以试下上面这篇文章。

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

参考资料:

1. http://hi.baidu.com/zhengym02/blog/item/cc2259dc5ce52b4e94ee379f.html

2. 安装包官网下载地址: http://www.mcs.anl.gov.sixxs.org/research/projects/mpich2/downloads/index.php?s=downloads

3. MPI安装与运行报告(Win7和Ubuntu) http://apps.hi.baidu.com/share/detail/32075184


你可能感兴趣的:(测试,ubuntu)