Building an MPI library : Différence entre versions
(6 révisions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
− | There are a few freely available MPI libraries around; among the most widely spread are the OpenMPI and MPICH libraries | + | There are a few freely available MPI libraries around; among the most widely spread are the OpenMPI https://www.open-mpi.org/ and MPICH https://www.mpich.org/ libraries |
== Checking if you have an Fortran enabled MPI library already installed and at hand == | == Checking if you have an Fortran enabled MPI library already installed and at hand == | ||
Ligne 8 : | Ligne 8 : | ||
returns something meaningful | returns something meaningful | ||
− | == Example of | + | == using a package manager == |
+ | If you have sudo privileges and are on an Ubuntu or Linux Mint machine you should be able to install the OpenMPI library with | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | sudo apt install libopenmpi-dev openmpi-bin | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | == Example of personal installation of the the OpenMPI library == | ||
To adapt to fit your onw needs and system specificities, obviously. | To adapt to fit your onw needs and system specificities, obviously. | ||
− | In the example below the installation is done in the '''$HOME/ | + | In the example below the installation is done in the '''$HOME/myopenmpi''' directory (for convenience this path is stored in the '''PATH_OPENMPI''' variable. |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | PATH_OPENMPI=$HOME/ | + | PATH_OPENMPI=$HOME/myopenmpi/ |
mkdir -p $PATH_OPENMPI | mkdir -p $PATH_OPENMPI | ||
cd $PATH_OPENMPI | cd $PATH_OPENMPI | ||
Ligne 19 : | Ligne 25 : | ||
tar xvf openmpi-1.10.3.tar | tar xvf openmpi-1.10.3.tar | ||
cd openmpi-1.10.3 | cd openmpi-1.10.3 | ||
− | ./configure --prefix $PATH_OPENMPI | + | ./configure --prefix $PATH_OPENMPI |
make all install | make all install | ||
</syntaxhighlight> | </syntaxhighlight> | ||
To check that the install went well check that | To check that the install went well check that | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $PATH_OPENMPI | + | $PATH_OPENMPI/bin/mpif90 -V |
+ | </syntaxhighlight> | ||
+ | returns something meaningful like | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 | ||
+ | Copyright (C) 2019 Free Software Foundation, Inc. | ||
+ | This is free software; see the source for copying conditions. There is NO | ||
+ | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | == | + | Once you have a distribution correctly installed you will need to update your environment variables '''PATH''' and '''LD_LIBRARY_PATH''' to point to the relevant locations (the '''bin''' and '''lib''' subdirectories of the distribution). |
− | ... | + | In practice this is typically done in your ''$HOME/.bash_profile'' or ''$HOME/.bashrc'' file, where for instance, if your installed the library in '''$HOME/myopenmpi''' you would add: |
+ | <syntaxhighlight lang="bash"> | ||
+ | export PATH=$PATH:$HOME/myopenmpi/bin | ||
+ | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/myopenmpi/lib | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | == A few things worth knowing about == | ||
+ | * '''mpif90''' is just a wrapper around a given compiler which could be gfortran, ifort, pgfortran, etc. to know more about that run | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | mpif90 --version | ||
+ | </syntaxhighlight> | ||
+ | * in some cases the Fortran wrapper is called '''mpifort''' or '''mpiifort''' (e.g. with ifort, sometimes) , not '''mpif90''' | ||
+ | * It is vital to use the '''mpirun''' command from the same package than the '''mpif90''' compilation wrapper used to compile the code. Otherwise one can get some really weird results... | ||
− | + | 24/05/2023 | |
− | [[Category: | + | [[Category:FAQ]] |
− |
Version actuelle en date du 24 mai 2023 à 08:02
There are a few freely available MPI libraries around; among the most widely spread are the OpenMPI https://www.open-mpi.org/ and MPICH https://www.mpich.org/ libraries
Sommaire
Checking if you have an Fortran enabled MPI library already installed and at hand
This can easily be done by checking if the MPI wrapper mpif90 is available, i.e. that
which mpif90
returns something meaningful
using a package manager
If you have sudo privileges and are on an Ubuntu or Linux Mint machine you should be able to install the OpenMPI library with
sudo apt install libopenmpi-dev openmpi-bin
Example of personal installation of the the OpenMPI library
To adapt to fit your onw needs and system specificities, obviously. In the example below the installation is done in the $HOME/myopenmpi directory (for convenience this path is stored in the PATH_OPENMPI variable.
PATH_OPENMPI=$HOME/myopenmpi/
mkdir -p $PATH_OPENMPI
cd $PATH_OPENMPI
wget https://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.3.tar.gz
gunzip openmpi-1.10.3.tar.gz
tar xvf openmpi-1.10.3.tar
cd openmpi-1.10.3
./configure --prefix $PATH_OPENMPI
make all install
To check that the install went well check that
$PATH_OPENMPI/bin/mpif90 -V
returns something meaningful like
GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Once you have a distribution correctly installed you will need to update your environment variables PATH and LD_LIBRARY_PATH to point to the relevant locations (the bin and lib subdirectories of the distribution). In practice this is typically done in your $HOME/.bash_profile or $HOME/.bashrc file, where for instance, if your installed the library in $HOME/myopenmpi you would add:
export PATH=$PATH:$HOME/myopenmpi/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/myopenmpi/lib
A few things worth knowing about
- mpif90 is just a wrapper around a given compiler which could be gfortran, ifort, pgfortran, etc. to know more about that run
mpif90 --version
- in some cases the Fortran wrapper is called mpifort or mpiifort (e.g. with ifort, sometimes) , not mpif90
- It is vital to use the mpirun command from the same package than the mpif90 compilation wrapper used to compile the code. Otherwise one can get some really weird results...
24/05/2023