MPI compile 设置 centos 7

需要使用openmpi的mpi.h文件才能成功compile,因此要安装openmpi:

sudo yum install openmpi-devel

简易方式

sudo yum install environment-modules
source /etc/profile.d/modules.sh
module add openmpi-x86_64

加入path

export PATH=$PATH:/usr/lib/openmpi/bin

将possum下makefile中加一行

CXX=mpicxx

若报错mpicc: error while loading shared libraries: libopen-pal.so.0: cannot open shared object file: No such file or directory

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64/openmpi/1.3.2-gcc/lib/

If you have not taken a precompiled version, you will require:

GNU make
GNU install
GCC C/C++ compiler (versions gcc-4.0, 4.1, 4.2 and 4.4 are known to work in general although 4.2 upwards is recommended).
Header files for:
    expat
    libX11
    libGL
    zlib 

On Centos/RHEL you would install these with the command (assuming your account has sudo rights):

    sudo yum install expat-devel libX11-devel mesa-libGL-devel zlib-devel

Make a folder to build the source code in, for example ~/fslbuild
Put the tar file into your build location, and unpack the sources :

    cd ~/fslbuild
    tar zxf fsl-5.0.0-sources.tar.gz

Set the main FSL environment variables (for version 5.0.6 and above you first need to uncomment the lines related to FSLCONFDIR and FSLMACHTYPE in $FSLDIR/etc/fslconf/fsl.sh):

export FSLDIR=`pwd`/fsl
. ${FSLDIR}/etc/fslconf/fsl.sh

Then check if your machine/compiler is supported by default:

ls $FSLDIR/config/$FSLMACHTYPE

If the above directory does not exist (the ls returns an error):

Select the closest match from the directories in $FSLDIR/config and do the following:

cp -r $FSLDIR/config/closestmatch $FSLDIR/config/$FSLMACHTYPE

Depending on how different your machine and compiler are from the closest match, you may need to edit the files inside the FSLDIR/config/ FSLMACHTYPE directory which set the local paths and variables for things like install commands, compiler flags, etc.

If you wish to use your vendor supplied TCL/TK (or other third-party libraries, eg libpng) then edit the file FSLDIR/config/ FSLMACHTYPE/externallibs.mk to point at the header files for these libraries.

Once this test is done then the sources can be built with:

cd $FSLDIR
./build

If you want to re-make a particular package in $FSLDIR/src (e.g. flirt) then first set the FSLDEVDIR environment variable to the same as FSLDIR and then just type:

make install

全部设置完,要使用以下方式运行

mpirun -np 3 ./possum

你可能感兴趣的:(系统,C++)