安装openmpi 基于Ubuntu16.04

一.

首先

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


  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值