diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2023-11-02 07:35:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 23:35:23 -0700 |
commit | 16fa3b9f077be62e62214585dee9f6dfda7f48ad (patch) | |
tree | 0a2208f08955524d0f2bad316816f5d94be580db /var | |
parent | 6cd2241e49a393d7ac32b46064a2d2f4e53f7d86 (diff) | |
download | spack-16fa3b9f077be62e62214585dee9f6dfda7f48ad.tar.gz spack-16fa3b9f077be62e62214585dee9f6dfda7f48ad.tar.bz2 spack-16fa3b9f077be62e62214585dee9f6dfda7f48ad.tar.xz spack-16fa3b9f077be62e62214585dee9f6dfda7f48ad.zip |
Cherry-picking virtual dependencies (#35322)
This PR makes it possible to select only a subset of virtual dependencies from a spec that _may_ provide more. To select providers, a syntax to specify edge attributes is introduced:
```
hdf5 ^[virtuals=mpi] mpich
```
With that syntax we can concretize specs like:
```console
$ spack spec strumpack ^[virtuals=mpi] intel-parallel-studio+mkl ^[virtuals=lapack] openblas
```
On `develop` this would currently fail with:
```console
$ spack spec strumpack ^intel-parallel-studio+mkl ^openblas
==> Error: Spec cannot include multiple providers for virtual 'blas'
Requested 'intel-parallel-studio' and 'openblas'
```
In package recipes, virtual specs that are declared in the same `provides` directive need to be provided _together_. This means that e.g. `openblas`, which has:
```python
provides("blas", "lapack")
```
needs to provide both `lapack` and `blas` when requested to provide at least one of them.
## Additional notes
This capability is needed to model compilers. Assuming that languages are treated like virtual dependencies, we might want e.g. to use LLVM to compile C/C++ and Gnu GCC to compile Fortran. This can be accomplished by the following[^1]:
```
hdf5 ^[virtuals=c,cxx] llvm ^[virtuals=fortran] gcc
```
[^1]: We plan to add some syntactic sugar around this syntax, and reuse the `%` sigil to avoid having a lot of boilerplate around compilers.
Modifications:
- [x] Add syntax to interact with edge attributes from spec literals
- [x] Add concretization logic to be able to cherry-pick virtual dependencies
- [x] Extend semantic of the `provides` directive to express when virtuals need to be provided together
- [x] Add unit-tests and documentation
Diffstat (limited to 'var')
11 files changed, 91 insertions, 11 deletions
diff --git a/var/spack/repos/builtin.mock/packages/intel-parallel-studio/package.py b/var/spack/repos/builtin.mock/packages/intel-parallel-studio/package.py new file mode 100644 index 0000000000..1ec5cf6932 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/intel-parallel-studio/package.py @@ -0,0 +1,19 @@ +# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + + +class IntelParallelStudio(Package): + """Intel Parallel Studio.""" + + homepage = "https://software.intel.com/en-us/intel-parallel-studio-xe" + url = "http://tec/16225/parallel_studio_xe_2020_cluster_edition.tgz" + + version("cluster.2020.0", sha256="b1d3e3e425b2e44a06760ff173104bdf") + + provides("mpi@:3") + provides("scalapack") + provides("blas", "lapack") diff --git a/var/spack/repos/builtin.mock/packages/low-priority-provider/package.py b/var/spack/repos/builtin.mock/packages/low-priority-provider/package.py index 5b7bfc03c1..940dea3daf 100644 --- a/var/spack/repos/builtin.mock/packages/low-priority-provider/package.py +++ b/var/spack/repos/builtin.mock/packages/low-priority-provider/package.py @@ -14,5 +14,5 @@ class LowPriorityProvider(Package): version("1.0", md5="0123456789abcdef0123456789abcdef") - provides("lapack") - provides("mpi") + # A low priority provider that provides both these specs together + provides("mpi", "lapack") diff --git a/var/spack/repos/builtin.mock/packages/many-virtual-consumer/package.py b/var/spack/repos/builtin.mock/packages/many-virtual-consumer/package.py index 070adf60bc..087cfb77cc 100644 --- a/var/spack/repos/builtin.mock/packages/many-virtual-consumer/package.py +++ b/var/spack/repos/builtin.mock/packages/many-virtual-consumer/package.py @@ -19,4 +19,4 @@ class ManyVirtualConsumer(Package): # This directive is an example of imposing a constraint on a # dependency is that dependency is in the DAG. This pattern # is mainly used with virtual providers. - depends_on("low-priority-provider@1.0", when="^low-priority-provider") + depends_on("low-priority-provider@1.0", when="^[virtuals=mpi,lapack] low-priority-provider") diff --git a/var/spack/repos/builtin.mock/packages/netlib-scalapack/package.py b/var/spack/repos/builtin.mock/packages/netlib-scalapack/package.py new file mode 100644 index 0000000000..fe5d7f90a1 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/netlib-scalapack/package.py @@ -0,0 +1,20 @@ +# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +from spack.package import * + + +class NetlibScalapack(Package): + homepage = "http://www.netlib.org/scalapack/" + url = "http://www.netlib.org/scalapack/scalapack-2.1.0.tgz" + + version("2.1.0", "b1d3e3e425b2e44a06760ff173104bdf") + + provides("scalapack") + + depends_on("mpi") + depends_on("lapack") + depends_on("blas") diff --git a/var/spack/repos/builtin.mock/packages/openblas-with-lapack/package.py b/var/spack/repos/builtin.mock/packages/openblas-with-lapack/package.py index 0156085877..1273b70def 100644 --- a/var/spack/repos/builtin.mock/packages/openblas-with-lapack/package.py +++ b/var/spack/repos/builtin.mock/packages/openblas-with-lapack/package.py @@ -14,5 +14,4 @@ class OpenblasWithLapack(Package): version("0.2.15", md5="b1190f3d3471685f17cfd1ec1d252ac9") - provides("lapack") - provides("blas") + provides("lapack", "blas") diff --git a/var/spack/repos/builtin/packages/lua-luajit-openresty/package.py b/var/spack/repos/builtin/packages/lua-luajit-openresty/package.py index fbcc63cded..081e07fe6c 100644 --- a/var/spack/repos/builtin/packages/lua-luajit-openresty/package.py +++ b/var/spack/repos/builtin/packages/lua-luajit-openresty/package.py @@ -28,8 +28,7 @@ class LuaLuajitOpenresty(LuaImplPackage): description="add symlinks to make lua-luajit a drop-in lua replacement", ) - provides("lua-lang@5.1", when="+lualinks") - provides("luajit") + provides("luajit", "lua-lang@5.1", when="+lualinks") lua_version_override = "5.1" @run_after("install") diff --git a/var/spack/repos/builtin/packages/lua-luajit/package.py b/var/spack/repos/builtin/packages/lua-luajit/package.py index e8a1c124e0..dfe9f51cd0 100644 --- a/var/spack/repos/builtin/packages/lua-luajit/package.py +++ b/var/spack/repos/builtin/packages/lua-luajit/package.py @@ -33,8 +33,7 @@ class LuaLuajit(LuaImplPackage): description="add symlinks to make lua-luajit a drop-in lua replacement", ) - provides("lua-lang@5.1", when="+lualinks") - provides("luajit") + provides("luajit", "lua-lang@5.1", when="+lualinks") lua_version_override = "5.1" conflicts("platform=darwin", msg="luajit not supported on MacOS, see lua-luajit-openresty") diff --git a/var/spack/repos/builtin/packages/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py index 43c3dafdad..409dfa004d 100644 --- a/var/spack/repos/builtin/packages/openblas/package.py +++ b/var/spack/repos/builtin/packages/openblas/package.py @@ -88,8 +88,7 @@ class Openblas(CMakePackage, MakefilePackage): ) # virtual dependency - provides("blas") - provides("lapack") + provides("blas", "lapack") provides("lapack@3.9.1:", when="@0.3.15:") provides("lapack@3.7.0", when="@0.2.20") diff --git a/var/spack/repos/edges.test/packages/conditional-edge/package.py b/var/spack/repos/edges.test/packages/conditional-edge/package.py new file mode 100644 index 0000000000..964596fcc1 --- /dev/null +++ b/var/spack/repos/edges.test/packages/conditional-edge/package.py @@ -0,0 +1,24 @@ +# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +from spack.package import * + + +class ConditionalEdge(Package): + """This package has a variant that triggers a condition only if a required dependency is + providing a virtual. + """ + + homepage = "http://www.example.com" + url = "http://www.example.com/a-1.0.tar.gz" + + version("2.0", md5="abcdef0123456789abcdef0123456789") + version("1.0", md5="0123456789abcdef0123456789abcdef") + + variant("foo", default=False, description="Just a regular foo") + + # zlib is a real package, providing zlib-api + depends_on("zlib") + depends_on("zlib-api", when="+foo") + depends_on("zlib@1.0", when="^[virtuals=zlib-api] zlib") diff --git a/var/spack/repos/edges.test/packages/zlib/package.py b/var/spack/repos/edges.test/packages/zlib/package.py new file mode 100644 index 0000000000..66dfc4f58b --- /dev/null +++ b/var/spack/repos/edges.test/packages/zlib/package.py @@ -0,0 +1,19 @@ +# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +from spack.package import * + + +class Zlib(Package): + """This package has a variant that triggers a condition only if a required dependency is + providing a virtual. + """ + + homepage = "http://www.example.com" + url = "http://www.example.com/a-1.0.tar.gz" + + version("2.0", md5="abcdef0123456789abcdef0123456789") + version("1.0", md5="0123456789abcdef0123456789abcdef") + + provides("zlib-api") diff --git a/var/spack/repos/edges.test/repo.yaml b/var/spack/repos/edges.test/repo.yaml new file mode 100644 index 0000000000..86df79affe --- /dev/null +++ b/var/spack/repos/edges.test/repo.yaml @@ -0,0 +1,2 @@ +repo: + namespace: edges.test |