summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-08-10 20:45:09 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commitf7dce19754057168aef1414e30319c21d24b8294 (patch)
tree7693fbbc1eadee2266471d9ca13f4ea2a5b087a8
parent34ea3d20cf6d4af8217e0135b504b258b8531874 (diff)
downloadspack-f7dce19754057168aef1414e30319c21d24b8294.tar.gz
spack-f7dce19754057168aef1414e30319c21d24b8294.tar.bz2
spack-f7dce19754057168aef1414e30319c21d24b8294.tar.xz
spack-f7dce19754057168aef1414e30319c21d24b8294.zip
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.
-rw-r--r--lib/spack/spack/solver/asp.py28
-rw-r--r--lib/spack/spack/solver/concretize.lp28
2 files changed, 41 insertions, 15 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 12ad5812c8..6d80b20b74 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -226,18 +226,14 @@ class AspGenerator(object):
# 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 @@ class AspGenerator(object):
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)
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index 6719eef7f2..b416b35e2b 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -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).