MPI学习笔记——MPI环境配置

来源:互联网 发布:mac安装自带输入法 编辑:程序博客网 时间:2024/05/14 10:29
第一步 Ubuntu下安装SSH服务器和客户端
打开新立得,在全部里键入openssh,选择openssh-client和openssh-server标记安装应用,或者直接执行
$ sudo apt-get install openssh-client openssh-server


第二步 安装MPICH
打开新立得,在全部里键入mpi,选择mpi-bin、mpi-doc、libmpich1.0-dev标记安装应用 


$ sudo apt-get install mpi-bin mpi-doc libmpich1.0-dev


第三步 测试安装
$ touch hello.c
键入以下内容到hello.c
1 #include <mpi.h> 
 2 #include <stdio.h>
 3 int main(int argc, char *argv[]) 
 4 { 
 5     int npes, myrank; 
 6     MPI_Init(&argc, &argv); 
 7     MPI_Comm_size(MPI_COMM_WORLD, &npes); 
 8     MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 
 9     printf("From process %d out of %d, Hello World!\n", myrank, npes); 
10    MPI_Finalize();
11 }
$ mpicc -o hello hello.c
$ mpirun -np 2 hello #应该会输出两次Hello,中间可能要求输入密码,如不想输入密码,看第四步


第四步 取消SSH的密码步骤
$ ssh-keygen -t dsa #中间提示输入密码,直接回车,会在生成文件~/.ssh/id_dsa.pub
$ cat id_dsa.pub >> authorized_keys
$ mpirun -np 2 hello #应该没有密码输入提示了

原创粉丝点击