If have not already installed the GNU compilers, check out the HOWTO for installing the GNU compilers on Mac OS X.
Background
Why might you consider installing Open MPI? First, many programs that were designed to run distributed across several computers using MPI can now be run on a multi-core modern desktop computer. To me, this is the biggest motivation, since I can test software more easily on my desktop (or laptop) machine than on a cluster. Second, multi-core computers are the future. Almost any machine purchased in the last year or two has multiple processor cores. Why not put them to use?
Requirements
To install Open MPI as described in this HOWTO, you'll need the following:
- A Mac running Mac OS 10.6 (Snow Leopard), 10.7 (Lion), 10.8 (Mountain Lion) or 10.9 (Mavericks)
- Internet access
- Fortran and or C/C++ compilers (If you don't have compliers installed, check out the HOWTO on installing the GNU compilers)
Instructions
The installation of Open MPI on Mac is surprisingly easy.
- Download source code from http://www.open-mpi.org/software/. At the time of posting the current stable release of Open MPI is version 1.6.5.
Copy the archive file to a temporary location to compile it. Open Terminal.app and change directories to the new location of the Open MPI archive. If you downloaded the source code as a
.tar.gz
file, you can untar/zip it by typingtar zxvf openmpi-1.6.5.tar.gz
which will create a directory called
openmpi-1.6.5/
. Change directories into the new directory.You can now run the configuration script. As mentioned above, if you don't have any compilers installed, you should check out the HOWTO on installing the GNU compilers before proceeding. If you only have one set of compilers installed, you can run the configuration script by typing
./configure --prefix=/usr/local
If you would like to install Open MPI someplace other than
/usr/local
, you can change the installation directory listed after theprefix
flag.If you have multiple compilers installed, you can specify which compilers you would like to use as follows
./configure CC=icc CXX=icpc F77=ifort FC=ifort --prefix=/usr/local
where you specify the C (
CC
), C++ (CXX
), Fortran 77 (F77
) and Fortran 90 and later (FC
) compilers with the listed variables.
Assuming the configuration script runs without issue, you can compile the code by typing
make all
which will compile the Open MPI libraries/binaries and configure the wrappers for using the specified compilers. This should take a bit...
Again, assuming the code compiles without issue, you can install Open MPI by typing
sudo make install
Beware that using
sudo
can do major damage to your computer if you aren't careful. You can now feel free to delete the temporary Open MPI build directory (e.g.,openmpi-1.6.5/
) since the code has been installed. If you think you might want to rebuild with different compilers or change the configuration, you may want to keep this directory around.
So now you should have a functional installation of Open MPI on your Mac. You should be able to compile code that uses MPI by using the Open MPI compiler wrappers (mpicc
, mpicxx
, mpif77
, mpif90
) and run MPI-enabled programs with mpiexec
. If you try to use the new Open MPI executables and they are not found, it may be that /usr/local/bin
(or wherever you specified with the --prefix
flag in the configure stage) is not in your $PATH
environment variable. You can confirm this by typing
echo $PATH
if you do not see /usr/local/bin
listed between the colons, you will need to add it. I describe how to do this at the end of the HOWTO on installing the GNU compilers.
Tips & Warnings
- For assistance on linking to Open MPI or running MPI-enabled software, check out the Open MPI documentation .
Related
10 Comments
Anonymous
Thank you, very clear instructions!
Anonymous
Thank u so much for you idea of installing openmpi
Anonymous
brew install open-mpi (using http://brew.sh).
Anonymous
hi, in make install , i got an error that "C compiler cannot creat executables.."
while configure was done, i saw that "checking whether C compiler works ... yes"
but in make file it says C compiler doesnt work: See below which i get after doing make file:
*** Startup tests
checking build system type... x86_64-apple-darwin13.1.0
checking host system type... x86_64-apple-darwin13.1.0
checking target system type... x86_64-apple-darwin13.1.0
checking for gcc... icc
checking whether the C compiler works... no
configure: error: in `//Users/username/Downloads/openmpi-1.8':
configure: error: C compiler cannot create executables
See `config.log' for more details
Please help...
Anonymous
I have gotten the same problem. It seems that the precompiled gcc has problems... I wonder if one can simply use clang from XCODE instead of gcc
Anonymous
I had the exact same error as a previous poster. (C compiler cannot create exectutables).
Weirdly, when I ran the exact same ./
configure --prefix=/usr/local
command a SECOND time, it worked without a hitch!Weird, but it worked.
Anonymous
Hi, I'm trying install openMPI on my macbook running os x 10.9.2 with Xcode 5.1.1.
I'm using the following compilers :
~/openmpi-1.6.5)gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
~/openmpi-1.6.5)gfortran -v
Using built-in specs.
Target: i686-apple-darwin8
Configured with: /Builds/unix/gcc/gcc-4.2/configure --prefix=/usr/local --mandir=/share/man --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --build=i686-apple-darwin8 --host=i686-apple-darwin8 --target=i686-apple-darwin8 --enable-languages=fortran
Thread model: posix
gcc version 4.2.3
The ./configure failed ending with
...
*** Fortran 90/95 compiler
checking for gfortran... gfortran
checking whether we are using the GNU Fortran compiler... yes
checking whether gfortran accepts -g... yes
checking if Fortran 77 compiler works... no
**********************************************************************
* It appears that your Fortran 77 compiler is unable to produce working
* executables. A simple test application failed to properly
* execute. Note that this is likely not a problem with Open MPI,
* but a problem with the local compiler installation. More
* information (including exactly what command was given to the
* compiler and what error resulted when the command was executed) is
* available in the config.log file in this directory.
**********************************************************************
configure: error: Could not run a simple Fortran 77 program. Aborting.
I don't know what to do..
Anonymous
Thank you so much!!! You did a great job!
Anonymous
Not to contaminate the sources one might create a "openmp-<version>/build" folder, cd to it, and run ../configure --prefix=/usr/local and the rest of the make commands from there.
If you upgraded to Mavericks, it might have removed some command line tools (seriously), reinstall them via "/usr/local/bin.xcode-select --install". This would preserve previous install of the gcc 4.9 and "configure" script of OpenMP will start working.
Nice job, otherwise!
Anonymous
Hi guys,
I think why you get things like "C compiler cannot creat executables.." is because your PATH is not set correctly. Moreover, even if the PATH was set correctly in your home terminal, if you sudo the installation the PATH changes to the sudoer (which is not the home user). An easy away is to
sudo su
and then run your configuration and make commands.