I've been taking the course Parallel Computing this semester, and I'm also participating in some student cluster competitions. Therefore, I wanted to configure OpenMP and MPI on my Mac to run some OpenMP and MPI programs. This post describes how I successfully configured OpenMP and MPI with Homebrew.
1 Known Guides For Building OpenFOAM 2.3.x on Mac OS X. The known guides for building OpenFOAM on Mac OS X are as follows: Available on the forum: Installation notes: OpenFOAM 2.3.x (git repo). Either do 'port install openmpi-mp' or 'port install openmpi-default' Ignore it. Using mpicc and mpicxx wrappers will take care of includes and linking. I have inherited an application with a makefile that supports the use of MPI for parallelization. Toward the end of the make procedure, the make fails due to the mpif90 command not being found. I have installed openmpi-bin (I am using Ubuntu 16.04), but that might have been pointless. Open MPI Mac OS X Package notes: This package was built on a machine running OS X 10.4.9. It should work on any 10.4 machine. The Open MPI tree is installed with a prefix of /usr/local. The Open MPI package is built as a Universal Binary, including support for PPC, PPC64, i386, and x8664 platforms. This package requires a Universal-binary. Stack Overflow Public questions & answers; Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Jobs Programming & related technical career opportunities; Talent Recruit tech talent & build your employer brand; Advertising Reach developers & technologists worldwide; About the company. Using the following command: CC=icc CFLAGS='-O3 -xcore-avx2 -ip -mp1 -m64 -shared-intel' CXX=icpc CXXFLAGS='-O3 -xcore-avx2 -ip -mp1 -m64.
Pre-requisite
Make sure you have Homebrew installed on your Mac. Homebrew is a package manager for macOS. It is in some way similar to package managers in Linux distributions, such as apt-get
and yum
. It's very easy to install, just go to their website and follow the steps.
Remember to run brew update
before you continue.
Installing OpenMP
One thing you should know is that OpenMP is not really a package that you install on your computer. Instead, it's part of the compiler. Therefore, what we need to do is to compile a compiler with OpenMP support. We'll use Homebrew to build the GNU Compiler Collection (GCC) on our Mac from source, with OpenMP support. To do that, type in the following command
Openmp For Mac
If you have installed gcc
before on your Mac using Homebrew, then reinstall it with the following command
According to my experience, it takes about half an hour to one hour to build gcc
since it's quite a large piece of program. Just be patient. After you installed it, you should be able to compile programs with OpenMP support with
Openmpi Macports
Installing MPI
MPI is only an interface. Therefore, there are several MPI implementations, such as MPICH, OpenMPI, and Intel MPI. In this post, we'll install OpenMPI. Here we also want to build it from source because then our MPI compiler is using the gcc
we built just now with OpenMP support. If you installed the binary distribution, it's compiled with clang
without any OpenMP support. To build OpenMPI, type in the following command
Openmpi Machinefile Slots
This command forces Homebrew to build OpenMPI from source with the gcc-6
compiler. (On Mac, the brewed gcc
has the name gcc-6
to avoid name clash with the system link gcc
that is in your Mac)
Now you should have OpenMPI installed on your Mac, with OpenMP support! To compile any MPI programs, just type
1 Known Guides For Building OpenFOAM 2.3.x on Mac OS X. The known guides for building OpenFOAM on Mac OS X are as follows: Available on the forum: Installation notes: OpenFOAM 2.3.x (git repo). Either do 'port install openmpi-mp' or 'port install openmpi-default' Ignore it. Using mpicc and mpicxx wrappers will take care of includes and linking. I have inherited an application with a makefile that supports the use of MPI for parallelization. Toward the end of the make procedure, the make fails due to the mpif90 command not being found. I have installed openmpi-bin (I am using Ubuntu 16.04), but that might have been pointless. Open MPI Mac OS X Package notes: This package was built on a machine running OS X 10.4.9. It should work on any 10.4 machine. The Open MPI tree is installed with a prefix of /usr/local. The Open MPI package is built as a Universal Binary, including support for PPC, PPC64, i386, and x8664 platforms. This package requires a Universal-binary. Stack Overflow Public questions & answers; Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Jobs Programming & related technical career opportunities; Talent Recruit tech talent & build your employer brand; Advertising Reach developers & technologists worldwide; About the company. Using the following command: CC=icc CFLAGS='-O3 -xcore-avx2 -ip -mp1 -m64 -shared-intel' CXX=icpc CXXFLAGS='-O3 -xcore-avx2 -ip -mp1 -m64.
Pre-requisite
Make sure you have Homebrew installed on your Mac. Homebrew is a package manager for macOS. It is in some way similar to package managers in Linux distributions, such as apt-get
and yum
. It's very easy to install, just go to their website and follow the steps.
Remember to run brew update
before you continue.
Installing OpenMP
One thing you should know is that OpenMP is not really a package that you install on your computer. Instead, it's part of the compiler. Therefore, what we need to do is to compile a compiler with OpenMP support. We'll use Homebrew to build the GNU Compiler Collection (GCC) on our Mac from source, with OpenMP support. To do that, type in the following command
Openmp For Mac
If you have installed gcc
before on your Mac using Homebrew, then reinstall it with the following command
According to my experience, it takes about half an hour to one hour to build gcc
since it's quite a large piece of program. Just be patient. After you installed it, you should be able to compile programs with OpenMP support with
Openmpi Macports
Installing MPI
MPI is only an interface. Therefore, there are several MPI implementations, such as MPICH, OpenMPI, and Intel MPI. In this post, we'll install OpenMPI. Here we also want to build it from source because then our MPI compiler is using the gcc
we built just now with OpenMP support. If you installed the binary distribution, it's compiled with clang
without any OpenMP support. To build OpenMPI, type in the following command
Openmpi Machinefile Slots
This command forces Homebrew to build OpenMPI from source with the gcc-6
compiler. (On Mac, the brewed gcc
has the name gcc-6
to avoid name clash with the system link gcc
that is in your Mac)
Now you should have OpenMPI installed on your Mac, with OpenMP support! To compile any MPI programs, just type
Please enable JavaScript to view the comments powered by Disqus.comments powered by Disqus