Getting Sart with OpenMPI On Federa 14 X86_64

Getting Sart with OpenMPI On Federa 14 X86_64

 

来源:http://dvbmonkey.wordpress.com/2009/02/27/getting-started-with-open-mpi-on-fedora/

 

背景介绍:工作需要,涉及到MPI编程,查了些资料,现将安装步骤记录如下,以备不时之需。由于只需要单机模式,不需要点集形式,所以配置起来也比较简单。


安装$ sudo yum install openmpi openmpi-devel openmpi-libs


安装之后,查看安装位置:

$ whereis oenmpi

openmpi:/usr/lib64/openmpi


配置 :将MPI的bin和lib加入到PATH 和LD_LIBRARY_PATH中去。

打开$HOME/.bash_profile
在最后加上

PATH=$PATH:/usr/lib64/openmpi/bin

LD_LIBRARY_PATH=/usr/lib64/openmpi/lib

保存

注销后登录查看配置结果

$echo $PATH

$echo $LD_LIBRARY_PATH

结果中显示有/usr/lib64/openmpi/lbin和 /usr/lib64/openmpi/lib则为配置成功


测试:

hello.c:

#include <stdio.h>
#include <mpi.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
int numprocs, rank, 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, &rank);
MPI_Get_processor_name(processor_name, &namelen);
printf("Hello World! from process %d out of %d on %s/n", rank, numprocs, processor_name);
MPI_Finalize();

  return 0;
}

编译:mpicc -o hello hello.c
运行:mpirun -np5 hello
运行结果显示:
Hello World! from process 0 out of 5 on Shisir
Hello World! from process 4 out of 5 on Shisir
Hello World! from process 2 out of 5 on Shisir
Hello World! from process 3 out of 5 on Shisir
Hello World! from process 1 out of 5 on Shisir

恭喜  安装配置成功!

你可能感兴趣的:(编程,工作,测试,Path,library,X86)