固定链接 html address
English title: The installation of mpich and the whole process to run a code on a parallel cluster imitated by ubuntu linux pc.
PVM
LAM/MPI and MPICH, 三种提供并行的实现。 我安装的是 MPICH. English title: The installation of mpich and the whole process to run a code on a parallel cluster imitated by ubuntu linux pc.
PVM
For non ubuntu linux 安装需要 root 权限。 type
su , then input the password, and you can do the operations as root.
在ubuntu 下,不能su成root, 在执行命令前加 sudo 即可。
For ubuntu, add sudo before command.
1.
sudo cp mpich2-1.0.3.tar.gz /usr/local/share/
cd /usr/local/share
2. unzip the file
sudo tar xzvf mpich2-1.0.3.tar.gz
cd mpich2-1.0.3
3. 默认安装 (install as default)
I installed mpich2-1.0.3 on my computer with an ubuntu operating system.
sudo ./configure
sudo make
sudo make install
这样我有了一个单机模拟多个cpu的并行环境。
But you can not compile f77 code, please use the following command
没有 fortran 编译命令 mpif77 . 下面的安装有 mpif77 , 可以编译fortran 程序。
sudo make clean
sudo ./configure --enable-f77
sudo make
sudo make install
4. go to your home directory
cd ~/
5. finish installing mpich, and then
you can write a small code
#include "mpi.h"
#include <iostream>
int main(){
int rank;
int size;
MPI_Init(0,0);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
std::cout<<"Hello world from process "<<rank<<" of "<<size<<std::endl;
MPI_Finalize();
return 0;
}
6. compile and link the code
mpicxx -o hello.out hello.cpp
7. start the parallel environment ( you have a virtual parallel cluster)
启动并行环境
mpdboot
8. If it is the first time you use the command 'mpdboot', you may see an error message.
Please do:
cd $HOME
touch .mpd.conf
chmod 600 .mpd.conf
then run the command 'mpdboot' again
mpdboot
9. 使用两个 node 运行程序
You can try using two node to run the code
mpirun -n 2 ./hello.out
Or using the following commands 下列命令也可:
mpiexec -n 2 ./hello.out
mpiexec -np 2 ./hello.out
mpirun -np 2 ./hello.out
输出的结果
The output will be
Hello world from process 0 of 2
Hello world from process 1 of 2
10. If you want to stop the parallel environment 想停止并行运行环境
mpdcleanup
11. There are other commands, and you can use 'man ' to see the help. 下面是其他的命令
mpdexit mpdringtest mpiexec
mpartition mpd mpdroot mpif77
mpdallexit