Skip to content

MDAnalysis⚓︎

OpenMP on macOS⚓︎

Apple's Clang compiler does not support OpenMP, and g++ on macOS is an alias for clang++. Therefore, compiling a simple OpenMP program with g++ -fopenmp fails on macOS.

clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
Simple OpenMP program
#include <omp.h>

int main(void) {
    omp_get_num_threads();
}

g++ on macOS is an alias for clang++.

OpenMP Support with GCC⚓︎

In order to use OpenMP on macOS, one needs to install gcc, for example via Homebrew.

brew install gcc

MDAnalysis can then be installed with OpenMP support as follows:

CC=gcc-11 CXX=g++-11 pip install -e package

Disabling OpenMP Support⚓︎

OpenMP support can be explicitly disabled with

MDA_USE_OPENMP=FALSE CC=gcc-11 CXX=g++-11 pip install -e package