您的位置:首页 > 运维架构

OpenMPI学习日记2

2016-08-16 14:19 435 查看
1. OpenMPI环境搭建
(1)下载和解压

wget https://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.3.tar.gz tar -zxvf openmpi-1.10.3.tar.gz
(2)配置,编译和安装
./configure --prefix=/usr/local/openmpi
make
make install
说明:如果不指定--prefix,那么默认的安装路径是/usr/local/lib。

(3)配置环境变量(~/.bashrc)

export PATH=$PATH:/usr/local/openmpi/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openmpi/lib/
source ~/.bashrc
sudo ldconfig
(4)进行测试
cd openmpi-1.10.3/examples
make
mpirun -np 4 hello_c
但是,在make的时候,却报错误,如下所示:
mpicc -g    hello_c.c   -o hello_c
hello_c.c: In function ‘main’:
hello_c.c:16:18: error: ‘MPI_MAX_LIBRARY_VERSION_STRING’ undeclared (first use in this function)
char version[MPI_MAX_LIBRARY_VERSION_STRING];
^
hello_c.c:16:18: note: each undeclared identifier is reported only once for each function it appears in
make: *** [hello_c] Error 1
说明:暂时还没有找到解决方案,换成openmpi-1.8.4后,便可以正常使用了。需要说明的是如果是以root账户运行程序,那么mpirun
--allow-run-as-root -np 8 hello_c即可。

2. mpic++命令

解析:

(1)mpic++ -showme:version

eg: mpic++: Open MPI 1.8.4 (Language: C++)

(2)mpic++ -showme

eg: g++ -I/usr/local/openmpi/include -pthread -Wl,-rpath -Wl,/usr/local/openmpi/lib -Wl,--enable-new-dtags -L/usr/local/openmpi/lib -lmpi_cxx -lmpi

(3)mpic++ -showme:libdirs

eg: /usr/local/openmpi/lib

(4)mpic++ -showme:libs

eg: mpi_cxx mpi

3. Nsight Eclipse Edition开发OpenMPI应用程序

主要是配置GCC C Linker中的Libraries。如下所示:



编译和链接程序的时候没有报错,但是执行程序的时候却报错error while loading shared libraries: libmpi_cxx.so.1: cannot open shared object file: No such file or directory。解决的方案是将/usr/local/openmpi/lib添加到/usr/local/openmpi/lib中,然后执行命令ldconfig,最后重新执行程序正常运行。

参考文献:

[1] ubuntu下安装openMPI:http://blog.csdn.net/swuteresa/article/details/9405383
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  openmpi ubuntu eclipse c g