Difference between revisions of "Building on Mac High Sierra"

From GridPACK
Jump to: navigation, search
(Created page with "== Introduction == This details the building of GridPACK on a Macbook Pro running Mac OS X High Sierra (10.13.6). The build was aided by the use of [https://www.macports.org...")
 
Line 12: Line 12:
  
 
The author uses the C-shell.  These instructions will need to be
 
The author uses the C-shell.  These instructions will need to be
slightly modified to adapt to another shell, like =bash=.
+
slightly modified to adapt to another shell, like <code>bash</code>.
  
 
== MacPorts ==
 
== MacPorts ==
  
The easiest way to get GridPACK going on Mac OS X is to use [[https://www.macports.org/][MacPorts]]
+
The easiest way to get GridPACK going on Mac OS X is to use [https://www.macports.org/ MacPorts]
to install (some of) the needed prerequisite software. [[https://www.macports.org/][MacPorts]] is
+
to install (some of) the needed prerequisite software. [https://www.macports.org/ MacPorts] is
 
free, open source system whereby various software packages can be
 
free, open source system whereby various software packages can be
installed and maintained on a Mac OS X system. [[https://brew.sh/][Homebrew]] provides a
+
installed and maintained on a Mac OS X system. [https://brew.sh/ Homebrew] provides a
 
similar capability, but the authors have no experience with it.
 
similar capability, but the authors have no experience with it.
  
The [[https://www.macports.org/][MacPorts]] project provides very good
+
The [https://www.macports.org/ MacPorts] project provides very good
[[https://www.macports.org/install.php][installation instructions]]. They will not be repeated here.  It is
+
[https://www.macports.org/install.php installation instructions]. They will not be repeated here.  It is
assumed here that  [https://www.macports.org/ MacPorts] was installed in <nowiki>/opt/local</nowiki>, which is the
+
assumed here that  [https://www.macports.org/ MacPorts] was installed in <code>/opt/local</code>, which is the
 
default.   
 
default.   
  
After [https://www.macports.org/ MacPorts] installation, <nowiki>/opt/local/bin</nowiki> needs to be in shell
+
After [https://www.macports.org/ MacPorts] installation, <code>/opt/local/bin</code> needs to be in shell
search path. The easiest way to do this is to add <nowiki>/opt/local/bin</nowiki> to
+
search path. The easiest way to do this is to add <code>/opt/local/bin</code> to
the top of <nowiki>/etc/paths</nowiki> (superuser privileges required).  Afterward, a reboot or
+
the top of <code>/etc/paths</code> (superuser privileges required).  Afterward, a reboot or
starting a new shell should make the <nowiki>port</nowiki> command available on the
+
starting a new shell should make the <code>port</code> command available on the
 
command line.
 
command line.
  
Line 45: Line 45:
 
  sudo port select --set mpi mpich-clang60-fortran
 
  sudo port select --set mpi mpich-clang60-fortran
  
That way the compiler commands, <nowiki>clang</nowiki> and <nowiki>clang++</nowiki>, and MPI compiler
+
That way the compiler commands, <code>clang</code> and <code>clang++</code>, and MPI compiler
wrappers, like <nowiki>mpicc</nowiki>, will be available at the command line.  
+
wrappers, like <code>mpicc</code>, will be available at the command line.  
  
 
Install CMake and the GNU linear programming kit:
 
Install CMake and the GNU linear programming kit:
Line 56: Line 56:
  
 
[http://www.mcs.anl.gov/petsc/ PETSc] and [http://www.emsl.pnl.gov/docs/global/ Global Arrays] need to be built from source.  You need to
 
[http://www.mcs.anl.gov/petsc/ PETSc] and [http://www.emsl.pnl.gov/docs/global/ Global Arrays] need to be built from source.  You need to
choose a path in which packages will be installed.
+
choose a path in which packages will be installed.  Here the author
 +
decided to use <code>$HOME/gridpack</code> as an installation directory. 
 +
 
 +
=== PETSc, version 3.8.4 ===
 +
 
 +
Download the [http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.8.4.tar.gz PETSc source]. It is recommended to unpack this in the
 +
installation directory (<code>$HOME/gridpack</code>).  Configure and build [http://www.mcs.anl.gov/petsc/ PETSc]
 +
using
 +
 
 +
setenv PETSC_DIR $HOME/gridpack/petsc-3.8.4
 +
unsetenv PETSC_ARCH
 +
./configure \
 +
    PETSC_ARCH=arch-macosx-clang-real-opt \
 +
    COPTFLAGS="-g -O2" \
 +
    CXXOPTFLAGS="-g -O2" \
 +
    FOPTFLAGS="-g -O2" \
 +
    --with-prefix="/Users/d3g096/Projects/GridPACK" \
 +
    --with-mpi=1 \
 +
    --with-gnu-compilers=0 \
 +
    --with-cc=/opt/local/bin/mpicc \
 +
    --with-fc=/opt/local/bin/mpif90 \
 +
    --with-cxx=/opt/local/bin/mpicxx \
 +
    --with-clanguage=c++ \
 +
    --with-fortran-bindings=0 \
 +
    --with-scalar-type=real \
 +
    --with-precision=double \
 +
    --download-suitesparse=1 \
 +
    --download-superlu_dist=1 \
 +
    --download-parmetis=1 \
 +
    --download-metis=1 \
 +
    --download-f2cblaslapack=1 \
 +
    --download-mumps=0 \
 +
    --download-scalapack=1 \
 +
    --with-shared-libraries=0 \
 +
    --with-x=0 \
 +
    --with-valgrind=0 \
 +
    --with-mpiexec=mpiexec \
 +
    --with-debugging=0
 +
make PETSC_DIR=$HOME/gridpack/petsc-3.8.4 PETSC_ARCH=arch-macosx-clang-real-opt all
 +
make PETSC_DIR=$HOME/gridpack/petsc-3.8.4 PETSC_ARCH=arch-macosx-clang-real-opt test
 +
 
 +
 
 +
=== Global Arrays, version 5.7 ===
 +
 
 +
Download the source from [https://github.com/GlobalArrays/ga/releases/download/v5.7/ga-5.7.tar.gz here] and unpack in a convenient location.  In
 +
the unpacked directory, configure, build, and install  [[http://www.emsl.pnl.gov/docs/global/][Global Arrays]] like this
 +
 
 +
mkdir build
 +
cd build
 +
../configure \
 +
    --enable-cxx \
 +
    --disable-f77 \
 +
    --enable-i4 \
 +
    --with-mpi \
 +
    --with-mpi-ts \
 +
    --enable-autodetect=yes \
 +
    --prefix="$HOME/gridpack" \
 +
    --without-blas \
 +
    --without-lapack \
 +
    --without-scalapack \
 +
    --enable-shared=no \
 +
    --enable-static=yes \
 +
    MPICC=mpicc MPICXX=mpicxx MPIF77=mpif90 \
 +
    MPIEXEC=mpiexec MPIRUN=mpirun \
 +
    LDFLAGS="-L/opt/local/lib"
 +
make
 +
make install
 +
 
 +
=== GridPACK ===
 +
 
 +
CMake will work very hard to choose the wrong compiler. Make sure it
 +
uses the correct compiler by setting environment variables as follows:
 +
 
 +
setenv CC /opt/local/bin/clang
 +
setenv CXX /opt/local/bin/clang++
 +
 
 +
Configure, build, and test GridPACK with
 +
 
 +
 
 +
rm -rf CMake*
 +
cmake \
 +
    -D GA_DIR:STRING="$HOME/gridpack" \
 +
    -D BOOST_ROOT:STRING="/opt/local" \
 +
    -D PETSC_DIR:PATH="$HOME/gridpack/petsc-3.8.4" \
 +
    -D PETSC_ARCH:STRING="arch-macosx-clang-real-opt" \
 +
    -D MPI_CXX_COMPILER:STRING='/opt/local/bin/mpicxx' \
 +
    -D MPI_C_COMPILER:STRING='/opt/local/bin/mpicc' \
 +
    -D MPIEXEC:STRING='/opt/local/bin/mpiexec' \
 +
    -D MPIEXEC_MAX_NUMPROCS:STRING="2" \
 +
    -D GRIDPACK_TEST_TIMEOUT:STRING=30 \
 +
    -D USE_GLPK:BOOL=ON \
 +
    -D GLPK_ROOT_DIR:PATH="/opt/local" \
 +
    -D CMAKE_INSTALL_PREFIX:PATH="$HOME/gridpack" \
 +
    ..
 +
make
 +
make test
 +
 
 +
 
 +
== Observations ==
 +
 
 +
It appears that at the time of writing the OpenMPI ports are not Boost
 +
or PETSc compatible.  Stick with mpich. 
 +
 
 +
Boost.MPI compiled with the stock [https://en.wikipedia.org/wiki/Xcode XCode] C++ compiler seems to have trouble
 +
with serialization needed in the GridPACK code. This may or may not be
 +
a real issue. Little effort was expended to track it down, since
 +
Boost.MPI appears to work fine on Mac OS X if compiled with another
 +
CLang-based compiler.
 +
 
 +
[https://www.macports.org/ MacPorts] does have a [http://www.mcs.anl.gov/petsc/ PETSc] package, but it will not work for GridPACK
 +
because it does not have the required C++ support built in. 
 +
 
 +
PETSc must be later than 3.8.  Versions 3.7.x do not configure
 +
properly with up to date XCode. This is a [https://lists.mcs.anl.gov/pipermail/petsc-users/2017-March/032042.html known issue] that was fixed
 +
in 3.8.x.

Revision as of 15:58, 12 September 2018

Introduction

This details the building of GridPACK on a Macbook Pro running Mac OS X High Sierra (10.13.6). The build was aided by the use of MacPorts to install some prerequisite software. Super user permissions are required to install and manage MacPorts.

These instructions use a specific combination of compilers, MPI implementation, and MacPorts packages. Other combinations can be used, the one here happened to work for the author. If you choose some other combination, you're on your own.

The author uses the C-shell. These instructions will need to be slightly modified to adapt to another shell, like bash.

MacPorts

The easiest way to get GridPACK going on Mac OS X is to use MacPorts to install (some of) the needed prerequisite software. MacPorts is free, open source system whereby various software packages can be installed and maintained on a Mac OS X system. Homebrew provides a similar capability, but the authors have no experience with it.

The MacPorts project provides very good installation instructions. They will not be repeated here. It is assumed here that MacPorts was installed in /opt/local, which is the default.

After MacPorts installation, /opt/local/bin needs to be in shell search path. The easiest way to do this is to add /opt/local/bin to the top of /etc/paths (superuser privileges required). Afterward, a reboot or starting a new shell should make the port command available on the command line.

Packages from MacPorts

Install the CLang 6.0 compiler set, mpich MPI implementation, and Boost with Boost.MPI using the following:

sudo port install boost +clang60+mpich

Make the installed compilers and MPI wrappers the default.

sudo port select --set clang mp-clang-6.0
sudo port select --set mpi mpich-clang60-fortran

That way the compiler commands, clang and clang++, and MPI compiler wrappers, like mpicc, will be available at the command line.

Install CMake and the GNU linear programming kit:

sudo port install cmake
sudo port install glpk

Build Packages from Source

PETSc and Global Arrays need to be built from source. You need to choose a path in which packages will be installed. Here the author decided to use $HOME/gridpack as an installation directory.

PETSc, version 3.8.4

Download the PETSc source. It is recommended to unpack this in the installation directory ($HOME/gridpack). Configure and build PETSc using

setenv PETSC_DIR $HOME/gridpack/petsc-3.8.4
unsetenv PETSC_ARCH
./configure \
   PETSC_ARCH=arch-macosx-clang-real-opt \
   COPTFLAGS="-g -O2" \
   CXXOPTFLAGS="-g -O2" \
   FOPTFLAGS="-g -O2" \
   --with-prefix="/Users/d3g096/Projects/GridPACK" \
   --with-mpi=1 \
   --with-gnu-compilers=0 \
   --with-cc=/opt/local/bin/mpicc \
   --with-fc=/opt/local/bin/mpif90 \
   --with-cxx=/opt/local/bin/mpicxx \
   --with-clanguage=c++ \
   --with-fortran-bindings=0 \
   --with-scalar-type=real \
   --with-precision=double \
   --download-suitesparse=1 \
   --download-superlu_dist=1 \
   --download-parmetis=1 \
   --download-metis=1 \
   --download-f2cblaslapack=1 \
   --download-mumps=0 \
   --download-scalapack=1 \
   --with-shared-libraries=0 \
   --with-x=0 \
   --with-valgrind=0 \
   --with-mpiexec=mpiexec \
   --with-debugging=0 
make PETSC_DIR=$HOME/gridpack/petsc-3.8.4 PETSC_ARCH=arch-macosx-clang-real-opt all
make PETSC_DIR=$HOME/gridpack/petsc-3.8.4 PETSC_ARCH=arch-macosx-clang-real-opt test


Global Arrays, version 5.7

Download the source from here and unpack in a convenient location. In the unpacked directory, configure, build, and install [[1][Global Arrays]] like this

mkdir build
cd build
../configure \
   --enable-cxx \
   --disable-f77 \
   --enable-i4 \
   --with-mpi \
   --with-mpi-ts \
   --enable-autodetect=yes \
   --prefix="$HOME/gridpack" \
   --without-blas \
   --without-lapack \
   --without-scalapack \
   --enable-shared=no \
   --enable-static=yes \
   MPICC=mpicc MPICXX=mpicxx MPIF77=mpif90 \
   MPIEXEC=mpiexec MPIRUN=mpirun \
   LDFLAGS="-L/opt/local/lib"
make
make install

GridPACK

CMake will work very hard to choose the wrong compiler. Make sure it uses the correct compiler by setting environment variables as follows:

setenv CC /opt/local/bin/clang
setenv CXX /opt/local/bin/clang++

Configure, build, and test GridPACK with


rm -rf CMake*
cmake \
   -D GA_DIR:STRING="$HOME/gridpack" \
   -D BOOST_ROOT:STRING="/opt/local" \
   -D PETSC_DIR:PATH="$HOME/gridpack/petsc-3.8.4" \
   -D PETSC_ARCH:STRING="arch-macosx-clang-real-opt" \
   -D MPI_CXX_COMPILER:STRING='/opt/local/bin/mpicxx' \
   -D MPI_C_COMPILER:STRING='/opt/local/bin/mpicc' \
   -D MPIEXEC:STRING='/opt/local/bin/mpiexec' \
   -D MPIEXEC_MAX_NUMPROCS:STRING="2" \
   -D GRIDPACK_TEST_TIMEOUT:STRING=30 \
   -D USE_GLPK:BOOL=ON \
   -D GLPK_ROOT_DIR:PATH="/opt/local" \
   -D CMAKE_INSTALL_PREFIX:PATH="$HOME/gridpack" \
   ..
make
make test


Observations

It appears that at the time of writing the OpenMPI ports are not Boost or PETSc compatible. Stick with mpich.

Boost.MPI compiled with the stock XCode C++ compiler seems to have trouble with serialization needed in the GridPACK code. This may or may not be a real issue. Little effort was expended to track it down, since Boost.MPI appears to work fine on Mac OS X if compiled with another CLang-based compiler.

MacPorts does have a PETSc package, but it will not work for GridPACK because it does not have the required C++ support built in.

PETSc must be later than 3.8. Versions 3.7.x do not configure properly with up to date XCode. This is a known issue that was fixed in 3.8.x.