concretizer: add a configuration option to use new or old concretizer

- [x] spec.py can call out to the new concretizer
- [x] config.yaml now has an option to choose a concretizer (original, clingo)
This commit is contained in:
Todd Gamblin 2020-06-07 11:09:18 -07:00
parent 2dd06f14f9
commit 14ab63f97c
4 changed files with 51 additions and 1 deletions

View File

@ -145,6 +145,20 @@ config:
ccache: false ccache: false
# 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.
#
# 'clingo' currently requires the clingo ASP solver to be installed and
# built with python bindings. 'original' is built in.
concretizer: original
# How long to wait to lock the Spack installation database. This lock is used # How long to wait to lock the Spack installation database. This lock is used
# when Spack needs to manage its own package metadata and all operations are # when Spack needs to manage its own package metadata and all operations are
# expected to complete within the default time limit. The timeout should # expected to complete within the default time limit. The timeout should
@ -159,11 +173,13 @@ config:
# never succeed. # never succeed.
package_lock_timeout: null package_lock_timeout: null
# Control whether Spack embeds RPATH or RUNPATH attributes in ELF binaries. # Control whether Spack embeds RPATH or RUNPATH attributes in ELF binaries.
# Has no effect on macOS. DO NOT MIX these within the same install tree. # Has no effect on macOS. DO NOT MIX these within the same install tree.
# See the Spack documentation for details. # See the Spack documentation for details.
shared_linking: 'rpath' shared_linking: 'rpath'
# Set to 'false' to allow installation on filesystems that doesn't allow setgid bit # Set to 'false' to allow installation on filesystems that doesn't allow setgid bit
# manipulation by unprivileged user (e.g. AFS) # manipulation by unprivileged user (e.g. AFS)
allow_sgid: true allow_sgid: true

View File

@ -109,6 +109,7 @@
'dirty': False, 'dirty': False,
'build_jobs': min(16, multiprocessing.cpu_count()), 'build_jobs': min(16, multiprocessing.cpu_count()),
'build_stage': '$tempdir/spack-stage', 'build_stage': '$tempdir/spack-stage',
'concretizer': 'original',
} }
} }

View File

@ -82,6 +82,10 @@
'build_language': {'type': 'string'}, 'build_language': {'type': 'string'},
'build_jobs': {'type': 'integer', 'minimum': 1}, 'build_jobs': {'type': 'integer', 'minimum': 1},
'ccache': {'type': 'boolean'}, 'ccache': {'type': 'boolean'},
'concretizer': {
'type': 'string',
'enum': ['original', 'clingo']
},
'db_lock_timeout': {'type': 'integer', 'minimum': 1}, 'db_lock_timeout': {'type': 'integer', 'minimum': 1},
'package_lock_timeout': { 'package_lock_timeout': {
'anyOf': [ 'anyOf': [

View File

@ -97,12 +97,14 @@
import spack.architecture import spack.architecture
import spack.compiler import spack.compiler
import spack.compilers as compilers import spack.compilers as compilers
import spack.config
import spack.dependency as dp import spack.dependency as dp
import spack.error import spack.error
import spack.hash_types as ht import spack.hash_types as ht
import spack.parse import spack.parse
import spack.provider_index import spack.provider_index
import spack.repo import spack.repo
import spack.solver
import spack.store import spack.store
import spack.util.crypto import spack.util.crypto
import spack.util.executable import spack.util.executable
@ -2244,7 +2246,7 @@ def feq(cfield, sfield):
return changed return changed
def concretize(self, tests=False): def _old_concretize(self, tests=False):
"""A spec is concrete if it describes one build of a package uniquely. """A spec is concrete if it describes one build of a package uniquely.
This will ensure that this spec is concrete. This will ensure that this spec is concrete.
@ -2417,6 +2419,33 @@ def concretize(self, tests=False):
# there are declared inconsistencies) # there are declared inconsistencies)
self.architecture.target.optimization_flags(self.compiler) self.architecture.target.optimization_flags(self.compiler)
def _new_concretize(self, tests=False):
import spack.solver.asp
if not self.name:
raise spack.error.SpecError(
"Spec has no name; cannot concretize an anonymous spec")
result = spack.solver.asp.solve([self])
if not result.satisfiable:
raise spack.error.UnsatisfiableSpecError(
self, "unknown", "Unsatisfiable!")
# take the best answer
opt, i, answer = min(result.answers)
assert self.name in answer
concretized = answer[self.name]
self._dup(concretized)
self._mark_concrete()
#: choose your concretizer here.
def concretize(self, tests=False):
if spack.config.get('config:concretizer') == "original":
self._old_concretize(tests)
else:
self._new_concretize(tests)
def _mark_concrete(self, value=True): def _mark_concrete(self, value=True):
"""Mark this spec and its dependencies as concrete. """Mark this spec and its dependencies as concrete.