Difference between revisions of "Building on Mac Yosemite"

From GridPACK
Jump to: navigation, search
(Building Global Arrays)
(Preparation)
Line 3: Line 3:
 
== Preparation ==
 
== Preparation ==
  
Create a suitable directory where GridPACK and related packages can be built and resulting binaries installed.  Herein, this directory is referred to as <code>$prefix</code>. In my case it was <code>~/Projects/GridPACK</code>. Adjust this to your personal set up.  
+
Create a suitable directory where GridPACK and related packages can be built and resulting binaries installed.  Herein, this directory is referred to as <code>$prefix</code>. In my case it was <code>~/Projects/GridPACK</code>. Adjust this to your personal set up. Also, the C-shell is used herein; some of the commands may need adjustment if another shell is used.
 
 
  
 
== Compiler Set ==
 
== Compiler Set ==

Revision as of 19:27, 10 February 2017

This system is a relatively new Mac Pro with Mac OS X 10.10 (Yosemite). The previous instructions for Mac OS X are really not helpful anymore due to changes in the OS.

Preparation

Create a suitable directory where GridPACK and related packages can be built and resulting binaries installed. Herein, this directory is referred to as $prefix. In my case it was ~/Projects/GridPACK. Adjust this to your personal set up. Also, the C-shell is used herein; some of the commands may need adjustment if another shell is used.

Compiler Set

Mac system do not have a compiler out of the box. To get the stock Apple compiler set (LLVM), XTools must be installed. Here is a good guide.

Care must be taken to use a consistent compiler set when building GridPACK. GridPACK is a C++ code. Mac OS X provides two standard C++ libraries on modern systems: libc++ (the one Apple wants to support), and libstdc++ (that will be phased out). The stock LLVM C++ compiler will use libc++. GNU compilers, if installed, will use libstdc++. If C++ objects from GNU compilers are mixed with the system compiler, they will not link together, because of conflicting and/or missing symbols from the standard library. This gets complicated. The best thing to do is just use the same compilers to build GridPACK and any prerequisites.

In addition, there were some other problems had while getting this to work:

  • Boost.MPI compiled with the stock LLVM compiler seemed to have trouble with serialization needed in the GridPACK code. This may or may not be a real issue. After the trouble was encountered, the CLang compilers were chosen and used there after. (NOTE: Boost does not report Boost.MPI unit test results for LLVM or CLang compilers on any platform).
  • Global Arrays 5.5 does not appear to work with LLVM or CLang, but the SVN trunk version does. Neither version worked as shared libraries, so GA must be built static.

After a couple of aborted starts with the LLVM compiler, CLang 3.8 (installed with MacPorts) was chosen, and, after some effort, it built GridPACK. GNU C++ should be avoid.

MacPorts

The CLang compiler set and some of the prerequisite software was installed on this system using MacPorts. Several necessary packages were installed by

   sudo port install boost boost @1.59.0_2+clang38+no_single-no_static+openmpi+python27

Note that the openmpi Boost variant was installed. This will install the CLang compiler set and OpenMPI. It's a good idea to install the select packages for CLang and MPI and make sure the right versions are "selected":

   sudo port install mpi_select clang_select
   sudo port select --set mpi openmpi-clang38-fortran
   sudo port select --set clang mp-clang-3.8

The following ports were installed:

 cmake @3.7.2_0+docs+gui+python27+qt4 (active)
 boost @1.59.0_2+clang38+no_single+openmpi+python27 (active)
 OpenBLAS @0.2.19_0+clang+lapack (active)
 doxygen @1.8.13_2+qt4+wizard (active)
 graphviz @2.40.1_1+pangocairo+x11 (active)

OpenBLAS was chosen in an attempt to be compatible with [1]. Doxygen and Graphviz are optional.

Building PETSc

PETSc 3.7.4 source was downloaded and unpacked in $prefix. It was then configured and built as follows:

   setenv PETSC_DIR "$prefix/petsc-3.7.4"
   unsetenv PETSC_ARCH
   ./configure \
       PETSC_ARCH=arch-macosx-clang-real-opt \
       COPTFLAGS="-O3" \
       CXXOPTFLAGS="-O3" \
       FOPTFLAGS="-O3" \
       --with-prefix="$prefix" \
       --with-mpi=1 \
       --with-cc=/opt/local/bin/mpicc \
       --with-fc=/opt/local/bin/mpif90 \
       --with-cxx=/opt/local/bin/mpicxx \
       --with-clanguage=c++ \
       --with-c++-support=1 \
       --with-c-support=0 \
       --with-fortran=0 \
       --with-scalar-type=real \
       --with-precision=double \
       --with-fortran-kernels=generic \
       --with-valgrind=0 \
       --with-blas-lapack-lib="/opt/local/lib/libopenblas.a" \
       --download-suitesparse=1 \
       --download-superlu_dist=1 \
       --download-parmetis=1 \
       --download-metis=1 \
       --download-f2cblaslapack=0 \
       --download-mumps=0 \
       --download-scalapack=0 \
       --with-shared-libraries=0 \
       --with-x=0 \
       --with-mpirun=mpiexec \
       --with-mpiexec=mpiexec \
       --with-debugging=0
   make PETSC_DIR=/Users/d3g096/Projects/GridPACK/petsc-3.7.4 PETSC_ARCH=arch-macosx-clang-real-opt all

Here, OpenBLAS, installed with MacPorts, was used for BLAS and LAPACK. Other packages (ParMETIS, SuperLU_DIST, etc.) were downloaded and built by the PETSc configuration.

It is possible to use the MacPorts PETSc package for GridPACK. I does not include SuperLU_DIST, however. This is left as an exercise for the reader.

Building Global Arrays

The trunk SVN version of Arrays is required here. Get the code using

 svn checkout https://svn.pnl.gov/svn/hpctools/trunk/ga $prefix/ga-svn
 cd $prefix/ga-svn

Configure, build, and install:

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

I had trouble using shared GA libraries, so only static libraries should be built. Version 5.5 did not work (some problem with process groups).

Building and Testing GridPACK

CMake projects are designed to be built outside of the source code location. If the entire GridPACK {{{trunk}}} repository is checked out, the top of the the CMake project is {{{.../src}}}. Make a subdirectory there called {{{build}}} or something. Configure and build GridPACK in that directory.