Fix attribute error
Compiler flag test still fail
This commit is contained in:
parent
be5f1bd9d7
commit
f4762cfe7b
@ -949,13 +949,10 @@ def visit(node):
|
||||
if not setup.concretize_everything:
|
||||
self.control.load(os.path.join(parent_dir, "when_possible.lp"))
|
||||
|
||||
tty.debug(f"Pyclingodriver attrs: {self.__dir__()}")
|
||||
has_propagation = False
|
||||
for spec in specs:
|
||||
for dep in spec.traverse(root=True):
|
||||
has_propagation |= self._compiler_flags_has_propagation(dep.compiler_flags)
|
||||
if has_propagation:
|
||||
self.control.load(os.path.join(parent_dir, "propagation.lp"))
|
||||
if self._compiler_flags_has_propagation(spec.compiler_flags):
|
||||
self.control.load(os.path.join(parent_dir, "propagation.lp"))
|
||||
break
|
||||
|
||||
timer.stop("load")
|
||||
|
||||
@ -1037,6 +1034,12 @@ def on_model(model):
|
||||
|
||||
return result, timer, self.control.statistics
|
||||
|
||||
def _compiler_flags_has_propagation(self, flags):
|
||||
for _, flag_vals in flags.items():
|
||||
if any(val.propagate for val in flag_vals):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class ConcreteSpecsByHash(collections.abc.Mapping):
|
||||
"""Mapping containing concrete specs keyed by DAG hash.
|
||||
@ -1101,12 +1104,6 @@ def __len__(self) -> int:
|
||||
def __iter__(self):
|
||||
return iter(self.data)
|
||||
|
||||
def _compiler_flags_has_propagation(self, flags):
|
||||
for _, flag_vals in flags.items():
|
||||
if any(val.propagate for val in flag_vals):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class SpackSolverSetup:
|
||||
"""Class to set up and run a Spack concretization solve."""
|
||||
@ -1936,7 +1933,7 @@ class Head:
|
||||
node_compiler_version = fn.attr("node_compiler_version_set")
|
||||
node_flag = fn.attr("node_flag_set")
|
||||
node_flag_source = fn.attr("node_flag_source")
|
||||
node_flag_possible_prop = fn.attr("node_flag_possible_prop")
|
||||
node_flag_propagation_candidate= fn.attr("node_flag_propagation_candidate")
|
||||
variant_propagation_candidate = fn.attr("variant_propagation_candidate")
|
||||
|
||||
class Body:
|
||||
@ -1950,7 +1947,7 @@ class Body:
|
||||
node_compiler_version = fn.attr("node_compiler_version")
|
||||
node_flag = fn.attr("node_flag")
|
||||
node_flag_source = fn.attr("node_flag_source")
|
||||
node_flag_possible_prop = fn.attr("node_flag_possible_prop")
|
||||
node_flag_propagation_candidate= fn.attr("node_flag_propagation_candidate")
|
||||
variant_propagation_candidate = fn.attr("variant_propagation_candidate")
|
||||
|
||||
f = Body if body else Head
|
||||
@ -2036,7 +2033,7 @@ class Body:
|
||||
clauses.append(f.node_flag_source(spec.name, flag_type, spec.name))
|
||||
if not spec.concrete and flag.propagate is True:
|
||||
clauses.append(
|
||||
f.node_flag_possible_prop(spec.name, flag_type, flag, spec.name)
|
||||
f.node_flag_propagation_candidate(spec.name, flag_type, flag, spec.name)
|
||||
)
|
||||
|
||||
# dependencies
|
||||
|
@ -110,7 +110,6 @@ unification_set(SetID, VirtualNode)
|
||||
|
||||
% Node attributes that have multiple node arguments (usually, only the first argument is a node)
|
||||
multiple_nodes_attribute("node_flag_source").
|
||||
multiple_nodes_attribute("node_flag_possible_prop").
|
||||
multiple_nodes_attribute("depends_on").
|
||||
multiple_nodes_attribute("virtual_on_edge").
|
||||
multiple_nodes_attribute("provider_set").
|
||||
@ -1244,6 +1243,30 @@ attr("node_flag_compiler_default", PackageNode)
|
||||
% if a flag is set to something or inherited, it's included
|
||||
attr("node_flag", PackageNode, FlagType, Flag) :- attr("node_flag_set", PackageNode, FlagType, Flag).
|
||||
|
||||
attr("node_flag_propagate", PackageNode, FlagType, Flag, Source) :-
|
||||
attr("node_flag_propagation_candidate", PackageNode, FlagType, Flag, Source),
|
||||
not attr("node_flag_set", PackageNode, FlagType, _).
|
||||
|
||||
% source is a node() attribute
|
||||
attr("node_flag_propagation_candidate", PackageNode, FlagType, Flag, Source) :-
|
||||
same_compiler(ParentNode, PackageNode),
|
||||
attr("node_flag_propagation_candidate", ParentNode, FlagType, _, Source),
|
||||
attr("node_flag", Source, FlagType, Flag),
|
||||
flag_type(FlagType).
|
||||
|
||||
error(100, "{0} and {1} cannot both propagate compiler flags '{2}' to {3}", Source1, Source2, PackageNode, FlagType) :-
|
||||
same_compiler(Source1, PackageNode),
|
||||
same_compiler(Source2, PackageNode),
|
||||
attr("node_flag_propagate", _, FlagType, _, Source1),
|
||||
attr("node_flag_propagate", _, FlagType, _, Source2),
|
||||
Source1 < Source2.
|
||||
|
||||
attr("node_flag_source", PackageNode, FlagType, Q)
|
||||
:- attr("node_flag_propagate", PackageNode, FlagType, _, Q).
|
||||
|
||||
attr("node_flag", PackageNode, FlagType, Flag) :- attr("node_flag_propagate", PackageNode, FlagType, Flag, _).
|
||||
|
||||
|
||||
% if no node flags are set for a type, there are no flags.
|
||||
attr("no_flags", PackageNode, FlagType)
|
||||
:- not attr("node_flag", PackageNode, FlagType, _),
|
||||
|
@ -9,12 +9,12 @@
|
||||
|
||||
% propagate flags when compiler match
|
||||
attr("node_flag_propagate", PackageNode, FlagType, Flag, Source) :- % source is a node() attribute
|
||||
attr("node_flag_possible_prop", PackageNode, FlagType, Flag, Source),
|
||||
attr("node_flag_propagation_candidate", PackageNode, FlagType, Flag, Source),
|
||||
not attr("node_flag_set", PackageNode, FlagType, _).
|
||||
|
||||
attr("node_flag_possible_prop", PackageNode, FlagType, Flag, Source) :- % source is a node() attribute
|
||||
attr("node_flag_propagation_candidate", PackageNode, FlagType, Flag, Source) :- % source is a node() attribute
|
||||
same_compiler(ParentNode, PackageNode),
|
||||
attr("node_flag_possible_prop", ParentNode, FlagType, _, Source),
|
||||
attr("node_flag_propagation_candidate", ParentNode, FlagType, _, Source),
|
||||
attr("node_flag", Source, FlagType, Flag),
|
||||
flag_type(FlagType).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user