--D. Thiebaut (talk) 12:43, 7 October 2013 (EDT)
updated --D. Thiebaut (talk) 16:50, 4 March 2017 (EST)
I've been looking for MPI for OS X and some websites say that it is already installed in OS X (since 10.5). Could someone point out where is it installed? I cannot find mpicc nor mpirun. Alpine Testing aarch64 Official openmpi-4.0.5-r0.apk: Message passing library for high-performance computing: Alpine Testing armhf Official openmpi-4.0.5-r0.apk: Message passing library for high-performance computing.
- from https://www.open-mpi.org/software/ompi/v2.0/
- get the tar file openmpi-2.0.2.tar.bz2 (or whichever latest version is the current one).
- Assume that the downloaded file is in your ~/Downloads directory
- Just follow the directions in the INSTALL file, which are summarized below. The installation was done on *my* machine, and assumes the user is thiebaut. Change and plug-in your own user name.
- open a Terminal window, and type the following commands in it:
- The last command will take 10 minutes or so. When it is done, make all and install
- This last command takes a while as well...
Update your path
- edit the .bash_profile file in your main account directory.
- locate the line that reads PATH=...
- right below this line, add the new line
- and make sure your replace thiebaut by your account name!
- source your .bash_profile so that the new path is learnt by your system
- You are done!
Create this file in the directory of your choice, and call it helloWorld.c:
Compile and Run
- If you see the two lines starting with 'Hello world' on your screen, MPI was successfully installed on your system!
If have not already installed the GNU compilers, check out the HOWTO for installing the GNU compilers on Mac OS X.
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?
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)
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.gzfile, you can untar/zip it by typing
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
If you would like to install Open MPI someplace other than
/usr/local, you can change the installation directory listed after the
If you have multiple compilers installed, you can specify which compilers you would like to use as follows
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
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
Beware that using
sudocan 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 (
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
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 .
Openmpi Mac インストール
Openmp For Mac