SpECTRE Documentation Coverage Report
Current view: top level - __w/spectre/spectre/docs/Installation - InstallationOnAppleSilicon.md Hit Total Coverage
Commit: b5f497991094937944b0a3f519166bb54739d08a Lines: 0 1 0.0 %
Date: 2024-03-28 18:20:13
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : \cond NEVER
       2             : Distributed under the MIT License.
       3             : See LICENSE.txt for details.
       4             : \endcond
       5             : ## Installing SpECTRE on Apple Silicon {#installation_on_apple_silicon}
       6             : 
       7             : \tableofcontents
       8             : 
       9             : The following instructions show how to install SpECTRE and its dependencies
      10             : on Apple Silicon Macs. Apple Silicon is an arm64 architecture, in contrast
      11             : to the x86-64 architecture that SpECTRE usually targets. These instructions
      12             : will result in an Apple Silicon native build of SpECTRE.
      13             : 
      14             : \note Floating-point exception trapping is not currently
      15             : supported on Apple Silicon.
      16             : 
      17             : ### 0. Install the xcode command-line tools.
      18             : 
      19             : Install the xcode command-line tools, which include the clang compiler, etc.
      20             : Run the following command in the terminal:
      21             : 
      22             : ```
      23             : xcode-select --install
      24             : ```
      25             : 
      26             : ### 1. Clone spectre and make a directory to install prerequisites
      27             : 
      28             : First, make a directory to hold some prerequisites that spectre depends on.
      29             : Name this directory whatever you like, and set `SPECTRE_DEPS_ROOT` to its value.
      30             : These instructions, as an example, set this to the `apps` directory in the
      31             : user's home folder.
      32             : ```
      33             : cd $HOME
      34             : git clone git@github.com:sxs-collaboration/spectre.git
      35             : cd spectre
      36             : export SPECTRE_HOME=$(pwd)
      37             : export SPECTRE_DEPS_ROOT=$HOME/apps
      38             : mkdir $SPECTRE_DEPS_ROOT
      39             : cd $SPECTRE_DEPS_ROOT
      40             : mkdir src
      41             : cd src
      42             : ```
      43             : 
      44             : ### 2. Install python dependencies
      45             : 
      46             : Spectre depends on python and some python packages. There are different ways to
      47             : install an arm64-native python stack. The following instructions show how
      48             : to do this using the Python 3 interpreter bundled with macOS.
      49             : 
      50             : ```sh
      51             : cd $SPECTRE_HOME
      52             : 
      53             : # Create a Python environment
      54             : python3 -m venv ./env --upgrade-deps
      55             : 
      56             : # Activate the Python environment
      57             : . ./env/bin/activate
      58             : 
      59             : # Install Python packages
      60             : pip install -r support/Python/requirements.txt \
      61             :   -r support/Python/dev_requirements.txt
      62             : 
      63             : # Optionally install additional packages you might want, like Jupyter
      64             : pip install jupyterlab
      65             : ```
      66             : 
      67             : ### 3. Install dependencies with Homebrew
      68             : 
      69             : Most of spectre's dependencies beyond python can be installed using the
      70             : [homebrew](https://brew.sh) package manager. First, if you haven't
      71             : already, install Homebrew by
      72             : following the instructions on the [homebrew](https://brew.sh) homepage. Then,
      73             : run the following to install a fortran compiler and other dependencies:
      74             : ```
      75             : brew install gcc
      76             : brew install boost gsl cmake doxygen catch2
      77             : brew install ccache autoconf automake jemalloc hdf5 pybind11 yaml-cpp
      78             : ```
      79             : 
      80             : ### 4. Install remaining dependencies
      81             : 
      82             : Here, install the remaining dependencies that cannot be installed
      83             : with homebrew or miniforge. You can install them from source manually, or use
      84             : the [Spack](https://github.com/spack/spack) package manager.
      85             : 
      86             : #### Install manually
      87             : 
      88             : ```
      89             : export SPECTRE_DEPS_ROOT=$HOME/apps
      90             : ```
      91             : 
      92             : ```
      93             : cd $SPECTRE_DEPS_ROOT
      94             : mkdir blaze
      95             : pushd blaze
      96             : curl -L https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.8.tar.gz \
      97             : > blaze-3.8.tar.gz
      98             : tar -xf blaze-3.8.tar.gz
      99             : mv blaze-3.8 include
     100             : popd
     101             : 
     102             : git clone https://github.com/edouarda/brigand.git
     103             : 
     104             : # Need master branch of libxsmm to support Apple Silicon
     105             : git clone https://github.com/hfp/libxsmm.git
     106             : pushd libxsmm
     107             : make
     108             : popd
     109             : 
     110             : pushd ./src
     111             : git clone https://github.com/Libsharp/libsharp.git
     112             : cd libsharp
     113             : 
     114             : # Do not use compiler flag -march=native (unsupported on Apple Silicon)
     115             : sed "s/-march=native//" configure.ac > configure.ac.mod
     116             : mv configure.ac.mod configure.ac
     117             : 
     118             : autoupdate
     119             : autoconf
     120             : ./configure
     121             : make
     122             : mv auto $SPECTRE_DEPS_ROOT/libsharp
     123             : popd
     124             : ```
     125             : 
     126             : Next, clone, patch, and install charm++ v7.0.0.
     127             : ```
     128             : git clone https://github.com/UIUC-PPL/charm
     129             : pushd charm
     130             : git checkout v7.0.0
     131             : ./build LIBS multicore-darwin-arm8 --with-production -g3 -j
     132             : popd
     133             : ```
     134             : 
     135             : #### Install with Spack
     136             : 
     137             : ```sh
     138             : # Download spack
     139             : cd ~
     140             : git clone -c feature.manyFiles=true https://github.com/spack/spack.git
     141             : cd spack
     142             : # Switch to latest release
     143             : git checkout releases/latest
     144             : # Load shell support
     145             : . ./share/spack/setup-env.sh
     146             : # Find some system packages so we don't have to install them all from source
     147             : spack external find
     148             : spack external find python
     149             : # Install dependencies
     150             : spack install \
     151             :   blaze@3.8.2 \
     152             :   brigand@master \
     153             :   charmpp@7.0.0: backend=multicore \
     154             :   libxsmm@main \
     155             :   libsharp~mpi~openmp
     156             : ```
     157             : 
     158             : ### 5. Configure and build SpECTRE
     159             : 
     160             : Create a build directory in a location of your choice, e.g.
     161             : ```
     162             : cd ${SPECTRE_HOME}
     163             : mkdir build
     164             : cd build
     165             : ```
     166             : 
     167             : Next, configure SpECTRE using the following CMake command. If you installed
     168             : dependencies with Spack, you can use `spack find -p` to retrieve the root
     169             : directories of the packages and replace them in the command below.
     170             : 
     171             : ```
     172             : cmake \
     173             : -D CMAKE_C_COMPILER=clang \
     174             : -D CMAKE_CXX_COMPILER=clang++ \
     175             : -D CMAKE_Fortran_COMPILER=gfortran \
     176             : -D CMAKE_BUILD_TYPE=Debug \
     177             : -D BUILD_SHARED_LIBS=OFF \
     178             : -D MEMORY_ALLOCATOR=SYSTEM \
     179             : -D CHARM_ROOT=${SPECTRE_DEPS_ROOT}/charm/multicore-darwin-arm8 \
     180             : -D SPECTRE_TEST_TIMEOUT_FACTOR=5 \
     181             : -D LIBXSMM_ROOT=${SPECTRE_DEPS_ROOT}/libxsmm/ \
     182             : -D BLAZE_ROOT=${SPECTRE_DEPS_ROOT}/blaze/ \
     183             : -D BRIGAND_ROOT=${SPECTRE_DEPS_ROOT}/brigand/ \
     184             : -D LIBSHARP_ROOT=${SPECTRE_DEPS_ROOT}/libsharp/ \
     185             : ..
     186             : ```
     187             : 
     188             : Finally, build and test SpECTRE. E.g., on a Mac with 10 cores,
     189             : ```
     190             : make -j10 unit-tests
     191             : make -j10 test-executables
     192             : ctest --output-on-failure -j10
     193             : ```

Generated by: LCOV version 1.14