diff --git a/CHANGELOG.md b/CHANGELOG.md index 8586e8f6bb..28f0199ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed (Repair bugs, etc) - [[PR292]](https://github.com/lanl/singularity-eos/pull/292) Added Carnahan-Starling EoS +- [[PR291]](https://github.com/lanl/singularity-eos/pull/291) package.py updates to reflect new CMake options - [[PR290]](https://github.com/lanl/singularity-eos/pull/290) Added target guards on export config - [[PR288]](https://github.com/lanl/singularity-eos/pull/288) Don't build tests that depend on spiner when spiner is disabled - [[PR287]](https://github.com/lanl/singularity-eos/pull/287) Fix testing logic with new HDF5 options diff --git a/CMakeLists.txt b/CMakeLists.txt index 462a9277bb..ed46c9314d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,6 @@ # publicly and display publicly, and to permit others to do so. # ------------------------------------------------------------------------------# -# We want to stay near to latest, as more compilers and third-party libraries -# are supported. However, uptake of new CMake releases can be slow. 20230403: -# version 3.19 is available on all testing platforms cmake_minimum_required(VERSION 3.19) # Disable "in-source" builds @@ -51,9 +48,10 @@ option(SINGULARITY_USE_FORTRAN "Enable fortran bindings" ON) option(SINGULARITY_USE_KOKKOS "Use Kokkos for portability" OFF) option(SINGULARITY_USE_EOSPAC "Enable eospac backend" OFF) +#TODO This should be dependent option (or fortran option) option(SINGULARITY_BUILD_CLOSURE "Mixed Cell Closure" ON) -cmake_dependent_option(SINGULARITY_USE_CUDA "Use CUDA backend of Kokkos" ON +cmake_dependent_option(SINGULARITY_USE_CUDA "Use CUDA backend of Kokkos" OFF "SINGULARITY_USE_KOKKOS" OFF) cmake_dependent_option( SINGULARITY_USE_KOKKOSKERNELS "Use KokkosKernels for LA routines" ON diff --git a/doc/sphinx/src/building.rst b/doc/sphinx/src/building.rst index d03445115c..7fdf3c565c 100644 --- a/doc/sphinx/src/building.rst +++ b/doc/sphinx/src/building.rst @@ -1,5 +1,5 @@ -Overview -======== +Building `singularity-eos` +========================== The ``singularity-eos`` build system is designed with two goals in mind @@ -53,15 +53,15 @@ Dependencies ====================================== =============================== =========================================== Package Name Distribution Comment ====================================== =============================== =========================================== - `spiner`_ submodule [*]_ / external [*]_ Required `ports-of-call`_ submodule / external Required `mpark_variant`_ submodule / external Required + `spiner`_ submodule [*]_ / external [*]_ Optional; enhanced backend for EOS tables `hdf5`_ external only Optional; used for table I/O `eospac`_ external only Optional; used for sesame tables. `kokkos`_ submodule / external Optional; enables GPU offloading. `Eigen`_ submodule / external Optional; used for linear algebra on the CPU when doing mixed-cell closures. `kokkos-kernels`_ submodule / external Optional; used for linear algebra on the GPU when doing mixed-cell closures. - `pybind11`_ external / fetchable [*]_ Optional; + `pybind11`_ external / fetchable [*]_ Optional ====================================== =============================== =========================================== .. [*] availible as a git submodule for in-tree builds @@ -105,6 +105,7 @@ The main CMake options to configure building are in the following table: ``SINGULARITY_USE_FORTRAN`` ON Enable Fortran API for equation of state. ``SINGULARITY_USE_KOKKOS`` OFF Uses Kokkos as the portability backend. Currently only Kokkos is supported for GPUs. ``SINGULARITY_USE_EOSPAC`` OFF Link against EOSPAC. Needed for sesame2spiner and some tests. + ``SINGULARITY_BUILD_CLOSURE`` OFF Build the mixed cell closure models ``SINGULARITY_BUILD_TESTS`` OFF Build test infrastructure. ``SINGULARITY_BUILD_PYTHON`` OFF Build Python bindings. ``SINGULARITY_INVERT_AT_SETUP`` OFF For tests, pre-invert eospac tables. @@ -146,8 +147,7 @@ preconditions: ============================================== ================================================================================= =========================================== ``SINGULARITY_USE_SPINER_WITH_HDF5`` ``SINGULARITY_USE_SPINER=ON`` Requests that ``spiner`` be configured for ``HDF5`` support. ``SINGULARITY_USE_CUDA`` ``SINGULARITY_USE_KOKKOS=ON`` Target nvidia GPUs for ``Kokkos`` offloading. - ``SINGULARITY_USE_KOKKOSKERNELS`` ``SINGULARITY_USE_KOKKOS=ON`` Use Kokkos Kernels for linear algebra. Needed for mixed cell closure models on GPU. - ``SINGULARITY_BUILD_CLOSURE`` ``SINGULARITY_USE_KOKKOS=ON`` ``SINGULARITY_USE_KOKKOSKERNELS=ON`` Mixed cell closure. + ``SINGULARITY_USE_KOKKOSKERNELS`` ``SINGULARITY_USE_KOKKOS=ON`` ``SINGULARITY_BUILD_CLOSURE=ON`` Use Kokkos Kernels for linear algebra. Needed for mixed cell closure models on GPU. ``SINGULARITY_BUILD_SESAME2SPINER`` ``SINGULARITY_USE_SPINER=ON`` ``SINGULARITY_USE_SPINER_WITH_HDF5=ON`` Builds the conversion tool sesame2spiner which makes files readable by SpinerEOS. ``SINGULARITY_BUILD_STELLARCOLLAPSE2SPINER`` ``SINGULARITY_USE_SPINER=ON`` ``SINGULARITY_USE_SPINER_WITH_HDF5=ON`` Builds the conversion tool stellarcollapse2spiner which optionally makes stellar collapse files faster to read. ``SINGULARITY_TEST_SESAME`` ``SINGULARITY_BUILD_TESTS=ON`` ``SINGULARITY_BUILD_SESAME2SPINER=ON`` Test the Sesame table readers. diff --git a/spack-repo/packages/singularity-eos/package.py b/spack-repo/packages/singularity-eos/package.py index 2de592367a..156891bb5b 100644 --- a/spack-repo/packages/singularity-eos/package.py +++ b/spack-repo/packages/singularity-eos/package.py @@ -58,8 +58,12 @@ class SingularityEos(CMakePackage, CudaPackage): # configuration variant("hdf5", default=False, description="Use hdf5") + variant("spiner", default=True, description="Use Spiner") + + variant("closure", default=True, description="Build closure module") + # building/testing/docs - depends_on("cmake@3.14:") + depends_on("cmake@3.19:") depends_on("catch2@2.13.7", when="+tests") depends_on("python@3:", when="+python") depends_on("py-numpy", when="+python+tests") @@ -73,18 +77,18 @@ class SingularityEos(CMakePackage, CudaPackage): # eospac when asked for depends_on("eospac", when="+eospac") - depends_on("ports-of-call@1.4.2:", when="@:1.7.0") - depends_on("ports-of-call@1.5.1:", when="@1.7.1:") + depends_on("ports-of-call@1.4.2,1.5.2:", when="@:1.7.0") + depends_on("ports-of-call@1.5.2:", when="@1.7.1:") # request HEAD of main branch depends_on("ports-of-call@main", when="@main") - depends_on("spiner +kokkos", when="+kokkos") + depends_on("spiner +kokkos", when="+kokkos+spiner") # tell spiner to use HDF5 - depends_on("spiner +hdf5", when="+hdf5") + depends_on("spiner +hdf5", when="+hdf5+spiner") - depends_on("spiner@:1.6.0", when="@:1.7.0") - depends_on("spiner@1.6.1:", when="@1.7.1:") #TODO version - depends_on("spiner@main", when="@main") + depends_on("spiner@:1.6.0", when="@:1.7.0 +spiner") + depends_on("spiner@1.6.1:", when="@1.7.1: +spiner") #TODO version + depends_on("spiner@main", when="@main +spiner") depends_on("mpark-variant") depends_on( @@ -96,9 +100,11 @@ class SingularityEos(CMakePackage, CudaPackage): when="+cuda", ) + + #TODO: do we need kokkos,kokkoskernels the exact same version? for _myver,_kver in zip(("@:1.6.2","@1.7.0:"),("@3.2:","@3.3:")): - depends_on("kokkos" + _kver, when=_myver) - depends_on("kokkos-kernels" + _kver, when=_myver) + depends_on("kokkos" + _kver, when=_myver + '+kokkos') + depends_on("kokkos-kernels" + _kver, when=_myver + '+kokkos-kernels') # set up kokkos offloading dependencies for _flag in ("~cuda", "+cuda", "~openmp", "+openmp"): @@ -107,8 +113,9 @@ class SingularityEos(CMakePackage, CudaPackage): depends_on("spiner" + _flag, when="+kokkos" + _flag) # specfic specs when using GPU/cuda offloading - # TODO Do we need `+aggressive_vectorization`, `+cuda_constexpr`, `~compiler_warnings` ? - depends_on("kokkos +wrapper+cuda_lambda+cuda_relocatable_device_code", when="+cuda+kokkos") + # TODO remove +wrapper for clang builds + # TODO version guard +cuda_lambda + depends_on("kokkos +wrapper+cuda_lambda", when="+cuda+kokkos") # fix for older spacks if spack.version.Version(spack.spack_version) >= spack.version.Version("0.17"): @@ -127,6 +134,10 @@ class SingularityEos(CMakePackage, CudaPackage): conflicts("+cuda", when="~kokkos") conflicts("+openmp", when="~kokkos") conflicts("+kokkos-kernels", when="~kokkos") + conflicts("+hdf5", when="~spiner") + + # TODO: @dholliday remove when sg_get_eos not singularity + conflicts("+fortran", when="~closure") # NOTE: these are set so that dependencies in downstream projects share # common MPI dependence @@ -144,9 +155,9 @@ def cmake_args(self): self.define_from_variant("SINGULARITY_USE_KOKKOS", "kokkos"), self.define_from_variant("SINGULARITY_USE_KOKKOSKERNELS", "kokkos-kernels"), self.define_from_variant("SINGULARITY_USE_FORTRAN", "fortran"), - self.define_from_variant("SINGULARITY_BUILD_CLOSURE", "fortran"), + self.define_from_variant("SINGULARITY_BUILD_CLOSURE", "closure"), self.define_from_variant("SINGULARITY_BUILD_PYTHON", "python"), - self.define_from_variant("SINGULARITY_USE_SPINER", "hdf5"), + self.define_from_variant("SINGULARITY_USE_SPINER", "spiner"), self.define_from_variant("SINGULARITY_USE_SPINER_WITH_HDF5", "hdf5"), self.define("SINGULARITY_BUILD_TESTS", self.run_tests), self.define( @@ -165,46 +176,18 @@ def cmake_args(self): ("stellarcollapse" in self.spec.variants["build_extra"].value and self.run_tests), ), self.define("SINGULARITY_TEST_PYTHON", ("+python" in self.spec and self.run_tests)), + # TODO: guard for older versions, remove for new versions(1.7<) self.define("SINGULARITY_USE_HDF5", "^hdf5" in self.spec), self.define("SINGULARITY_USE_EOSPAC", "^eospac" in self.spec), ] + #TODO: do we need this? if "+kokkos+cuda" in self.spec: args.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx)) return args - # TODO everything past here may not be needed, - # except the pythonpath setting - # - # specify the name of the auto-generated cmake cache config - @property - def cmake_config_fname(self): - return "singularity-eos_spackconfig.cmake" - - # generate the pre-configured cmake cache file that reflects the spec options - # NOTE: this file isn't replaced if the same spec is already installed - - # you may need to uninstall the old spec first - @run_after("cmake") - def generate_cmake_configuration(self): - config_fname = self.cmake_config_fname - cmake_config = self.cmake_args() - - with working_dir("cmake-gen", create=True): - with open(config_fname, "w") as cmc: - for arg in cmake_config: - kt, v = arg.replace("-D", "").split("=") - k, t = kt.split(":") - cmc.write('set({} "{}" CACHE {} "" FORCE)\n'.format(k, v, t)) - install(config_fname, join_path(prefix, config_fname)) - - # run when loaded - # NOTE: to use: - # cmake -C $SINGULARITY_SPACK_CMAKE_CONFIG ... def setup_run_environment(self, env): - env.set( - "SINGULARITY_SPACK_CMAKE_CONFIG", os.path.join(self.prefix, self.cmake_config_fname) - ) if os.path.isdir(self.prefix.lib64): lib_dir = self.prefix.lib64 else: