Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to package.py #291

Merged
merged 6 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [[PR269]](https://github.com/lanl/singularity-eos/pull/269) Add SAP Polynomial EoS

### Fixed (Repair bugs, etc)
- [[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
Expand Down
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
69 changes: 26 additions & 43 deletions spack-repo/packages/singularity-eos/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]", when="+tests")
depends_on("python@3:", when="+python")
depends_on("py-numpy", when="+python+tests")
Expand All @@ -74,17 +78,17 @@ class SingularityEos(CMakePackage, CudaPackage):
depends_on("eospac", when="+eospac")

depends_on("[email protected]:", when="@:1.7.0")
mauneyc-LANL marked this conversation as resolved.
Show resolved Hide resolved
depends_on("[email protected].1:", when="@1.7.1:")
depends_on("[email protected].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("[email protected]:", 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("[email protected]:", when="@1.7.1: +spiner") #TODO version
depends_on("spiner@main", when="@main +spiner")

depends_on("mpark-variant")
depends_on(
Expand All @@ -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"):
Expand All @@ -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"):
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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:
Expand Down