Reduce the dependency types in a solve

Count the maximum number of nodes based on dependency types
This commit is contained in:
Massimiliano Culpo 2023-06-21 06:29:16 +02:00 committed by Todd Gamblin
parent 22c95923e3
commit b7cc4bd247

View file

@ -1123,8 +1123,6 @@ def _rule_from_str(
def pkg_rules(self, pkg, tests): def pkg_rules(self, pkg, tests):
pkg = packagize(pkg) pkg = packagize(pkg)
self.gen.fact(fn.max_nodes(pkg.name, 1))
# versions # versions
self.pkg_version_rules(pkg) self.pkg_version_rules(pkg)
self.gen.newline() self.gen.newline()
@ -1321,6 +1319,8 @@ def package_dependencies_rules(self, pkg):
msg = "%s depends on %s" % (pkg.name, dep.spec.name) msg = "%s depends on %s" % (pkg.name, dep.spec.name)
if cond != spack.spec.Spec(): if cond != spack.spec.Spec():
msg += " when %s" % cond msg += " when %s" % cond
else:
pass
condition_id = self.condition(cond, dep.spec, pkg.name, msg) condition_id = self.condition(cond, dep.spec, pkg.name, msg)
self.gen.fact( self.gen.fact(
@ -2227,9 +2227,24 @@ def setup(self, driver, specs, reuse=None):
# get list of all possible dependencies # get list of all possible dependencies
self.possible_virtuals = set(x.name for x in specs if x.virtual) self.possible_virtuals = set(x.name for x in specs if x.virtual)
possible = spack.package_base.possible_dependencies(
*specs, virtuals=self.possible_virtuals, deptype=spack.dependency.all_deptypes link_run_dependency_types = ("link", "run", "test")
dependency_types = spack.dependency.all_deptypes
if not self.tests:
link_run_dependency_types = ("link", "run")
dependency_types = ("link", "run", "build")
link_run = spack.package_base.possible_dependencies(
*specs, virtuals=self.possible_virtuals, deptype=link_run_dependency_types
) )
direct_build = set()
for x in link_run:
current = spack.repo.path.get_pkg_class(x).dependencies_of_type("build")
direct_build.update(current)
total_build = spack.package_base.possible_dependencies(
*direct_build, virtuals=self.possible_virtuals, deptype=dependency_types
)
possible = set(link_run) | set(total_build)
# Fail if we already know an unreachable node is requested # Fail if we already know an unreachable node is requested
for spec in specs: for spec in specs:
@ -2272,6 +2287,12 @@ def setup(self, driver, specs, reuse=None):
for reusable_spec in reuse: for reusable_spec in reuse:
self._facts_from_concrete_spec(reusable_spec, possible) self._facts_from_concrete_spec(reusable_spec, possible)
self.gen.h1("Maximum number of nodes")
counter = collections.Counter(list(link_run) + list(total_build))
for pkg, count in sorted(counter.items()):
# FIXME (multiple nodes): should be count
self.gen.fact(fn.max_nodes(pkg, 1))
self.gen.h1("Possible flags on nodes") self.gen.h1("Possible flags on nodes")
for flag in spack.spec.FlagMap.valid_compiler_flags(): for flag in spack.spec.FlagMap.valid_compiler_flags():
self.gen.fact(fn.flag_type(flag)) self.gen.fact(fn.flag_type(flag))