要安装并同时支持MPICH和OpenMPI,您需要按照以下步骤操作:
安装gcc和icc编译器:
sudo apt-get install gcc
sudo apt-get install icc
安装MPICH:
wget http://www.mpich.org/static/downloads/3.4.2/mpich-3.4.2.tar.gz
tar xf mpich-3.4.2.tar.gz
cd mpich-3.4.2
./configure CC=gcc CXX=g++ FC=gfortran --prefix=/usr/local/mpich
make -j4
sudo make install
安装OpenMPI:
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.1.tar.gz
tar xf openmpi-4.1.1.tar.gz
cd openmpi-4.1.1
./configure CC=gcc CXX=g++ FC=gfortran --prefix=/usr/local/openmpi
make -j4
sudo make install
配置环境变量:
打开终端配置文件(例如~/.bashrc)并添加以下行:
export PATH=/usr/local/mpich/bin:$PATH
export PATH=/usr/local/openmpi/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/mpich/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH
然后运行以下命令使更改生效:
source ~/.bashrc
现在,您的系统应该同时支持MPICH和OpenMPI,并且可以使用gcc和icc编译器进行编译。