一.
首先
sudo apt-get install build-essential
sudo apt-get install checkinstall
二.
然后
1. Go to http://www.open-mpi.org and download the latest .tar.gz package
https://download.open-mpi.org/release/open-mpi/v3.1/openmpi-3.1.0.tar.gz
2. Create a directory to install OpenMPI and go into it
$ mkdir $HOME/openmpi
$ cd $HOME/openmpi
3. Copy the .tar.gz file into this directory:
$ cp $HOME/Downloads/openmpi-1.8.7.tar.gz $HOME/openmpi
4. Extract the package and go into the extracted directory:
$ tar -xzvf openmpi-1.8.7.tar.gz$ cd openmpi-1.8.7
5. Configure and compile (this step may take about 5-10 minutes):
$ ./configure --prefix=$HOME/openmpi
$ make all
6. Finally install using the following command:
$ make install
Add OpenMPI to your PATH and LD_LIBRARY_PATH environment variable.
bash shell可以使用如下命令添加环境变量
export PATH=$PATH:$HOME/openmpi/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/openmpi/lib
三.
可以输入
ompi_info
测试是否安装成功
参考 https://www.youtube.com/watch?v=QIMAu_o_5V8
待续...
//运行 mpirun -np 8 ./hellowrold_c
helloworld.c
//编译 mpicxx helloworld.c -o helloworld_c
#include <mpi.h>
#include <stdio.h>
int main(int argc, char**argv){
MPI_Init(&argc, &argv);
printf("hello \n");
MPI_Finalize();
return 0;
/*
//openMPI的初始化函数
MPI_Init(&argc, &argv);
int world_size, wrank;
//获取容器中进程数
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
//获取当前进程标识
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
//调用C语言的printf函数打印
printf("Hello world. I'm the process %d, we are %d process in total\n, wrank, world_size.");
//openMPI的结束函数
MPI_Finalize();
return 0;*/
}
其它类型,建议自己挨个试试
mpiCC.openmpi
mpic++.openmpi
mpicc.openmpi
mpicxx.openmpi
mpif77.openmpi
mpif90.openmpi