-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first iteration of plugin enabled spackage
- Loading branch information
Showing
1 changed file
with
65 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,25 @@ | |
|
||
import os | ||
|
||
from spack.error import SpackError | ||
from spack.package import * | ||
from spack.directives import directive | ||
|
||
|
||
@directive("singularity_eos_plugins") | ||
def singularity_eos_plugin(name, path): | ||
def _execute_register(pkg): | ||
pkg.plugins[name] = path | ||
|
||
return _execute_register | ||
|
||
|
||
def plugin_validator(pkg_name, variant_name, values): | ||
if values == ("none",): | ||
return | ||
for v in values: | ||
if v not in SingularityEos.plugins: | ||
raise SpackError(f"Unknown Singularity-EOS plugin '{v}'") | ||
|
||
|
||
class SingularityEos(CMakePackage, CudaPackage): | ||
|
@@ -22,8 +40,16 @@ class SingularityEos(CMakePackage, CudaPackage): | |
version("main", branch="main") | ||
version("1.8.0", sha256="1f1ec496f714aa23cc7003c88a85bd10d0e53e37659ba7310541248e48a66558") | ||
version("1.7.0", sha256="ce0825db2e9d079503e98cecf1c565352be696109042b3a0941762b35f36dc49") | ||
version("1.6.2", sha256="9c85fca679139a40cc9c72fcaeeca78a407cc1ca184734785236042de364b942", deprecated=True) | ||
version("1.6.1", sha256="c6d92dfecf9689ffe2df615791c039f7e527e9f47799a862e26fa4e3420fe5d7", deprecated=True) | ||
version( | ||
"1.6.2", | ||
sha256="9c85fca679139a40cc9c72fcaeeca78a407cc1ca184734785236042de364b942", | ||
deprecated=True, | ||
) | ||
version( | ||
"1.6.1", | ||
sha256="c6d92dfecf9689ffe2df615791c039f7e527e9f47799a862e26fa4e3420fe5d7", | ||
deprecated=True, | ||
) | ||
|
||
# build with kokkos, kokkos-kernels for offloading support | ||
variant("kokkos", default=False, description="Enable kokkos") | ||
|
@@ -55,14 +81,27 @@ class SingularityEos(CMakePackage, CudaPackage): | |
# link to EOSPAC for table reads | ||
variant("eospac", default=True, description="Pull in EOSPAC") | ||
|
||
# enable/disable HDF5 - used to control upstream `spiner` | ||
# configuration | ||
# enable/disable HDF5 - used to control upstream `spiner` | ||
# configuration | ||
variant("hdf5", default=False, description="Use hdf5") | ||
|
||
variant("spiner", default=True, description="Use Spiner") | ||
|
||
variant("closure", default=True, description="Build closure module") | ||
|
||
plugins = {} | ||
|
||
singularity_eos_plugin("dust", "example/plugin") | ||
|
||
variant( | ||
"plugins", | ||
multi=True, | ||
default="none", | ||
validator=plugin_validator, | ||
description="list of plugins to build", | ||
) | ||
variant("variant", default="default", description="include path used for variant header") | ||
|
||
# building/testing/docs | ||
depends_on("[email protected]:") | ||
depends_on("[email protected]:", when="@main +tests") | ||
|
@@ -76,20 +115,20 @@ class SingularityEos(CMakePackage, CudaPackage): | |
# so maybe this should be `when="~kokkos-kernels~cuda"` | ||
depends_on("[email protected]", when="~cuda") | ||
|
||
# eospac when asked for | ||
# eospac when asked for | ||
depends_on("eospac", when="+eospac") | ||
|
||
depends_on("[email protected],1.5.2:", when="@:1.7.0") | ||
depends_on("[email protected]:", when="@1.7.1:") | ||
# request HEAD of main branch | ||
depends_on("ports-of-call@main", when="@main") | ||
|
||
depends_on("spiner +kokkos", when="+kokkos+spiner") | ||
# tell spiner to use HDF5 | ||
# tell spiner to use HDF5 | ||
depends_on("spiner +hdf5", when="+hdf5+spiner") | ||
|
||
depends_on("spiner@:1.6.0", when="@:1.7.0 +spiner") | ||
depends_on("[email protected]:", when="@1.7.1: +spiner") #TODO version | ||
depends_on("[email protected]:", when="@1.7.1: +spiner") # TODO version | ||
depends_on("spiner@main", when="@main +spiner") | ||
|
||
depends_on("mpark-variant") | ||
|
@@ -102,11 +141,10 @@ 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 + '+kokkos') | ||
depends_on("kokkos-kernels" + _kver, when=_myver + '+kokkos-kernels') | ||
# 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 + "+kokkos") | ||
depends_on("kokkos-kernels" + _kver, when=_myver + "+kokkos-kernels") | ||
|
||
# set up kokkos offloading dependencies | ||
for _flag in ("~cuda", "+cuda", "~openmp", "+openmp"): | ||
|
@@ -146,9 +184,9 @@ class SingularityEos(CMakePackage, CudaPackage): | |
for _flag in ("~mpi", "+mpi"): | ||
depends_on("hdf5~cxx+hl" + _flag, when="+hdf5" + _flag) | ||
depends_on("py-h5py" + _flag, when="@:1.6.2 " + _flag) | ||
# depends_on("kokkos-nvcc-wrapper" + _flag, when="+cuda+kokkos" + _flag) | ||
# depends_on("kokkos-nvcc-wrapper" + _flag, when="+cuda+kokkos" + _flag) | ||
|
||
# TODO some options are now version specific. For now it should be | ||
# TODO some options are now version specific. For now it should be | ||
# benign, but good practice to do some version guards. | ||
def cmake_args(self): | ||
args = [ | ||
|
@@ -163,7 +201,8 @@ def cmake_args(self): | |
self.define_from_variant("SINGULARITY_USE_SPINER_WITH_HDF5", "hdf5"), | ||
self.define("SINGULARITY_BUILD_TESTS", self.run_tests), | ||
self.define( | ||
"SINGULARITY_BUILD_SESAME2SPINER", "sesame" in self.spec.variants["build_extra"].value | ||
"SINGULARITY_BUILD_SESAME2SPINER", | ||
"sesame" in self.spec.variants["build_extra"].value, | ||
), | ||
self.define( | ||
"SINGULARITY_TEST_SESAME", | ||
|
@@ -183,7 +222,16 @@ def cmake_args(self): | |
self.define("SINGULARITY_USE_EOSPAC", "^eospac" in self.spec), | ||
] | ||
|
||
#TODO: do we need this? | ||
if "none" not in self.spec.variants["plugins"].value: | ||
pdirs = [] | ||
for p in self.spec.variants["plugins"].value: | ||
pdirs.append(join_path(self.stage.source_path, self.plugins[p])) | ||
args.append(self.define("SINGULARITY_PLUGINS", ";".join(pdirs))) | ||
|
||
if self.spec.variants["variant"].value != "default": | ||
args.append(self.define_from_variant("SINGULARITY_VARIANT", "variant")) | ||
|
||
# TODO: do we need this? | ||
if "+kokkos+cuda" in self.spec: | ||
args.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx)) | ||
|
||
|