Skip to content

ASP: targets, compilers and providers soft-preferences are only global#31261

Merged
alalazo merged 3 commits intospack:developfrom
alalazo:asp/soft_preferences_semantic
Nov 7, 2023
Merged

ASP: targets, compilers and providers soft-preferences are only global#31261
alalazo merged 3 commits intospack:developfrom
alalazo:asp/soft_preferences_semantic

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Jun 23, 2022

fixes #31199
fixes #27055

A number of our soft preferences are broken and hard to make sense of when specified at the package level. Similarly, version when specified at the all: level is unintuitive -- there are very few situations where we'd want to universally prefer "1.0".

This PR disallows unintuitive per-package soft preferences in packages.yaml, and forces compilers:, targets:, and providers: to only appear at the all: level. Similarly, it disallows version: at the all: level and only allows it in per-package sections of packages.yaml.

The new require: style preferences are much more intuitive for setting one-off preferences in the DAG, and you can use them to force a node to use certain compilers, targets, or providers. Use require: instead of the preferences syntax if you need to be this specific.

Modifications:

  • target, compiler and providers soft-preferences can only be set under all: in packages.yaml
  • version can only be set under each specific package (and not under all:)
  • ASP code has a single set of weights for providers, targets and compilers (as opposed to different weights per package)
  • Modified documentation to reflect the change in packages.yaml
  • Added warnings to guide users if they have configurations which are not valid anymore

@spackbot-app spackbot-app bot added commands tests General test capability(ies) labels Jun 23, 2022
@alalazo alalazo requested review from becker33 and tgamblin June 23, 2022 10:22
@alalazo alalazo force-pushed the asp/soft_preferences_semantic branch 2 times, most recently from 58882ea to ec59165 Compare June 30, 2022 15:47
@alalazo

This comment was marked as outdated.

@tgamblin tgamblin added this to the v0.20.0 milestone Nov 7, 2022
@alalazo alalazo force-pushed the asp/soft_preferences_semantic branch from ec59165 to 3e7c089 Compare March 22, 2023 22:50
@spackbot-app spackbot-app bot added core PR affects Spack core functionality documentation Improvements or additions to documentation labels Mar 22, 2023
@alalazo alalazo force-pushed the asp/soft_preferences_semantic branch from 3e7c089 to b60fd34 Compare March 24, 2023 11:39
@alalazo alalazo marked this pull request as ready for review March 24, 2023 11:39
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Mar 24, 2023

Tested this change on a few concretizations that don't involve package preferences, and there is no impact. I used the same configuration for both and develop at d0d5526:

radiuss_develop.csv
radiuss_packages.csv
radiuss.txt

Here is a plot of the results:
totals

@frejanordsiek
Copy link
Copy Markdown

I have a couple thoughts on this due to running into one of the things this involves.

On the modifications

Modifications:

* [x]  `version` can only be set under each specific package (and not under `all:`) 
* [x]  Modified documentation to reflect the change in `packages.yaml`

* [x]  Added warnings to guide users if they have configurations which are not valid anymore

These changes are very sensible. The first one is kind of a surprise that it was this way at all. And the last one is the best approach when what is allowed in a config file changes.

* [x]  `target`, `compiler` and `providers` soft-preferences can only be set under `all:` in `packages.yaml`

I don't know about providers, but have some thoughts on target and compiler. My run in has been with target.

It is definitely true that forcing compiler and target to be global vastly simplifies things.

And with compiler, it certainly can help avoid some sticky issues for C++ based packages where unlike languages like C, built objects are not that compatible with each other due to different name mangling schemes, how exceptions are implemented, etc. with the exception of compilers that put serious work into being compatible with each other. Very easy to have a configuration that cannot be built. C++ isn't the only language in this situation, but it is the biggest offender. Fortran is as well, but to a much lesser degree, especially for legacy Fortran.

