Exemplo n.º 1
0
    def test_overlapping_freq_doms(self):
        """Can't build an EM with energy nodes overlapping freq domains"""

        # To make this easy we'll just use a single active state everywhere, and
        # no idle states
        active_states = {10000: ActiveState(capacity=1024, power=100)}

        def cpu_node(cpu):
            return EnergyModelNode(cpu=cpu,
                                   active_states=active_states,
                                   idle_states=[])

        root_node = EnergyModelRoot(children=[
            EnergyModelNode(
                name='cluster1',
                active_states=active_states,
                idle_states=[],
                children=[cpu_node(0), cpu_node(1)])])

        def cpu_pd(cpu):
            return PowerDomain(idle_states=[], cpu=cpu)

        with self.assertRaises(ValueError):
            EnergyModel(root_node=root_node,
                        root_power_domain=PowerDomain(
                            idle_states=[], children=[cpu_pd(0), cpu_pd(1)]),
                        freq_domains=[[0], [1]]),
Exemplo n.º 2
0
 def _nrg_model_from_target(cls, target):
     logger = cls.get_logger()
     logger.info('Attempting to read energy model from target')
     try:
         return EnergyModel.from_target(target)
     except (TargetStableError, RuntimeError, ValueError) as err:
         logger.error("Couldn't read target energy model: {}".format(err))
         return None
Exemplo n.º 3
0
                           active_states=gold_cpu_active_states,
                           idle_states=cpu_idle_states)


def cpu_pd(cpu):
    return PowerDomain(cpu=cpu, idle_states=["WFI", "cpu-sleep-0"])


nrg_model = EnergyModel(
    root_node=EnergyModelRoot(children=[
        EnergyModelNode(name='cluster_silver',
                        children=[silver_cpu_node(c) for c in silvers],
                        active_states=silver_cluster_active_states,
                        idle_states=cluster_idle_states),
        EnergyModelNode(name='cluster_gold',
                        children=[gold_cpu_node(c) for c in golds],
                        active_states=gold_cluster_active_states,
                        idle_states=cluster_idle_states)
    ]),
    root_power_domain=PowerDomain(
        idle_states=[],
        children=[
            PowerDomain(idle_states=['cluster-sleep-0'],
                        children=[cpu_pd(c) for c in silvers]),
            PowerDomain(idle_states=['cluster-sleep-0'],
                        children=[cpu_pd(c) for c in golds])
        ]),
    freq_domains=[silvers, golds])

# vim :set tabstop=4 shiftwidth=4 textwidth=80 expandtab
Exemplo n.º 4
0
    def add_target_src(self,
                       target,
                       rta_calib_res_dir,
                       src='target',
                       only_missing=True,
                       **kwargs):
        """
        Add source from a live :class:`lisa.target.Target`.

        :param target: Target to inspect.
        :type target: lisa.target.Target

        :param rta_calib_res_dir: Result directory for rt-app calibrations.
        :type rta_calib_res_dir: str

        :param src: Named of the added source.
        :type src: str

        :param only_missing: If ``True``, only add values for the keys that are
            not already provided by another source. This allows speeding up the
            connection to target, at the expense of not being able to spot
            inconsistencies between user-provided values and autodetected values.
        :type only_missing: bool

        :Variable keyword arguments: Forwarded to
            :class:`lisa.conf.MultiSrcConf.add_src`.
        """
        info = {
            'nrg-model': lambda: EnergyModel.from_target(target),
            'kernel': {
                'version': lambda: target.kernel_version,
                'config': lambda: target.config.typed_config,
            },
            'abi': lambda: target.abi,
            'os': lambda: target.os,
            'rtapp': {
                # Since it is expensive to compute, use an on-demand DeferredValue
                'calib':
                DeferredValue(RTA.get_cpu_calibrations, target,
                              rta_calib_res_dir)
            },
            'cpus-count': lambda: target.number_of_cpus,
            'numa-nodes-count': lambda: target.number_of_nodes
        }

        def get_freq_domains():
            if target.is_module_available('cpufreq'):
                return list(target.cpufreq.iter_domains())
            else:
                return None

        info['freq-domains'] = get_freq_domains

        def get_freqs():
            if target.is_module_available('cpufreq'):
                freqs = {
                    cpu: target.cpufreq.list_frequencies(cpu)
                    for cpu in range(target.number_of_cpus)
                }
                # Only add the frequency info if there is any, otherwise don't
                # mislead the client code with empty frequency list
                if all(freqs.values()):
                    return freqs
                else:
                    return None
            else:
                return None

        info['freqs'] = get_freqs

        @memoized
        def get_orig_capacities():
            if target.is_module_available('sched'):
                return target.sched.get_capacities(default=1024)
            else:
                return None

        def get_writeable_capacities():
            orig_capacities = get_orig_capacities()

            if orig_capacities is None:
                return None
            else:
                cpu = 0
                path = '/sys/devices/system/cpu/cpu{}/cpu_capacity'.format(cpu)
                capa = orig_capacities[cpu]
                test_capa = capa - 1 if capa > 1 else capa + 1

                try:
                    target.write_value(path, test_capa, verify=True)
                except TargetStableError:
                    writeable = False
                else:
                    writeable = True
                finally:
                    with contextlib.suppress(TargetStableError):
                        target.write_value(path, capa)

                return writeable

        info['cpu-capacities'] = {
            'writeable': get_writeable_capacities,
            'orig': get_orig_capacities,
        }

        info['kernel']['symbols-address'] = DeferredValue(
            self._read_kallsyms, target)

        return self._add_info(src,
                              info,
                              only_missing=only_missing,
                              filter_none=True,
                              **kwargs)
