summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2021-10-22 02:37:08 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2021-11-05 00:15:47 -0700
commitb60a95cd5d037b6abf5aafff4e9c231f7f00dae4 (patch)
tree5fe7edb6775b07db2142d3ade59b764c64dc8cfc /lib
parentb88da9d73d9edd6df55e0f821daee026e48d3d45 (diff)
downloadspack-b60a95cd5d037b6abf5aafff4e9c231f7f00dae4.tar.gz
spack-b60a95cd5d037b6abf5aafff4e9c231f7f00dae4.tar.bz2
spack-b60a95cd5d037b6abf5aafff4e9c231f7f00dae4.tar.xz
spack-b60a95cd5d037b6abf5aafff4e9c231f7f00dae4.zip
concretizer: unify handling of single- and multi-valued variants
Multi-valued variants previously maximized default values to handle cases where the default contained two values, e.g.: variant("foo", default="bar,baz") This is because previously we were minimizing non-default values, and `foo=bar`, `foo=baz`, and `foo=bar,baz` all had the same score, as none of them had any "non-default" values. This commit changes the approach and considers a non-default value to be either a value set to something not default *or* the absence of a default value from the set value. This allows multi- and single-valued variants to be handled the same way, with the same minimization criterion. It alse means that the "best" value for every optimization criterion is now zero, which allows us to make useful assumptions about the optimization criteria.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/concretize.lp23
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index 2cb1512a33..cab54b9bd0 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -429,9 +429,11 @@ variant_value(Package, Variant, Value)
% whenever possible. If a variant is set in a spec, or if it is
% specified in an external, we score it as if it was a default value.
variant_not_default(Package, Variant, Value, 1)
- :- variant_value(Package, Variant, Value),
- not variant_default_value(Package, Variant, Value),
- not variant_set(Package, Variant, Value),
+ :- variant_value(Package, Variant, Actual),
+ not variant_value(Package, Variant, Value),
+ variant_default_value(Package, Variant, Value),
+ Actual != Value,
+ not variant_set(Package, Variant, Actual),
not external_with_variant_set(Package, Variant, Value),
node(Package).
@@ -937,21 +939,6 @@ opt_criterion(5, "version badness").
build_priority(Package, Priority)
}.
-% If the value is a multivalued variant there could be multiple
-% values set as default. Since a default value has a weight of 0 we
-% need to maximize their number below to ensure they're all set
-opt_criterion(104, "(build) number of values in multi valued variants (non-root)").
-opt_criterion(4, "number of values in multi valued variants (non-root)").
-#minimize{ 0@104 : #true }.
-#minimize{ 0@4 : #true }.
-#maximize {
- 1@4+Priority,Package,Variant,Value
- : variant_not_default(Package, Variant, Value, _),
- not variant_single_value(Package, Variant),
- not root(Package),
- build_priority(Package, Priority)
-}.
-
% Try to use preferred compilers
opt_criterion(103, "(build) non-preferred compilers").
opt_criterion(3, "non-preferred compilers").