centos mpi 安装(openmp安装)

大家好,关于centos mpi 安装很多朋友都还不太明白,不过没关系,因为今天小编就来为大家分享关于openmp安装的知识点,相信应该可以解决大家的一些困惑和问题,如果碰巧可以解决您的问题,还望关注下本站哦,希望对各位有所帮助!

centos7上怎么用intel mpi搭建集群

您好,你的问题,我之前好像也遇到过,以下是我原来的解决思路和方法,希望能帮助到你,若有错误,还望见谅!展开全部

一.配置安装MPI

先在官网下载openmpi安装包(Linux版):下载MPI

2.然后通过一下命令安装:

解压:

tar-zxvf openmpi-1.6.4.tar.gz

进入到解压文件目录下:

cd openmpi-1.6.4

执行:(在这一步之前,要确保已经安装g++,没有安装可以输入命令:sudo apt-get install g++进行安装)

./configure

安装所有文件:(这一步会花几分钟的时间,慢慢等待)

make all install

为/etc/profile文件添加库共享路径,(默认情况下,MPI的库文件在/usr/local/lib目录下),执行sudo geidt/etc/profile,然后在其中加入一行export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

执行下面命令,使配置的文件有效:

source/etc/profile

到这里MPI就已经配置完成了!

接下来测试一下:

测试成功!!!(如果出现:“cannont open shared object file…”的情况,需要重新编译source/etc/profile)

二、安装eclipse,下载eclipse。下载完毕,直接解压运行即可。

三、给eclipse装PTP插件

打开eclipse>help>install new software>>add,然后输入需要安装的PTP……

安装完成!非常感谢您的耐心观看,如有帮助请采纳,祝生活愉快!谢谢!

Linux(CentOS)安装mpich

为了在 CentOS系统中安装 MPICH,首先需要在官方网站 mpich.org/下载合适的版本,例如 mpich-3.2.tar.gz。之后,将下载的文件上传至服务器中并进行解压操作。

进入解压目录并配置编译环境。具体步骤为:cd到解压后的目录下,然后运行./configure--prefix=/home/mpich-3.2命令。

接下来,编译并安装 MPICH。可以使用 make&& make install的命令组合完成。如果希望将编译和安装分开进行,也可以分别使用 make和 make install命令。

为了确保 MPICH环境变量可以被其他程序使用,需要设置环境变量。打开~/.bashrc文件并加入如下环境变量设置代码:export PATH="home//mpich-3.2/bin:$PATH"。

更新环境变量:source~/.bashrc。

至此,MPICH已经安装完成。可以通过以下步骤进行测试:进入解压目录下的 examples文件夹;在 examples文件夹中,利用 MPI接口编译 hellow.c文件,命令为:mpicc hellow.c-o hellow;最后运行 hellow文件,并使用 mpirun-np N./hellow命令(N为进程数),检查每个核是否成功输出"Hello world from process 0 of N"。如果出现该输出,则表示 MPICH安装成功。

Centos7安装MPICH出现问题

mpiexec-n<number>./examples/cpi

运行时需要自己修改<number>为自己的值,我指定的是<number>=4

在运行后出现了一下的问题,程序cpi所在的位置不允许运行。

/usr/bin/ld: cannot open output file/home/themingyi/Downloads/mpich-3.3/examples/.libs/14351-lt-cpi: Permission denied

查找资料后发现是程序所在位置权限设置的问题;修改如下:

sudo chown-R"$USER:"/home/themingyi/Downloads/mpich-3.3/examples

chmod-R 777/home/themingyi/Downloads/mpich-3.3/examples

几点解释:

(1)The-R flag stands for recursive, so that directory and all its subfiles and subdirectories will change owner. Remove the-R flag to just change the permissions of the directory itself.

(2)运行时找到examples文件夹,就在自己下载的mpich包的解压文件中

运行结果如下:

cpi.c程序:

/*-*- Mode: C; c-basic-offset:5; indent-tabs-mode:nil;-*-*/↩

/*↩

*(C) 2001 by Argonne National Laboratory.↩

* See COPYRIGHT in top-level directory.↩

*/↩

#include"mpi.h"↩

#include<stdio.h>↩

#include<math.h>↩

double f(double);↩

double f(double a)↩

{↩

return(4.0/(1.0+ a* a));↩

}↩

int main(int argc, char*argv[])↩

{↩

int n, myid, numprocs, i;↩

double PI25DT= 3.141592653589793238462643;↩

double mypi, pi, h, sum, x;↩

double startwtime= 0.0, endwtime;↩

int namelen;↩

char processor_name[MPI_MAX_PROCESSOR_NAME];↩

MPI_Init(&argc,&argv);↩

MPI_Comm_size(MPI_COMM_WORLD,&numprocs);↩

MPI_Comm_rank(MPI_COMM_WORLD,&myid);↩

MPI_Get_processor_name(processor_name,&namelen);↩

fprintf(stdout,"Process%d of%d is on%s\n", myid, numprocs, processor_name);↩

fflush(stdout);↩

n= 10000;/* default# of rectangles*/↩

if(myid== 0)↩

startwtime= MPI_Wtime();↩

MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD);

h= 1.0/(double) n;↩

sum= 0.0;↩

/* A slightly better approach starts from large i and works ba ck*/↩

for(i= myid+ 1; i<= n; i+= numprocs){↩

x= h*((double) i- 0.5);↩

sum+= f(x);↩

}↩

mypi= h* sum;↩

MPI_Reduce(&mypi,&pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WOR LD);↩

if(myid== 0){↩

endwtime= MPI_Wtime();↩

printf("pi is approximately%.16f, Error is%.16f\n", pi, fabs(pi- PI25DT));↩

printf("wall clock time=%f\n", endwtime- startwtime);↩

fflush(stdout);↩

}↩

MPI_Finalize();↩

return 0;↩

}↩

建议看看《Linux就该这么学》

阅读剩余
THE END