diff options
-rw-r--r-- | etc/spack/defaults/concretizer.yaml | 17 | ||||
-rw-r--r-- | etc/spack/defaults/config.yaml | 11 | ||||
-rw-r--r-- | lib/spack/spack/config.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/schema/concretizer.py | 30 | ||||
-rw-r--r-- | lib/spack/spack/solver/asp.py | 9 |
5 files changed, 65 insertions, 6 deletions
diff --git a/etc/spack/defaults/concretizer.yaml b/etc/spack/defaults/concretizer.yaml new file mode 100644 index 0000000000..52200062c8 --- /dev/null +++ b/etc/spack/defaults/concretizer.yaml @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------- +# This is the default spack configuration file. +# +# Settings here are versioned with Spack and are intended to provide +# sensible defaults out of the box. Spack maintainers should edit this +# file to keep it current. +# +# Users can override these settings by editing +# `$SPACK_ROOT/etc/spack/concretizer.yaml`, `~/.spack/concretizer.yaml`, +# or by adding a `concretizer:` section to an environment. +# ------------------------------------------------------------------------- +concretizer: + # Whether to consider installed packages or packages from buildcaches when + # concretizing specs. If `true`, we'll try to use as many installs/binaries + # as possible, rather than building. If `false`, we'll always give you a fresh + # concretization. + reuse: false diff --git a/etc/spack/defaults/config.yaml b/etc/spack/defaults/config.yaml index eb0d4fc409..d0d3468e8d 100644 --- a/etc/spack/defaults/config.yaml +++ b/etc/spack/defaults/config.yaml @@ -155,14 +155,17 @@ config: # The concretization algorithm to use in Spack. Options are: # - # 'original': Spack's original greedy, fixed-point concretizer. This - # algorithm can make decisions too early and will not backtrack - # sufficiently for many specs. - # # 'clingo': Uses a logic solver under the hood to solve DAGs with full # backtracking and optimization for user preferences. Spack will # try to bootstrap the logic solver, if not already available. # + # 'original': Spack's original greedy, fixed-point concretizer. This + # algorithm can make decisions too early and will not backtrack + # sufficiently for many specs. This will soon be deprecated in + # favor of clingo. + # + # See `concretizer.yaml` for more settings you can fine-tune when + # using clingo. concretizer: clingo diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 6062634ca5..f9e3f2125a 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -53,6 +53,7 @@ import spack.platforms import spack.schema import spack.schema.bootstrap import spack.schema.compilers +import spack.schema.concretizer import spack.schema.config import spack.schema.env import spack.schema.mirrors @@ -69,6 +70,7 @@ from spack.util.cpus import cpus_available #: Dict from section names -> schema for that section section_schemas = { 'compilers': spack.schema.compilers.schema, + 'concretizer': spack.schema.concretizer.schema, 'mirrors': spack.schema.mirrors.schema, 'repos': spack.schema.repos.schema, 'packages': spack.schema.packages.schema, @@ -101,7 +103,7 @@ config_defaults = { 'dirty': False, 'build_jobs': min(16, cpus_available()), 'build_stage': '$tempdir/spack-stage', - 'concretizer': 'original', + 'concretizer': 'clingo', } } diff --git a/lib/spack/spack/schema/concretizer.py b/lib/spack/spack/schema/concretizer.py new file mode 100644 index 0000000000..e3bdde4adf --- /dev/null +++ b/lib/spack/spack/schema/concretizer.py @@ -0,0 +1,30 @@ +# Copyright 2013-2022 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) + +"""Schema for concretizer.yaml configuration file. + +.. literalinclude:: _spack_root/lib/spack/spack/schema/concretizer.py + :lines: 13- +""" + +properties = { + 'concretizer': { + 'type': 'object', + 'additionalProperties': False, + 'properties': { + 'reuse': {'type': 'boolean'}, + } + } +} + + +#: Full schema with metadata +schema = { + '$schema': 'http://json-schema.org/draft-07/schema#', + 'title': 'Spack concretizer configuration file schema', + 'type': 'object', + 'additionalProperties': False, + 'properties': properties, +} diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index a87fa445f9..1403077997 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -2060,7 +2060,11 @@ class Solver(object): self.set_default_configuration() def set_default_configuration(self): - self.reuse = False + # These properties are settable via spack configuration. `None` + # means go with the configuration setting; user can override. + self.reuse = None + + # these are concretizer settings self.dump = () self.models = 0 self.timers = False @@ -2079,6 +2083,9 @@ class Solver(object): continue spack.spec.Spec.ensure_valid_variants(s) + if self.reuse is None: + self.reuse = spack.config.get("concretizer:reuse", False) + setup = SpackSolverSetup(reuse=self.reuse, tests=self.tests) return driver.solve( setup, specs, self.dump, self.models, self.timers, self.stats |