Exemplo n.º 5
0
 def test_serialization(self):
     path = os.path.join(self.res_dir, "nrg_model")
     em.to_path(path)
     stored_em = EnergyModel.from_path(path)
Exemplo n.º 6
0
                           idle_states=big_cpu_idle_states)


em = EnergyModel(
    root_node=EnergyModelRoot(children=[
        EnergyModelNode(name='cluster_little',
                        active_states=little_cluster_active_states,
                        idle_states=little_cluster_idle_states,
                        children=[little_cpu_node(0),
                                  little_cpu_node(1)]),
        EnergyModelNode(name='cluster_big',
                        active_states=big_cluster_active_states,
                        idle_states=big_cluster_idle_states,
                        children=[big_cpu_node(2),
                                  big_cpu_node(3)])
    ]),
    root_power_domain=PowerDomain(idle_states=[], children=[
        PowerDomain(
            idle_states=['cluster-sleep-0'],
            children=[PowerDomain(idle_states=['WFI', 'cpu-sleep-0'], cpu=c)
                      for c in littles]),
        PowerDomain(
            idle_states=['cluster-sleep-0'],
            children=[PowerDomain(idle_states=['WFI', 'cpu-sleep-0'], cpu=c)
                      for c in bigs]),
    ]),
    freq_domains=[littles, bigs]
)


class TestInvalid(TestCase):
Exemplo n.º 7
0
                           idle_states=a57_cpu_idle_states)


nrg_model = EnergyModel(
    root_node=EnergyModelRoot(children=[
        EnergyModelNode(name="cluster_a53",
                        active_states=a53_cluster_active_states,
                        idle_states=a53_cluster_idle_states,
                        children=[a53_cpu_node(c) for c in a53s]),
        EnergyModelNode(name="cluster_a57",
                        active_states=a57_cluster_active_states,
                        idle_states=a57_cluster_idle_states,
                        children=[a57_cpu_node(c) for c in a57s])
    ]),
    root_power_domain=PowerDomain(
        idle_states=[],
        children=[
            PowerDomain(idle_states=["cluster-sleep-0"],
                        children=[
                            PowerDomain(idle_states=["WFI", "cpu-sleep-0"],
                                        cpu=c) for c in a57s
                        ]),
            PowerDomain(idle_states=["cluster-sleep-0"],
                        children=[
                            PowerDomain(idle_states=["WFI", "cpu-sleep-0"],
                                        cpu=c) for c in a53s
                        ])
        ]),
    freq_domains=[a53s, a57s])

# vim :set tabstop=4 shiftwidth=4 textwidth=80 expandtab
Exemplo n.º 8
0

def cpu_node(cpu):
    return EnergyModelNode(cpu=cpu,
                           active_states=cpu_active_states,
                           idle_states=cpu_idle_states)


nrg_model = EnergyModel(
    root_node=EnergyModelRoot(children=[
        EnergyModelNode(name='cluster0',
                        children=[cpu_node(c) for c in [0, 1, 2, 3]],
                        active_states=cluster_active_states,
                        idle_states=cluster_idle_states),
        EnergyModelNode(name='cluster1',
                        children=[cpu_node(c) for c in [4, 5, 6, 7]],
                        active_states=cluster_active_states,
                        idle_states=cluster_idle_states)
    ]),
    root_power_domain=PowerDomain(
        idle_states=[],
        children=[
            PowerDomain(idle_states=["cluster-sleep"],
                        children=[cpu_pd(c) for c in [0, 1, 2, 3]]),
            PowerDomain(idle_states=["cluster-sleep"],
                        children=[cpu_pd(c) for c in [4, 5, 6, 7]])
        ]),
    freq_domains=[[0, 1, 2, 3, 4, 5, 6, 7]])

# vim :set tabstop=4 shiftwidth=4 textwidth=80 expandtab