DedalusProject / dedalus

A flexible framework for solving PDEs with modern spectral methods.
http://dedalus-project.org/
GNU General Public License v3.0
489 stars 115 forks source link

A brief guide to compile from source on apple silicon (M1, M2, M3) #283

Open deKeijzer opened 6 months ago

deKeijzer commented 6 months ago

Hi there,

Perhaps this will help someone out. To compile dedalus from source using

CC=mpicc pip3 install --upgrade --force-reinstall --no-deps --no-cache --no-build-isolation http://github.com/dedalusproject/dedalus/zipball/master/

as stated in the docs, might results in an error

...mpicc -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g -I/usr/local/opt/llvm/include -I/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mpi4py/include -I/opt/homebrew/opt/open-mpi/include -Idedalus/libraries/fftw/ -I/opt/homebrew/opt/fftw/include -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c dedalus/core/transposes.c -o build/temp.macosx-10.9-universal2-cpython-312/dedalus/core/transposes.o -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -Wno-unused-function -fopenmp
      clang: error: unsupported option '-fopenmp'
      clang: error: unsupported option '-fopenmp'
      error: command '/opt/homebrew/bin/mpicc' failed with exit code 1
      [end of output]...

This is solved by using gcc instead of mpi;

briandekeijzer@MacBook-Pro build % brew install gcc

==> Downloading https://formulae.brew.sh/api/formula.jws.json
##O=- #      #                                                                                                                                                                                                        
==> Downloading https://formulae.brew.sh/api/cask.jws.json

Warning: gcc 13.2.0 is already installed and up-to-date.
To reinstall 13.2.0, run:
  brew reinstall gcc
briandekeijzer@MacBook-Pro build % export CC=/opt/homebrew/bin/gcc-13
export CXX=/opt/homebrew/bin/g++-13

Then specifically compile with gcc-version_number

CC=gcc-13 pip3 install --upgrade --force-reinstall --no-deps --no-cache --no-build-isolation http://github.com/dedalusproject/dedalus/zipball/master/

This allows for compilation fo Dedalus on Apple silicon with the latest Python version.

Have fun simulating!