Chinaunix首页 | 论坛 | 博客
  • 博客访问: 386317
  • 博文数量: 124
  • 博客积分: 2911
  • 博客等级: 少校
  • 技术积分: 1050
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-15 15:57
文章分类

全部博文(124)

文章存档

2012年(6)

2011年(26)

2010年(92)

我的朋友
MPI

分类: 云计算

2011-11-04 20:49:01

1. Environment:
          Node1: will_00 (hostname); cpu=1;192.168.122.50; 
          Node2: will_01 (hostname); cpu=1;192.168.122.51;
     ###双机安装相同的mpich2环境: mpich2, mpich2-devel;###
     ###双机创建相同的用户: 0092 (user); 123 (passwd) ###

2. 创建ssh信任
     1) vi /etc/hosts
          (will_00)
               127.0.0.1   localhost will_00
               192.168.122.50  will_01
               192.168.122.51  will_00
          (will_01)
               127.0.0.1   localhost will_01
               192.168.122.50  will_01
               192.168.122.51  will_00
     2)
     (will_00)
          [0092@will_00 ~]:$ ssh-keygen -t rsa
          [0092@will_00 ~]:$
             Generating public/private rsa key pair.Enter file in which to save the key (/home/0092/.ssh/id_rsa): [默认值]
             Enter passphrase (empty for no passphrase): [默认值,空字符]
             Enter same passphrase again: [默认值,空字符]
             Your identification has been saved in /home/0092/.ssh/id_rsa.
             Your public key has been saved in /home/0092/.ssh/id_rsa.pub.
             The key fingerprint is:67:ae:bd:ef:7b:3f:58:0e:a6:dc:35:68:56:1c:c5:37
          [0092@will_00 ~]:$ ls -a
              . ../   .ssh/
          [0092@will_00 ~]:$ cd .ssh/
          [0092@will_00 ~]:$ cp id_rsa.pub authorized_keys
          [0092@will_00 ~]:$ cd ..
          [0092@will_00 ~]:$ ssh will_01
           ………………………………………………………………………………(yes/no): yes
     (will_01)
          [0092@will_01 ~]:$ ssh-keygen -t rsa      //生成.ssh/
           ………………………………………………………………
          [0092@will_01 ~]:$ scp will_00:/home/0092/.ssh/*   /home/0092/.ssh 
          [0092@will_01 ~]:$ ssh will_00
           ………………………………………………………………………………(yes/no): yes
          ###确认两台机器的信任连接已建立: 在每个节点试验执行###
          [0092@will_01 ~]:$ssh will_00
          [0092@will_00 ~]:$ssh will_01
          ###如有提示,输入yes,确保双方无需输入密码即能登陆###
3. 设置Hydra
    (will_00)
          [0092@will_00 ~]:$ sudo mkdir /etc/hydra
          [0092@will_00 ~]:$ sudo vi /etc/hydra/hosts
                   ##文件结构如下:
                   ## node:cpu_num
                    will_00:1
                    will_01:1
          [0092@will_00 ~]:$ vi ~/.bashrc
                    export HYDRA_HOST_FILE=/etc/hydra/hosts
     (will_01)
          ## do the same thing as above in will_01 ##
4. 测试MPI环境
          [0092@will_00 ~]:$ vim test.c
#include
#include
#include
int main(){
int my_rank;
int comm_sz;

MPI_Init(NULL,NULL);
MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
MPI_Comm_rank(MPI_COMM_WORLD,&comm_sz);

printf("my_rank:%d,comm_sz:%d\n",my_rank,comm_sz);
MPI_Finalize();
return 0;
}
          [0092@will_00 ~]:$ mpicc test.c -o xxx
          [0092@will_00 ~]:$ mpiexec -n 1 ./xxx
          [0092@will_00 ~]:$ mpiexec -n 2 ./xxx

阅读(1180) | 评论(0) | 转发(0) |
0

上一篇:Xen

下一篇:大数乘法

给主人留下些什么吧!~~