From 06758fe5cbcbf631959ffc459ccaf372345231cf Mon Sep 17 00:00:00 2001 From: Brian Van Essen Date: Wed, 31 Jan 2018 10:38:53 -0700 Subject: [PATCH] LBANN OS X (#7105) * Added a package for the MDAnalysis toolkit. * Added some flags to fix the build RPATHs and OpenMP for LBANN on OS X. * Fixed Hydrogen branch of Elemental to find OpenMP on OS X. --- var/spack/repos/builtin/packages/cnpy/package.py | 9 +++++++++ .../repos/builtin/packages/elemental/package.py | 10 ++++++++++ .../repos/builtin/packages/lbann/package.py | 16 +++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/cnpy/package.py b/var/spack/repos/builtin/packages/cnpy/package.py index 7c868b62b4..6677d8800c 100644 --- a/var/spack/repos/builtin/packages/cnpy/package.py +++ b/var/spack/repos/builtin/packages/cnpy/package.py @@ -24,6 +24,8 @@ ############################################################################## from spack import * +import sys + class Cnpy(CMakePackage): """cnpy: library to read/write .npy and .npz files in C/C++.""" @@ -32,3 +34,10 @@ class Cnpy(CMakePackage): url = "https://github.com/rogersce/cnpy" version('master', git='https://github.com/rogersce/cnpy.git', branch="master") + + def cmake_args(self): + args = [] + if sys.platform == 'darwin': + args.extend(['-DCMAKE_MACOSX_RPATH=ON']) + + return args diff --git a/var/spack/repos/builtin/packages/elemental/package.py b/var/spack/repos/builtin/packages/elemental/package.py index c661e073cb..2b6de080f6 100644 --- a/var/spack/repos/builtin/packages/elemental/package.py +++ b/var/spack/repos/builtin/packages/elemental/package.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## import os +import sys from spack import * from spack.spec import UnsupportedCompilerError @@ -211,6 +212,15 @@ def cmake_args(self): '-DHydrogen_GENERAL_LAPACK_FALLBACK=ON', ] + # Add support for OS X to find OpenMP + if (self.spec.satisfies('%clang')): + if (sys.platform == 'darwin'): + clang = self.compiler.cc + clang_bin = os.path.dirname(clang) + clang_root = os.path.dirname(clang_bin) + args.extend([ + '-DOpenMP_DIR={0}'.format(clang_root)]) + if 'blas=openblas' in spec: args.extend([ '-DHydrogen_USE_OpenBLAS:BOOL=%s' % ('blas=openblas' in spec), diff --git a/var/spack/repos/builtin/packages/lbann/package.py b/var/spack/repos/builtin/packages/lbann/package.py index 6a32a53d8b..4b1a80c2b5 100644 --- a/var/spack/repos/builtin/packages/lbann/package.py +++ b/var/spack/repos/builtin/packages/lbann/package.py @@ -22,6 +22,8 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## +import os +import sys from spack import * @@ -50,7 +52,7 @@ class Lbann(CMakePackage): values=('Debug', 'Release')) depends_on('elemental +openmp_blas +shared +int64') - depends_on('elemental +openmp_blas +shared +int64 build_type=Debug', + depends_on('elemental +openmp_blas +shared +int64 build_type=Debug', when=('build_type=Debug')) depends_on('cuda', when='+gpu') depends_on('cudnn', when='+gpu') @@ -93,6 +95,18 @@ def cmake_args(self): '-DLBANN_DATATYPE={0}'.format(spec.variants['dtype'].value), '-DLBANN_VERBOSE=0']) + # Add support for OpenMP + if (self.spec.satisfies('%clang')): + if (sys.platform == 'darwin'): + clang = self.compiler.cc + clang_bin = os.path.dirname(clang) + clang_root = os.path.dirname(clang_bin) + args.extend([ + '-DOpenMP_CXX_FLAGS=-fopenmp=libomp', + '-DOpenMP_CXX_LIB_NAMES=libomp', + '-DOpenMP_libomp_LIBRARY={0}/lib/libomp.dylib'.format( + clang_root)]) + if '+opencv' in spec: args.extend(['-DOpenCV_DIR:STRING={0}'.format( spec['opencv'].prefix)])