From b079e1dbd56670514a312fbad4dd8e62f1e9ddcd Mon Sep 17 00:00:00 2001 From: Cyrus Harrison Date: Fri, 10 Nov 2017 17:00:47 -0800 Subject: add alpine ascent (#6224) * add ascent package and and deps * proper use of site_packages_dir prop * flake8 * add maitain, small updates * flake8 * flake8 * fixs for docstrings for sphinx --- var/spack/repos/builtin/packages/ascent/package.py | 333 +++++++++++++++++++++ .../repos/builtin/packages/conduit/package.py | 18 +- .../repos/builtin/packages/intel-tbb/package.py | 3 + .../packages/intel-tbb/tbb_gcc_rtm_key.patch | 23 ++ var/spack/repos/builtin/packages/vtkh/package.py | 97 ++++++ var/spack/repos/builtin/packages/vtkm/package.py | 83 +++++ 6 files changed, 551 insertions(+), 6 deletions(-) create mode 100644 var/spack/repos/builtin/packages/ascent/package.py create mode 100644 var/spack/repos/builtin/packages/intel-tbb/tbb_gcc_rtm_key.patch create mode 100644 var/spack/repos/builtin/packages/vtkh/package.py create mode 100644 var/spack/repos/builtin/packages/vtkm/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/ascent/package.py b/var/spack/repos/builtin/packages/ascent/package.py new file mode 100644 index 0000000000..854bf1e909 --- /dev/null +++ b/var/spack/repos/builtin/packages/ascent/package.py @@ -0,0 +1,333 @@ +############################################################################## +# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/spack/spack +# Please also see the NOTICE and LICENSE files for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## + + +from spack import * + +import socket +import os + +import llnl.util.tty as tty +from os import environ as env + + +def cmake_cache_entry(name, value): + """ + Helper that creates CMake cache entry strings used in + 'host-config' files. + """ + return 'set({0} "{1}" CACHE PATH "")\n\n'.format(name, value) + + +class Ascent(Package): + """Ascent is an open source many-core capable lightweight in situ + visualization and analysis infrastructure for multi-physics HPC + simulations.""" + + homepage = "https://github.com/Alpine-DAV/ascent" + url = "https://github.com/Alpine-DAV/ascent" + + maintainers = ['cyrush'] + + version('develop', + git='https://github.com/Alpine-DAV/ascent.git', + branch='develop', + submodules=True) + + ########################################################################### + # package variants + ########################################################################### + + variant("shared", default=True, description="Build Conduit as shared libs") + + variant("cmake", default=True, + description="Build CMake (if off, attempt to use cmake from PATH)") + + variant("mpi", default=True, description="Build Ascent MPI Support") + + # variants for python support + variant("python", default=True, description="Build Conduit Python support") + + # variants for runtime features + + variant("vtkh", default=True, + description="Build VTK-h filter and rendering support") + + variant("tbb", default=True, description="Build tbb support") + variant("cuda", default=False, description="Build cuda support") + + variant("adios", default=True, description="Build Adios filter support") + + # variants for dev-tools (docs, etc) + variant("doc", default=False, description="Build Conduit's documentation") + + ########################################################################### + # package dependencies + ########################################################################### + + depends_on("cmake", when="+cmake") + depends_on("conduit") + + ####################### + # Python + ####################### + # we need a shared version of python b/c linking with static python lib + # causes duplicate state issues when running compiled python modules. + depends_on("python+shared") + extends("python", when="+python") + # TODO: blas and lapack are disabled due to build + # issues Cyrus experienced on OSX 10.11.6 + depends_on("py-numpy~blas~lapack", when="+python", type=('build', 'run')) + + ####################### + # MPI + ####################### + depends_on("mpi", when="+mpi") + depends_on("py-mpi4py", when="+python+mpi") + + ############################# + # TPLs for Runtime Features + ############################# + + depends_on("vtkh", when="+vtkh") + depends_on("vtkh+cuda", when="+vtkh+cuda") + depends_on("adios", when="+adios") + + ####################### + # Documentation related + ####################### + depends_on("py-sphinx", when="+python+doc", type='build') + + def install(self, spec, prefix): + """ + Build and install Conduit. + """ + with working_dir('spack-build', create=True): + host_cfg_fname = self.create_host_config(spec, prefix) + cmake_args = [] + # if we have a static build, we need to avoid any of + # spack's default cmake settings related to rpaths + # (see: https://github.com/LLNL/spack/issues/2658) + if "+shared" in spec: + cmake_args.extend(std_cmake_args) + else: + for arg in std_cmake_args: + if arg.count("RPATH") == 0: + cmake_args.append(arg) + cmake_args.extend(["-C", host_cfg_fname, "../src"]) + cmake(*cmake_args) + make() + make("install") + # TODO also copy host_cfg_fname into install + + def create_host_config(self, spec, prefix): + """ + This method creates a 'host-config' file that specifies + all of the options used to configure and build ascent. + """ + + ####################### + # Compiler Info + ####################### + c_compiler = env["SPACK_CC"] + cpp_compiler = env["SPACK_CXX"] + f_compiler = None + + if self.compiler.fc: + # even if this is set, it may not exist so do one more sanity check + if os.path.isfile(env["SPACK_FC"]): + f_compiler = env["SPACK_FC"] + + ####################################################################### + # By directly fetching the names of the actual compilers we appear + # to doing something evil here, but this is necessary to create a + # 'host config' file that works outside of the spack install env. + ####################################################################### + + sys_type = spec.architecture + # if on llnl systems, we can use the SYS_TYPE + if "SYS_TYPE" in env: + sys_type = env["SYS_TYPE"] + + ############################################## + # Find and record what CMake is used + ############################################## + + if "+cmake" in spec: + cmake_exe = spec['cmake'].command.path + else: + cmake_exe = which("cmake") + if cmake_exe is None: + msg = 'failed to find CMake (and cmake variant is off)' + raise RuntimeError(msg) + cmake_exe = cmake_exe.path + + host_cfg_fname = "%s-%s-%s.cmake" % (socket.gethostname(), + sys_type, + spec.compiler) + + cfg = open(host_cfg_fname, "w") + cfg.write("##################################\n") + cfg.write("# spack generated host-config\n") + cfg.write("##################################\n") + cfg.write("# {0}-{1}\n".format(sys_type, spec.compiler)) + cfg.write("##################################\n\n") + + # Include path to cmake for reference + cfg.write("# cmake from spack \n") + cfg.write("# cmake executable path: %s\n\n" % cmake_exe) + + ####################### + # Compiler Settings + ####################### + + cfg.write("#######\n") + cfg.write("# using %s compiler spec\n" % spec.compiler) + cfg.write("#######\n\n") + cfg.write("# c compiler used by spack\n") + cfg.write(cmake_cache_entry("CMAKE_C_COMPILER", c_compiler)) + cfg.write("# cpp compiler used by spack\n") + cfg.write(cmake_cache_entry("CMAKE_CXX_COMPILER", cpp_compiler)) + + cfg.write("# fortran compiler used by spack\n") + if f_compiler is not None: + cfg.write(cmake_cache_entry("ENABLE_FORTRAN", "ON")) + cfg.write(cmake_cache_entry("CMAKE_Fortran_COMPILER", f_compiler)) + else: + cfg.write("# no fortran compiler found\n\n") + cfg.write(cmake_cache_entry("ENABLE_FORTRAN", "OFF")) + + ####################################################################### + # Core Dependencies + ####################################################################### + + ####################### + # Conduit + ####################### + + cfg.write("# conduit from spack \n") + cfg.write(cmake_cache_entry("CONDUIT_DIR", spec['conduit'].prefix)) + + ####################################################################### + # Optional Dependencies + ####################################################################### + + ####################### + # Python + ####################### + + cfg.write("# Python Support\n") + + if "+python" in spec: + cfg.write("# Enable python module builds\n") + cfg.write(cmake_cache_entry("ENABLE_PYTHON", "ON")) + cfg.write("# python from spack \n") + cfg.write(cmake_cache_entry("PYTHON_EXECUTABLE", + spec['python'].command.path)) + # install module to standard style site packages dir + # so we can support spack activate + cfg.write(cmake_cache_entry("PYTHON_MODULE_INSTALL_PREFIX", + site_packages_dir)) + else: + cfg.write(cmake_cache_entry("ENABLE_PYTHON", "OFF")) + + if "+doc" in spec: + cfg.write(cmake_cache_entry("ENABLE_DOCS", "ON")) + + cfg.write("# sphinx from spack \n") + sphinx_build_exe = join_path(spec['py-sphinx'].prefix.bin, + "sphinx-build") + cfg.write(cmake_cache_entry("SPHINX_EXECUTABLE", sphinx_build_exe)) + + cfg.write("# doxygen from uberenv\n") + doxygen_exe = spec['doxygen'].command.path + cfg.write(cmake_cache_entry("DOXYGEN_EXECUTABLE", doxygen_exe)) + else: + cfg.write(cmake_cache_entry("ENABLE_DOCS", "OFF")) + + ####################### + # MPI + ####################### + + cfg.write("# MPI Support\n") + + if "+mpi" in spec: + cfg.write(cmake_cache_entry("ENABLE_MPI", "ON")) + cfg.write(cmake_cache_entry("MPI_C_COMPILER", spec['mpi'].mpicc)) + cfg.write(cmake_cache_entry("MPI_CXX_COMPILER", + spec['mpi'].mpicxx)) + cfg.write(cmake_cache_entry("MPI_Fortran_COMPILER", + spec['mpi'].mpifc)) + else: + cfg.write(cmake_cache_entry("ENABLE_MPI", "OFF")) + + ####################### + # CUDA + ####################### + + cfg.write("# CUDA Support\n") + + if "+cuda" in spec: + cfg.write(cmake_cache_entry("ENABLE_CUDA", "ON")) + else: + cfg.write(cmake_cache_entry("ENABLE_CUDA", "OFF")) + + ####################### + # VTK-h + ####################### + + cfg.write("# vtk-h support \n") + + if "+vtkh" in spec: + cfg.write("# tbb from spack\n") + cfg.write(cmake_cache_entry("TBB_DIR", spec['tbb'].prefix)) + + cfg.write("# vtk-m from spack\n") + cfg.write(cmake_cache_entry("VTKM_DIR", spec['vtkm'].prefix)) + + cfg.write("# vtk-h from spack\n") + cfg.write(cmake_cache_entry("VTKH_DIR", spec['vtkh'].prefix)) + else: + cfg.write("# vtk-h not built by spack \n") + + ####################### + # Adios + ####################### + + cfg.write("# adios support\n") + + if "+adios" in spec: + cfg.write(cmake_cache_entry("ADIOS_DIR", spec['adios'].prefix)) + else: + cfg.write("# adios not built by spack \n") + + cfg.write("##################################\n") + cfg.write("# end spack generated host-config\n") + cfg.write("##################################\n") + cfg.close() + + host_cfg_fname = os.path.abspath(host_cfg_fname) + tty.info("spack generated conduit host-config file: " + host_cfg_fname) + return host_cfg_fname diff --git a/var/spack/repos/builtin/packages/conduit/package.py b/var/spack/repos/builtin/packages/conduit/package.py index ef6f66521f..6793a391c3 100644 --- a/var/spack/repos/builtin/packages/conduit/package.py +++ b/var/spack/repos/builtin/packages/conduit/package.py @@ -28,6 +28,7 @@ import socket import os import llnl.util.tty as tty +from os import environ as env def cmake_cache_entry(name, value): @@ -52,6 +53,8 @@ class Conduit(Package): version('0.2.1', 'ed7358af3463ba03f07eddd6a6e626ff') version('0.2.0', 'a7b398d493fd71b881a217993a9a29d4') + maintainers = ['cyrush'] + version('master', git='https://github.com/LLNL/conduit.git', branch="master", @@ -84,12 +87,15 @@ class Conduit(Package): ####################### # CMake ####################### - # cmake 3.8.2 is the version we recommend - depends_on("cmake@3.8.2", when="+cmake") + # cmake 3.8.2 or newer + depends_on("cmake@3.8.2:", when="+cmake") ####################### # Python ####################### + # we need a shared version of python b/c linking with static python lib + # causes duplicate state issues when running compiled python modules. + depends_on("python+shared") extends("python", when="+python") # TODO: blas and lapack are disabled due to build # issues Cyrus experienced on OSX 10.11.6 @@ -103,12 +109,12 @@ class Conduit(Package): # to link against shared libs. # # we are not using hdf5's mpi or fortran features. - depends_on("hdf5~cxx~mpi~fortran", when="+shared") - depends_on("hdf5~shared~cxx~mpi~fortran", when="~shared") + depends_on("hdf5~cxx~mpi~fortran", when="+hdf5+shared") + depends_on("hdf5~shared~cxx~mpi~fortran", when="+hdf5~shared") # we are not using silo's fortran features - depends_on("silo~fortran", when="+shared") - depends_on("silo~shared~fortran", when="~shared") + depends_on("silo~fortran", when="+silo+shared") + depends_on("silo~shared~fortran", when="+silo~shared") ####################### # MPI diff --git a/var/spack/repos/builtin/packages/intel-tbb/package.py b/var/spack/repos/builtin/packages/intel-tbb/package.py index adf2f9728d..05185ce297 100644 --- a/var/spack/repos/builtin/packages/intel-tbb/package.py +++ b/var/spack/repos/builtin/packages/intel-tbb/package.py @@ -54,6 +54,9 @@ class IntelTbb(Package): provides('tbb') + # include patch for gcc rtm options + patch("tbb_gcc_rtm_key.patch", level=0) + def coerce_to_spack(self, tbb_build_subdir): for compiler in ["icc", "gcc", "clang"]: fs = glob.glob(join_path(tbb_build_subdir, diff --git a/var/spack/repos/builtin/packages/intel-tbb/tbb_gcc_rtm_key.patch b/var/spack/repos/builtin/packages/intel-tbb/tbb_gcc_rtm_key.patch new file mode 100644 index 0000000000..f1a42fb52f --- /dev/null +++ b/var/spack/repos/builtin/packages/intel-tbb/tbb_gcc_rtm_key.patch @@ -0,0 +1,23 @@ +*** build/linux.gcc.inc.orig 2017-01-10 16:54:01.000000000 -0800 +--- build/linux.gcc.inc 2017-01-10 16:54:04.000000000 -0800 +*************** +*** 49,57 **** + endif + + # gcc 4.8 and later support RTM intrinsics, but require command line switch to enable them +! ifneq (,$(shell gcc -dumpversion | egrep "^(4\.[8-9]|[5-9])")) +! RTM_KEY = -mrtm +! endif + + ifeq ($(cfg), release) + CPLUS_FLAGS = $(ITT_NOTIFY) -g -O2 -DUSE_PTHREAD +--- 49,57 ---- + endif + + # gcc 4.8 and later support RTM intrinsics, but require command line switch to enable them +! #ifneq (,$(shell gcc -dumpversion | egrep "^(4\.[8-9]|[5-9])")) +! # RTM_KEY = -mrtm +! #endif + + ifeq ($(cfg), release) + CPLUS_FLAGS = $(ITT_NOTIFY) -g -O2 -DUSE_PTHREAD \ No newline at end of file diff --git a/var/spack/repos/builtin/packages/vtkh/package.py b/var/spack/repos/builtin/packages/vtkh/package.py new file mode 100644 index 0000000000..9073c1f6f3 --- /dev/null +++ b/var/spack/repos/builtin/packages/vtkh/package.py @@ -0,0 +1,97 @@ +############################################################################## +# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/spack/spack +# Please also see the NOTICE and LICENSE files for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## + +from spack import * + + +class Vtkh(Package): + """VTK-h is a toolkit of scientific visualization algorithms for emerging + processor architectures. VTK-h brings together several projects like VTK-m + and DIY2 to provide a toolkit with hybrid parallel capabilities.""" + + homepage = "https://github.com/Alpine-DAV/vtk-h" + url = "https://github.com/Alpine-DAV/vtk-h" + + version('master', + git='https://github.com/Alpine-DAV/vtk-h.git', + branch='master', + submodules=True) + + maintainers = ['cyrush'] + + variant("mpi", default=True, description="build mpi support") + variant("tbb", default=True, description="build tbb support") + variant("cuda", default=False, description="build cuda support") + + depends_on("cmake") + + depends_on("mpi", when="+mpi") + depends_on("tbb", when="+tbb") + depends_on("cuda", when="+cuda") + + depends_on("vtkm@master") + depends_on("vtkm@master+tbb", when="+tbb") + depends_on("vtkm@master+cuda", when="+cuda") + + def install(self, spec, prefix): + with working_dir('spack-build', create=True): + cmake_args = ["../src", + "-DVTKM_DIR={0}".format(spec["vtkm"].prefix), + "-DENABLE_TESTS=OFF", + "-DBUILD_TESTING=OFF"] + # mpi support + if "+mpi" in spec: + mpicc = spec['mpi'].mpicc + mpicxx = spec['mpi'].mpicxx + cmake_args.extend(["-DMPI_C_COMPILER={0}".format(mpicc), + "-DMPI_CXX_COMPILER={0}".format(mpicxx)]) + + # tbb support + if "+tbb" in spec: + cmake_args.append("-DTBB_DIR={0}".format(spec["tbb"].prefix)) + + # cuda support + if "+cuda" in spec: + cmake_args.append("-DENABLE_CUDA=ON") + # this fix is necessary if compiling platform has cuda, but + # no devices (this common for front end nodes on hpc clusters) + # we choose kepler as a lowest common denominator + cmake_args.append("-DVTKm_CUDA_Architecture=kepler") + + # use release, instead of release with debug symbols b/c vtkh libs + # can overwhelm compilers with too many symbols + for arg in std_cmake_args: + if arg.count("CMAKE_BUILD_TYPE") == 0: + cmake_args.extend(std_cmake_args) + cmake_args.append("-DCMAKE_BUILD_TYPE=Release") + cmake(*cmake_args) + if "+cuda" in spec: + # avoid issues with make -j and FindCuda deps + # likely a ordering issue that needs to be resolved + # in vtk-h + make(parallel=False) + else: + make() + make("install") diff --git a/var/spack/repos/builtin/packages/vtkm/package.py b/var/spack/repos/builtin/packages/vtkm/package.py new file mode 100644 index 0000000000..c1bc968f85 --- /dev/null +++ b/var/spack/repos/builtin/packages/vtkm/package.py @@ -0,0 +1,83 @@ +############################################################################## +# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/spack/spack +# Please also see the NOTICE and LICENSE files for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## + +from spack import * +import os + + +class Vtkm(Package): + """VTK-m is a toolkit of scientific visualization algorithms for emerging + processor architectures. VTK-m supports the fine-grained concurrency for + data analysis and visualization algorithms required to drive extreme scale + computing by providing abstract models for data and execution that can be + applied to a variety of algorithms across many different processor + architectures.""" + + homepage = "https://m.vtk.org/" + url = "https://gitlab.kitware.com/vtk/vtk-m/repository/v1.1.0/archive.tar.gz" + + version('1.1.0', "6aab1c0885f6ffaaffcf07930873d0df") + + version('master', + git='https://gitlab.kitware.com/vtk/vtk-m.git', + branch='master') + + variant("cuda", default=False, description="build cuda support") + variant("tbb", default=True, description="build TBB support") + + depends_on("cmake") + depends_on("tbb", when="+tbb") + depends_on("cuda", when="+cuda") + + def install(self, spec, prefix): + with working_dir('spack-build', create=True): + cmake_args = ["../", + "-DVTKm_ENABLE_TESTING=OFF", + "-DVTKm_BUILD_RENDERING=ON", + "-DVTKm_USE_64BIT_IDS=OFF", + "-DVTKm_USE_DOUBLE_PRECISION=ON"] + # tbb support + if "+tbb" in spec: + # vtk-m detectes tbb via TBB_ROOT env var + os.environ["TBB_ROOT"] = spec["tbb"].prefix + cmake_args.append("-DVTKm_ENABLE_TBB=ON") + + # cuda support + if "+cuda" in spec: + cmake_args.append("-DVTKm_ENABLE_CUDA=ON") + # this fix is necessary if compiling platform has cuda, but + # no devices (this common for front end nodes on hpc clusters) + # we choose kepler as a lowest common denominator + cmake_args.append("-DVTKm_CUDA_Architecture=kepler") + + # use release, instead of release with debug symbols b/c vtkm libs + # can overwhelm compilers with too many symbols + for arg in std_cmake_args: + if arg.count("CMAKE_BUILD_TYPE") == 0: + cmake_args.extend(std_cmake_args) + cmake_args.append("-DCMAKE_BUILD_TYPE=Release") + cmake(*cmake_args) + make() + make("install") -- cgit v1.2.3-70-g09d2