Created
March 13, 2021 01:35
-
-
Save tgamblin/83eba3c6d27f90d9fa3afebfc049ceaf to your computer and use it in GitHub Desktop.
Diffing specs by ASP facts in Spack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env spack-python | |
from pprint import pprint | |
from spack.spec import Spec | |
from spack.solver.asp import SpackSolverSetup | |
specs = [ | |
Spec("openblas +ilp64 +shared").concretized(), | |
Spec("openblas ~ilp64 +shared").concretized(), | |
Spec("openblas +ilp64 ~shared").concretized(), | |
Spec("openblas ~ilp64 ~shared").concretized(), | |
] | |
for spec in specs: | |
print(spec.tree()) | |
def to_tuple(asp_function): | |
return tuple([asp_function.name, *asp_function.args]) | |
setup = SpackSolverSetup() | |
def diff(a, b): | |
a_facts = set(to_tuple(t) for t in setup.spec_clauses(a)) | |
b_facts = set(to_tuple(t) for t in setup.spec_clauses(b)) | |
print(a_facts.difference(b_facts)) | |
print(b_facts.difference(a_facts)) | |
for i in range(len(specs)): | |
for j in range(len(specs)): | |
print("diff(%d, %d) ===============================" % (i, j)) | |
diff(specs[i], specs[j]) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment