Create a separate file for compiler flag propagation
This commit is contained in:
parent
b8c373f51e
commit
3c9bac5861
@ -862,6 +862,13 @@ def visit(node):
|
|||||||
self.control.load(os.path.join(parent_dir, "display.lp"))
|
self.control.load(os.path.join(parent_dir, "display.lp"))
|
||||||
if not setup.concretize_everything:
|
if not setup.concretize_everything:
|
||||||
self.control.load(os.path.join(parent_dir, "when_possible.lp"))
|
self.control.load(os.path.join(parent_dir, "when_possible.lp"))
|
||||||
|
flags = []
|
||||||
|
for spec in specs:
|
||||||
|
flags.append(spec.compiler_flags)
|
||||||
|
|
||||||
|
if self._compiler_flag_has_propagation(flags):
|
||||||
|
self.control.load(os.path.join(parent_dir, "propagation.lp"))
|
||||||
|
|
||||||
timer.stop("load")
|
timer.stop("load")
|
||||||
|
|
||||||
# Grounding is the first step in the solve -- it turns our facts
|
# Grounding is the first step in the solve -- it turns our facts
|
||||||
@ -970,6 +977,13 @@ def _model_has_cycles(self, models):
|
|||||||
|
|
||||||
return cycle_result.unsatisfiable
|
return cycle_result.unsatisfiable
|
||||||
|
|
||||||
|
def _compiler_flag_has_propagation(self, flags):
|
||||||
|
for flag in flags:
|
||||||
|
for flag_type, flag_vals in flag.items():
|
||||||
|
if any(val.propagate for val in flag_vals):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class SpackSolverSetup:
|
class SpackSolverSetup:
|
||||||
"""Class to set up and run a Spack concretization solve."""
|
"""Class to set up and run a Spack concretization solve."""
|
||||||
|
32
lib/spack/spack/solver/propagation.lp
Normal file
32
lib/spack/spack/solver/propagation.lp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
% Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
|
||||||
|
% Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||||
|
%
|
||||||
|
% SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
|
%=============================================================================
|
||||||
|
% TODO: Later
|
||||||
|
%=============================================================================
|
||||||
|
|
||||||
|
#program propagate_node_flag.
|
||||||
|
% 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),
|
||||||
|
not attr("node_flag_set", PackageNode, FlagType, _).
|
||||||
|
|
||||||
|
attr("node_flag_possible_prop", PackageNode, FlagType, Flag, Source) :- % source is a node() attribute
|
||||||
|
same_compiler(ParentNode, PackageNode),
|
||||||
|
attr("node_flag_possible_prop", 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, _).
|
Loading…
Reference in New Issue
Block a user