def target_defaults(self, specs):
    'Add facts about targets and target compatibility.'
    self.gen.h2('Default target')
    platform = spack.architecture.platform()
    uarch = archspec.cpu.TARGETS.get(platform.default)
    self.gen.h2('Target compatibility')
    compatible_targets = ([uarch] + uarch.ancestors)
    additional_targets_in_family = sorted([t for t in archspec.cpu.TARGETS.values() if ((t.family.name == uarch.family.name) and (t not in compatible_targets))], key=(lambda x: len(x.ancestors)), reverse=True)
    compatible_targets += additional_targets_in_family
    compilers = self.possible_compilers
    best_targets = set([uarch.family.name])
    for compiler in sorted(compilers):
        supported = self._supported_targets(compiler.name, compiler.version, compatible_targets)
        if (not supported):
            compiler_obj = spack.compilers.compilers_for_spec(compiler)
            compiler_obj = compiler_obj[0]
            supported = self._supported_targets(compiler.name, compiler_obj.real_version, compatible_targets)
        if (not supported):
            continue
        for target in supported:
            best_targets.add(target.name)
            self.gen.fact(fn.compiler_supports_target(compiler.name, compiler.version, target.name))
            self.gen.fact(fn.compiler_supports_target(compiler.name, compiler.version, uarch.family.name))
    for spec in specs:
        if ((not spec.architecture) or (not spec.architecture.target)):
            continue
        target = archspec.cpu.TARGETS.get(spec.target.name)
        if (not target):
            self.target_ranges(spec, None)
            continue
        if (target not in compatible_targets):
            compatible_targets.append(target)
    i = 0
    for target in compatible_targets:
        self.gen.fact(fn.target(target.name))
        self.gen.fact(fn.target_family(target.name, target.family.name))
        for parent in sorted(target.parents):
            self.gen.fact(fn.target_parent(target.name, parent.name))
        if (target.name in best_targets):
            self.gen.fact(fn.default_target_weight(target.name, i))
            i += 1
        else:
            self.gen.fact(fn.default_target_weight(target.name, 100))
        self.gen.newline()
Add facts about targets and target compatibility.
def target_defaults(self, specs):
    
    self.gen.h2('Default target')
    platform = spack.architecture.platform()
    uarch = archspec.cpu.TARGETS.get(platform.default)
    self.gen.h2('Target compatibility')
    compatible_targets = ([uarch] + uarch.ancestors)
    additional_targets_in_family = sorted([t for t in archspec.cpu.TARGETS.values() if ((t.family.name == uarch.family.name) and (t not in compatible_targets))], key=(lambda x: len(x.ancestors)), reverse=True)
    compatible_targets += additional_targets_in_family
    compilers = self.possible_compilers
    best_targets = set([uarch.family.name])
    for compiler in sorted(compilers):
        supported = self._supported_targets(compiler.name, compiler.version, compatible_targets)
        if (not supported):
            compiler_obj = spack.compilers.compilers_for_spec(compiler)
            compiler_obj = compiler_obj[0]
            supported = self._supported_targets(compiler.name, compiler_obj.real_version, compatible_targets)
        if (not supported):
            continue
        for target in supported:
            best_targets.add(target.name)
            self.gen.fact(fn.compiler_supports_target(compiler.name, compiler.version, target.name))
            self.gen.fact(fn.compiler_supports_target(compiler.name, compiler.version, uarch.family.name))
    for spec in specs:
        if ((not spec.architecture) or (not spec.architecture.target)):
            continue
        target = archspec.cpu.TARGETS.get(spec.target.name)
        if (not target):
            self.target_ranges(spec, None)
            continue
        if (target not in compatible_targets):
            compatible_targets.append(target)
    i = 0
    for target in compatible_targets:
        self.gen.fact(fn.target(target.name))
        self.gen.fact(fn.target_family(target.name, target.family.name))
        for parent in sorted(target.parents):
            self.gen.fact(fn.target_parent(target.name, parent.name))
        if (target.name in best_targets):
            self.gen.fact(fn.default_target_weight(target.name, i))
            i += 1
        else:
            self.gen.fact(fn.default_target_weight(target.name, 100))
        self.gen.newline()