But, on compiler, one major issue is that if one wants to use compiler X for most things, but compiler X is incompatible with package A that is a dependency (say someone wants to use the Intel compiler for most things, but there are a few things that require GCC); then the user is completely out of luck unless they explicitly add that dependency to their package specs and configure concretization to reuse (which a user may not want for other reasons, but now their choice would be forced). For one package, this isn't too bad, but it doesn't scale that well compared to having this in the packages.yaml for the packages that apply, which has the added bonus of it ideally automatically applying when the package is installed.

On target, there are less sticky issues I think than on compiler. If the CPU can run all the targets, it probably doesn't matter much if the targets differ for different packages even if they are dependencies of each other so long as a function in one package isn't trying to say pass AVX512 registers to a function in another package that was compiled for an architecture that doesn't have them. But aren't those sorts of things usually passed on the stack or as pointers instead on x86? Though, even if so, that might not be true for non-x86 architectures and more sticky issues come up (spack does support many architectures after all, so choices need to keep them all in mind). I have a use case for having mismatched target, which is my horse in this race. But as it stands, the weights aren't sufficient to make my use case work at present anyways and I might be the only user who wants this (spack is used by many people and thus has to keep more in mind than just a single user, after all).

* [x]  ASP code has a single set of weights for providers, targets and compilers (as opposed to different weights per package)

I actually have a somewhat naive question on this. If the user specifically asks for a specific config, whether in their specs or in their packages.yaml, why consider any other option other than what was specifically requested and just warn the user if it looks like this will cause something that might not work (essentially trusting the user even if they might want something that will fail to build and/or run)? Is it that doing this means concretization outright fails all the time or something? Essentially, what problem/s is this scheme trying to solve?

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Apr 6, 2023

It is definitely true that forcing compiler and target to be global vastly simplifies things.

Just to be sure there are no misconceptions: I am forcing target and compiler preferences to be global. The DAG can be mixed as it was before. For instance:

$ spack spec hdf5 %clang target=icelake ^zlib %gcc target=x86_64

is still perfectly valid. Users can mix and match as they want, either using spec literals or the requirements in the configuration file.

If the user specifically asks for a specific config, whether in their specs [ ... ]

If the users asks for a specific configuration, i.e. they use spec literals or requirements, Spack either provides that or errors out. We have also a less strict "preferences" mechanism, and that's what I am touching here.

@frejanordsiek
Copy link
Copy Markdown

It is definitely true that forcing compiler and target to be global vastly simplifies things.

Just to be sure there are no misconceptions: I am forcing target and compiler preferences to be global. The DAG can be mixed as it was before. For instance:

$ spack spec hdf5 %clang target=icelake ^zlib %gcc target=x86_64

is still perfectly valid. Users can mix and match as they want, either using spec literals or the requirements in the configuration file.

If the user specifically asks for a specific config, whether in their specs [ ... ]

If the users asks for a specific configuration, i.e. they use spec literals or requirements, Spack either provides that or errors out. We have also a less strict "preferences" mechanism, and that's what I am touching here.

I don't know how I missed or misunderstood that feature. So, something like require: "target=X" would work and that is stronger than putting it the way that this PR would remove? If that is the case, then this PR basically gets rid of the weak path that doesn't always work while still keeping the much stronger path. In this case, then, I don't see any particular problems for this PR.

@alalazo alalazo force-pushed the asp/soft_preferences_semantic branch 2 times, most recently from 3a98fbd to 7e90bc8 Compare May 8, 2023 15:51
@alalazo alalazo force-pushed the asp/soft_preferences_semantic branch from 7e90bc8 to 8ddeaee Compare May 10, 2023 10:05
@alalazo alalazo modified the milestones: v0.20.0, v0.21.0 May 11, 2023
@alalazo alalazo removed this from the v0.21.0 milestone Jun 7, 2023
@alalazo alalazo force-pushed the asp/soft_preferences_semantic branch from 8ddeaee to 0c8b138 Compare June 14, 2023 11:23
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Oct 31, 2023

