From 9eb94be6dd3d790ff9c4238f6a328f0e03bb8f87 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sun, 8 Aug 2021 21:36:44 -0700 Subject: [PATCH] concretizer: only minimize builds when `--reuse` is enabled. Make the first minimization conditional on whether `--reuse` is enabled in the solve. If `--reuse` is not enabled, there will be nothing in the set to minimize and the objective function (for this criterion) will be 0 for every answer set. --- lib/spack/spack/solver/asp.py | 2 ++ lib/spack/spack/solver/concretize.lp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 88c2897e20..5fed553080 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1570,6 +1570,8 @@ def setup(self, driver, specs, tests=False, reuse=False): if reuse: self.gen.h1("Installed packages") + self.gen.fact(fn.optimize_for_reuse()) + self.gen.newline() self.define_installed_packages(possible) self.gen.h1('General Constraints') diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index efd364dd92..00c4100a58 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -794,7 +794,8 @@ build(Package) :- not hash(Package, _), node(Package). % Try hard to reuse installed packages (i.e., minimize the number built) opt_criterion(16, "number of packages to build (vs. reuse)"). #minimize { 0@16: #true }. -#minimize { 1@16,Package : build(Package) }. +#minimize { 1@16,Package : build(Package), optimize_for_reuse() }. +#defined optimize_for_reuse/0. % Minimize the number of deprecated versions being used opt_criterion(15, "deprecated versions used").