Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/tutorials/exp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ Here is another recipe using modules that has been found to work on Flatiron Ins

EXP also builds on Mac by installing the dependencies with Homebrew::

brew install cmake eigen@3 fftw hdf5 open-mpi git ninja
brew install cmake eigen@3 fftw hdf5 open-mpi git ninja libomp

Note that building Gala-EXP requires OpenMP support. The Apple Clang compiler shipped
with macOS does not support ``-fopenmp`` directly, but Gala's build system will
automatically use the correct flags (``-Xpreprocessor -fopenmp`` with ``libomp`` from
Homebrew). This works with both Apple Clang and LLVM Clang from Homebrew.

By default, the build expects ``libomp`` at ``/opt/homebrew/opt/libomp``. If it is
installed elsewhere, set the ``LIBOMP_PREFIX`` environment variable::

export LIBOMP_PREFIX=/path/to/libomp

Installing ``llvm`` from Homebrew is not required for building Gala, but may be needed
for building EXP itself.

After installing the dependencies, one can download and build EXP on Linux with::

Expand Down
17 changes: 15 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,21 @@ def base_cfg():
if extra_incl_flags is not None:
ext.extra_compile_args.extend(extra_incl_flags)

ext.extra_compile_args.extend(["-fopenmp"])
ext.extra_link_args.extend(["-fopenmp"])
# OpenMP support: macOS with Apple Clang requires different flags
if sys.platform == "darwin":
# Apple Clang doesn't support -fopenmp directly; use
# -Xpreprocessor -fopenmp with libomp from Homebrew. This also
# works with LLVM Clang from Homebrew.
libomp_prefix = os.environ.get(
"LIBOMP_PREFIX", "/opt/homebrew/opt/libomp"
)
ext.include_dirs.append(os.path.join(libomp_prefix, "include"))
ext.library_dirs.append(os.path.join(libomp_prefix, "lib"))
ext.extra_compile_args.extend(["-Xpreprocessor", "-fopenmp"])
ext.extra_link_args.extend(["-lomp"])
else:
ext.extra_compile_args.extend(["-fopenmp"])
ext.extra_link_args.extend(["-fopenmp"])

if "exp" not in ext.libraries:
ext.libraries.extend(
Expand Down
Loading