OpenMPI学习日记2

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NLP工程化

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值