Benchmarked on:

  • Spack: 0.21.0.dev0 (fc49a02)
  • Python: 3.11.5
  • Platform: linux-ubuntu20.04-icelake
  • Concretizer: clingo

radiuss-pr.csv
radiuss-develop.csv
radiuss.txt

radiuss

There is no impact in performance.

alecbcs
alecbcs previously approved these changes Oct 31, 2023
Copy link
Copy Markdown
Member

@alecbcs alecbcs left a comment

Choose a reason for hiding this comment

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

This PR looks good to me. I agree with the previous discussion, I'm a fan of how this PR brings the functionality of the concretizer more into line with my general assumptions and gets rid of surprising behavior.

tgamblin
tgamblin previously approved these changes Nov 6, 2023
Modify the packages.yaml schema so that soft-preferences on targets,
compilers and providers can only be specified under the "all" attribute.
This makes them effectively global preferences.

Version preferences instead can only be specified under a package
specific section.

If a preference attribute is found in a section where it should
not be, it will be ignored and a warning is printed to screen.
@alalazo alalazo force-pushed the asp/soft_preferences_semantic branch from fc49a02 to 5ca20d2 Compare November 6, 2023 19:30
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Nov 6, 2023

This PR has no impact on the solver performance. Tested on:

  • Spack: 0.21.0.dev0 (5ca20d2)
  • Python: 3.11.5
  • Platform: linux-ubuntu20.04-icelake
  • Concretizer: clingo

develop: a2f0088
PR: 5ca20d2

radiuss-develop.csv
radiuss-pr.csv
radiuss.txt

radiuss

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Nov 6, 2023

If we use the following packages.yaml:

packages:
  all:
    version: ["1.0", "2.0"]
  hdf5:
    target: x86_64
    compiler: [gcc]
  zlib-ng:
    target: x86_64
    compiler: [clang]

we get these warnings:
Screenshot from 2023-11-06 20-36-58

@alecbcs
Copy link
Copy Markdown
Member

alecbcs commented Nov 6, 2023

I'd get rid of the Currently, in both error messages but otherwise I think this looks great.

@alalazo alalazo dismissed stale reviews from alecbcs and tgamblin via 1c9ccea November 6, 2023 19:58
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Nov 6, 2023

@alecbcs Done, see 1c9ccea

@alalazo alalazo requested review from alecbcs and tgamblin November 6, 2023 20:40
@alalazo alalazo enabled auto-merge (squash) November 6, 2023 21:10
@tgamblin tgamblin added this to the v0.21.0 milestone Nov 6, 2023
@alalazo alalazo disabled auto-merge November 7, 2023 06:45
@alalazo alalazo merged commit f3537bc into spack:develop Nov 7, 2023
@alalazo alalazo deleted the asp/soft_preferences_semantic branch November 7, 2023 06:46
gabrielctn added a commit to gabrielctn/spack that referenced this pull request Nov 7, 2023
gabrielctn pushed a commit to gabrielctn/spack that referenced this pull request Nov 24, 2023
spack#31261)

Modify the packages.yaml schema so that soft-preferences on targets,
compilers and providers can only be specified under the "all" attribute.
This makes them effectively global preferences.

Version preferences instead can only be specified under a package
specific section.

If a preference attribute is found in a section where it should
not be, it will be ignored and a warning is printed to screen.
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Dec 14, 2023
spack#31261)

Modify the packages.yaml schema so that soft-preferences on targets,
compilers and providers can only be specified under the "all" attribute.
This makes them effectively global preferences.

Version preferences instead can only be specified under a package
specific section.

If a preference attribute is found in a section where it should
not be, it will be ignored and a warning is printed to screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change commands concretization configuration core PR affects Spack core functionality documentation Improvements or additions to documentation tests General test capability(ies)

Projects

None yet

4 participants