concretizer: simplify and move architecture semantics into concretize.lp
- Model architecture default settings and propagation off of variants - Leverage ASP default logic to set architecture to default if it's not set otherwise. - Move logic out of Python and into concretize.lp as first-order rules.
This commit is contained in:
parent
34ea3d20cf
commit
f7dce19754
2 changed files with 41 additions and 15 deletions
|
@ -226,18 +226,14 @@ def spec_rules(self, spec):
|
|||
|
||||
# seed architecture at the root (we'll propagate later)
|
||||
# TODO: use better semantics.
|
||||
arch = spack.spec.ArchSpec(spack.architecture.sys_type())
|
||||
spec_arch = spec.architecture
|
||||
if spec_arch:
|
||||
if spec_arch.platform:
|
||||
arch.platform = spec_arch.platform
|
||||
if spec_arch.os:
|
||||
arch.os = spec_arch.os
|
||||
if spec_arch.target:
|
||||
arch.target = spec_arch.target
|
||||
self.fact(fn.arch_platform(spec.name, arch.platform))
|
||||
self.fact(fn.arch_os(spec.name, arch.os))
|
||||
self.fact(fn.arch_target(spec.name, arch.target))
|
||||
arch = spec.architecture
|
||||
if arch:
|
||||
if arch.platform:
|
||||
self.fact(fn.arch_platform_set(spec.name, arch.platform))
|
||||
if arch.os:
|
||||
self.fact(fn.arch_os_set(spec.name, arch.os))
|
||||
if arch.target:
|
||||
self.fact(fn.arch_target_set(spec.name, arch.target))
|
||||
|
||||
# variants
|
||||
for vname, variant in spec.variants.items():
|
||||
|
@ -268,6 +264,14 @@ def generate_asp_program(self, specs):
|
|||
concretize_lp = pkgutil.get_data('spack.solver', 'concretize.lp')
|
||||
self.out.write(concretize_lp.decode("utf-8"))
|
||||
|
||||
self.h1('General Constraints')
|
||||
|
||||
self.h2('Default architecture')
|
||||
default_arch = spack.spec.ArchSpec(spack.architecture.sys_type())
|
||||
self.fact(fn.arch_platform_default(default_arch.platform))
|
||||
self.fact(fn.arch_os_default(default_arch.os))
|
||||
self.fact(fn.arch_target_default(default_arch.target))
|
||||
|
||||
self.h1('Package Constraints')
|
||||
for pkg in pkgs:
|
||||
self.h2('Package: %s' % pkg)
|
||||
|
|
|
@ -39,7 +39,29 @@ variant_value(P, V, X) :- node(P), variant(P, V), not variant_set(P, V),
|
|||
% Architecture semantics
|
||||
%-----------------------------------------------------------------------------
|
||||
|
||||
% arch fields for pkg P are set if set to anything
|
||||
arch_platform_set(P) :- arch_platform_set(P, _).
|
||||
arch_os_set(P) :- arch_os_set(P, _).
|
||||
arch_target_set(P) :- arch_target_set(P, _).
|
||||
|
||||
% avoid info warnings (see variants)
|
||||
#defined arch_platform_set/2.
|
||||
#defined arch_os_set/2.
|
||||
#defined arch_target_set/2.
|
||||
|
||||
% if architecture value is set, it's the value
|
||||
arch_platform(P, A) :- node(P), arch_platform_set(P, A).
|
||||
arch_os(P, A) :- node(P), arch_os_set(P, A).
|
||||
arch_target(P, A) :- node(P), arch_target_set(P, A).
|
||||
|
||||
% if no architecture is set, fall back to the default architecture value.
|
||||
arch_platform(P, A) :- node(P), not arch_platform_set(P),
|
||||
arch_platform_default(A).
|
||||
arch_os(P, A) :- node(P), not arch_os_set(P), arch_os_default(A).
|
||||
arch_target(P, A) :- node(P), not arch_target_set(P), arch_target_default(A).
|
||||
|
||||
% propagate platform, os, target downwards
|
||||
arch_platform(D, A) :- node(D), depends_on(P, D), arch_platform(P, A).
|
||||
arch_os(D, A) :- node(D), depends_on(P, D), arch_os(P, A).
|
||||
arch_target(D, A) :- node(D), depends_on(P, D), arch_target(P, A).
|
||||
% TODO: handle multiple dependents and arch compatibility
|
||||
arch_platform_set(D, A) :- node(D), depends_on(P, D), arch_platform_set(P, A).
|
||||
arch_os_set(D, A) :- node(D), depends_on(P, D), arch_os_set(P, A).
|
||||
arch_target_set(D, A) :- node(D), depends_on(P, D), arch_target_set(P, A).
|
||||
|
|
Loading…
Reference in a new issue