How to install MPICH

1 minute read

Requirements

Directions

Linux and macOS

  1. Make sure you are using bash.
     echo $SHELL
    

    If it is not bash, command: bash

  2. Create a folder for mpich
     mkdir /home/you/mpich
    

  3. Unpack mpich-x-y-z.tar.gz to that folder, where x-y-z is the version
     tar xfz mpich-x-y-z.tar.gz
    
  4. Create 2 other folders
     mkdir /home/you/mpich/build
     mkdir /home/you/mpich/mpich-install
    
  5. Enter the build directory and run the configuration script. It is important to write the full path in the prefix argument.
     cd /home/you/mpich/build
     ../mpich-x-y-z/configure --with-device=ch4:ofi -prefix=/home/you/mpich/mpich-install 2>&1 | tee c.txt
    
  6. Build mpich. Run command and go for a coffee:
     make 2>&1 | tee m.txt
    

  7. Install MPICH.
     make install 2>&1 | tee mi.txt	
    
  8. Add the bin subdirectory of the installation directory to your path:
     export PATH=/home/you/mpich/mpich-install/bin:$PATH
    
  9. Check if the installation went well:
     which mpicc
     which mpiexec
    
  10. Test mpi in your machine by using the example file that the building process creates. That simple program computes the value of PI. While still inside the build folder, command:
    mpiexe -n NC ./examples/cpi
    

    where NC is the number of cores of your machine.

Learn more

Windows

You should install Microsoft MPI instead. See how to install Microsoft MPI.

Categories:

Updated:

Leave a comment