Skip to content

Conversation

@alalazo
Copy link
Member

@alalazo alalazo commented Feb 3, 2023

depends on #39508
fixes #15443

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:

$ spack spec strumpack ^[virtuals=mpi] intel-parallel-studio+mkl ^[virtuals=lapack] openblas

and get this concrete DAG:

strumpack_virtuals

On develop this would currently fail with:

$ 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:

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 following1:

hdf5 ^[virtuals=c,cxx] llvm ^[virtuals=fortran] gcc

Modifications:

  • Add syntax to interact with edge attributes from spec literals
  • Add concretization logic to be able to cherry-pick virtual dependencies
  • Extend semantic of the provides directive to express when virtuals need to be provided together
  • Add unit-tests and documentation

Footnotes

  1. We plan to add some syntactic sugar around this syntax, and reuse the % sigil to avoid having a lot of boilerplate around compilers.

@spackbot-app
Copy link

spackbot-app bot commented Feb 3, 2023

Hi @alalazo! I noticed that the following package(s) don't yet have maintainers:

  • openblas

Are you interested in adopting any of these package(s)? If so, simply add the following to the package class:

    maintainers = ["alalazo"]

If not, could you contact the developers of this package and see if they are interested? You can quickly see who has worked on a package with spack blame:

$ spack blame openblas

Thank you for your help! Please don't add maintainers without their consent.

You don't have to be a Spack expert or package developer in order to be a "maintainer," it just gives us a list of users willing to review PRs or debug issues relating to this package. A package can have multiple maintainers; just add a list of GitHub handles of anyone who wants to volunteer.

@spackbot-app spackbot-app bot requested a review from pghysels February 3, 2023 13:55
@alalazo alalazo force-pushed the features/casd/cherry_pick_vdeps branch from 502e8ec to a97ae9a Compare February 3, 2023 13:56
@alalazo alalazo linked an issue Feb 3, 2023 that may be closed by this pull request
2 tasks
@alalazo alalazo force-pushed the features/compilers-as-deps branch from 8471718 to d9bf846 Compare February 3, 2023 18:37
@alalazo alalazo force-pushed the features/casd/cherry_pick_vdeps branch from 3902ec3 to 3da64e2 Compare February 3, 2023 18:38
@alalazo
Copy link
Member Author

alalazo commented Feb 6, 2023

@spackbot run pipeline

@spackbot-app
Copy link

spackbot-app bot commented Feb 6, 2023

I've started that pipeline for you!

@alalazo alalazo force-pushed the features/compilers-as-deps branch 2 times, most recently from d8ae02c to 6ad4286 Compare February 28, 2023 15:38
@alalazo alalazo force-pushed the features/compilers-as-deps branch from 6ad4286 to f5eb6ac Compare March 30, 2023 09:04
@alalazo alalazo force-pushed the features/casd/cherry_pick_vdeps branch from 3da64e2 to 3ac92ab Compare March 31, 2023 08:08
@RMeli
Copy link
Member

RMeli commented Apr 28, 2023

Hello. I tried this PR with the following spec:

cp2k@master +dlaf +libxc +libint +spglib build_system=cmake ^[virtuals=blas,lapack,scalapack,mkl]
    intel-mkl@2020.4.304 threads=openmp ^fftw ^cray-mpich

It returned this error, which is very cryptic:

==> Error: 
        cp2k@master+dlaf+libint+libxc+spglib build_system=cmake ^cray-mpich ^fftw ^[virtuals=blas,lapack,mkl,scalapack] intel-mkl@2020.4.304 threads=openmp is unsatisfiable, errors are:

That is, no error messages are actually printed for errors are:.

However, by removing mkl I was able to concretise the environment with both intel-mkl and fftw and everything seems to work as expected:

cp2k@master +dlaf +libxc +libint +spglib build_system=cmake ^[virtuals=blas,lapack,scalapack]
    intel-mkl@2020.4.304 threads=openmp ^fftw ^cray-mpich

This is a really neat and useful feature.

@alalazo
Copy link
Member Author

alalazo commented Apr 28, 2023

@RMeli Thanks for the feedback! Error messages are a pain point when working with ASP, we'll try to improve them considerably for v0.21 (so roughly going to November 2023) 🙂

@alalazo alalazo added this to the v0.21.0 milestone May 11, 2023
@alalazo alalazo force-pushed the features/casd/cherry_pick_vdeps branch from eae15ce to 6893fc1 Compare October 30, 2023 11:46
@alalazo
Copy link
Member Author

alalazo commented Oct 30, 2023

Not completely done, but here is a partial review.

@tgamblin ☝️

@alalazo alalazo force-pushed the features/casd/cherry_pick_vdeps branch from 6893fc1 to cc60cef Compare November 1, 2023 09:25
Copy link
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went over the rest of the code here and it LGTM.

@tgamblin tgamblin merged commit 16fa3b9 into spack:develop Nov 2, 2023
@alalazo alalazo deleted the features/casd/cherry_pick_vdeps branch November 2, 2023 07:32
gabrielctn pushed a commit to gabrielctn/spack that referenced this pull request Nov 24, 2023
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
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Dec 14, 2023
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
@haampie haampie mentioned this pull request Jul 8, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-systems commands core PR affects Spack core functionality dependencies directives documentation Improvements or additions to documentation environments new-variant new-version stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) update-package virtual-dependencies workflow

Projects

Development

Successfully merging this pull request may close these issues.

Finer selection of virtual providers in a DAG

5 participants