当前位置: 首页 > 工具软件 > Open MPI > 使用案例 >

Open MPI 环境搭建

乐正穆冉
2023-12-01

##Open MPI 环境搭建
(1)下载和解压


wget https://download.open-mpi.org/release/open-mpi/v3.1/openmpi-3.1.1.tar.gz
tar -zxvf openmpi-3.1.1.tar.gz

(2)配置,编译和安装

./configure --prefix=/usr/local/openmpi
make
make install

说明:如果不指定–prefix,那么默认的安装路径是/usr/local/lib。
如果MPI 开启多线程支持:

./configure --enable-mpi-thread-multiple

(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-3.1.1/examples
make
mpirun -np 4 hello_c

##2 . mpic++命令

解析:

(1)mpic++ -showme:version

eg: mpic++: Open MPI 3.1.1 (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

使用mpic++编译文件
mpic++ -o3 oneDevicePerprocess.cpp -o cpi

*使用mpicc编译文件
mpicc -o3 oneDevicePerprocess.cpp -o cpi

 类似资料: