예제 #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]]),
예제 #2
0
파일: generic.py 프로젝트: johnny90/lisa
    def _getExperimentsConf(cls, test_env):
        if not test_env.nrg_model:
            try:
                test_env.nrg_model = EnergyModel.from_target(test_env.target)
            except Exception as e:
                raise SkipTest(
                    'This test requires an EnergyModel for the platform. '
                    'Either provide one manually or ensure it can be read '
                    'from the filesystem: {}'.format(e))

        conf = {
            'tag': 'energy_aware',
            'flags': ['ftrace', 'freeze_userspace'],
        }

        if 'cpufreq' in test_env.target.modules:
            available_govs = test_env.target.cpufreq.list_governors(0)
            if 'schedutil' in available_govs:
                conf['cpufreq'] = {'governor': 'schedutil'}
            elif 'sched' in available_govs:
                conf['cpufreq'] = {'governor': 'sched'}

        return {
            'wloads': cls.workloads,
            'confs': [conf],
        }
예제 #3
0
파일: generic.py 프로젝트: msrasmussen/lisa
    def _getExperimentsConf(cls, test_env):
        if not test_env.nrg_model:
            try:
                test_env.nrg_model = EnergyModel.from_target(test_env.target)
            except Exception as e:
                raise SkipTest(
                    'This test requires an EnergyModel for the platform. '
                    'Either provide one manually or ensure it can be read '
                    'from the filesystem: {}'.format(e))

        conf = {
            'tag' : 'energy_aware',
            'flags' : ['ftrace', 'freeze_userspace'],
        }

        if 'cpufreq' in test_env.target.modules:
            available_govs = test_env.target.cpufreq.list_governors(0)
            if 'schedutil' in available_govs:
                conf['cpufreq'] = {'governor' : 'schedutil'}
            elif 'sched' in available_govs:
                conf['cpufreq'] = {'governor' : 'sched'}

        return {
            'wloads' : cls.workloads,
            'confs' : [conf],
        }
예제 #4
0

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])

예제 #5
0
def silver_cpu_node(cpu):
    return EnergyModelNode(cpu=cpu,
                           active_states=silver_cpu_active_states,
                           idle_states=cpu_idle_states)

def gold_cpu_node(cpu):
    return EnergyModelNode(cpu=cpu,
                           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"])

op3_energy = 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])
예제 #6
0
    def _init_target(self, force = False):

        if not force and self.target is not None:
            return self.target

        self.__connection_settings = {}

        # Configure username
        if 'username' in self.conf:
            self.__connection_settings['username'] = self.conf['username']
        else:
            self.__connection_settings['username'] = USERNAME_DEFAULT

        # Configure password or SSH keyfile
        if 'keyfile' in self.conf:
            self.__connection_settings['keyfile'] = self.conf['keyfile']
        elif 'password' in self.conf:
            self.__connection_settings['password'] = self.conf['password']
        else:
            self.__connection_settings['password'] = PASSWORD_DEFAULT

        # Configure port
        if 'port' in self.conf:
            self.__connection_settings['port'] = self.conf['port']

        # Configure the host IP/MAC address
        if 'host' in self.conf:
            try:
                if ':' in self.conf['host']:
                    (self.mac, self.ip) = self.resolv_host(self.conf['host'])
                else:
                    self.ip = self.conf['host']
                self.__connection_settings['host'] = self.ip
            except KeyError:
                raise ValueError('Config error: missing [host] parameter')

        try:
            platform_type = self.conf['platform']
        except KeyError:
            raise ValueError('Config error: missing [platform] parameter')

        if platform_type.lower() == 'android':
            self.ANDROID_HOME = self.conf.get('ANDROID_HOME',
                                              self.ANDROID_HOME)
            if self.ANDROID_HOME:
                self._adb = os.path.join(self.ANDROID_HOME,
                                         'platform-tools', 'adb')
                self._fastboot = os.path.join(self.ANDROID_HOME,
                                              'platform-tools', 'fastboot')
                os.environ['ANDROID_HOME'] = self.ANDROID_HOME
                os.environ['CATAPULT_HOME'] = self.CATAPULT_HOME
            else:
                raise RuntimeError('Android SDK not found, ANDROID_HOME must be defined!')

            self._log.info('External tools using:')
            self._log.info('   ANDROID_HOME: %s', self.ANDROID_HOME)
            self._log.info('   CATAPULT_HOME: %s', self.CATAPULT_HOME)

            if not os.path.exists(self._adb):
                raise RuntimeError('\nADB binary not found\n\t{}\ndoes not exists!\n\n'
                                   'Please configure ANDROID_HOME to point to '
                                   'a valid Android SDK installation folder.'\
                                   .format(self._adb))

        ########################################################################
        # Board configuration
        ########################################################################

        # Setup board default if not specified by configuration
        self.nrg_model = None
        platform = None
        self.__modules = ['cpufreq', 'cpuidle']
        if 'board' not in self.conf:
            self.conf['board'] = 'UNKNOWN'

        # Initialize TC2 board
        if self.conf['board'].upper() == 'TC2':
            platform = devlib.platform.arm.TC2()
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize JUNO board
        elif self.conf['board'].upper() in ('JUNO', 'JUNO2'):
            platform = devlib.platform.arm.Juno()
            self.nrg_model = juno_energy
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize OAK board
        elif self.conf['board'].upper() == 'OAK':
            platform = Platform(model='MT8173')
            self.__modules = ['bl', 'cpufreq']

        # Initialized HiKey board
        elif self.conf['board'].upper() == 'HIKEY':
            self.nrg_model = hikey_energy
            self.__modules = [ "cpufreq", "cpuidle" ]
            platform = Platform(model='hikey')

        # Initialize HiKey960 board
        elif self.conf['board'].upper() == 'HIKEY960':
            self.__modules = ['bl', 'cpufreq', 'cpuidle']
            platform = Platform(model='hikey960')

        # Initialize Pixel phone
        elif self.conf['board'].upper() == 'PIXEL':
            self.nrg_model = pixel_energy
            self.__modules = ['bl', 'cpufreq']
            platform = Platform(model='pixel')

        # Initialize gem5 platform
        elif self.conf['board'].upper() == 'GEM5':
            self.nrg_model = None
            self.__modules=['cpufreq']
            platform = self._init_target_gem5()

        elif self.conf['board'] != 'UNKNOWN':
            # Initilize from platform descriptor (if available)
            board = self._load_board(self.conf['board'])
            if board:
                core_names=board['cores']
                platform = Platform(
                    model=self.conf['board'],
                    core_names=core_names,
                    core_clusters = self._get_clusters(core_names),
                    big_core=board.get('big_core', None)
                )
                if 'modules' in board:
                    self.__modules = board['modules']

        ########################################################################
        # Modules configuration
        ########################################################################

        modules = set(self.__modules)

        # Refine modules list based on target.conf
        modules.update(self.conf.get('modules', []))
        # Merge tests specific modules
        modules.update(self.test_conf.get('modules', []))

        remove_modules = set(self.conf.get('exclude_modules', []) +
                             self.test_conf.get('exclude_modules', []))
        modules.difference_update(remove_modules)

        self.__modules = list(modules)
        self._log.info('Devlib modules to load: %s', self.__modules)

        ########################################################################
        # Devlib target setup (based on target.config::platform)
        ########################################################################

        # If the target is Android, we need just (eventually) the device
        if platform_type.lower() == 'android':
            self.__connection_settings = None
            device = 'DEFAULT'

            # Workaround for ARM-software/devlib#225
            if not self.workdir:
                self.workdir = '/data/local/tmp/devlib-target'

            if 'device' in self.conf:
                device = self.conf['device']
                self.__connection_settings = {'device' : device}
            elif 'host' in self.conf:
                host = self.conf['host']
                port = '5555'
                if 'port' in self.conf:
                    port = str(self.conf['port'])
                device = '{}:{}'.format(host, port)
                self.__connection_settings = {'device' : device}
            self._log.info('Connecting Android target [%s]', device)
        else:
            self._log.info('Connecting %s target:', platform_type)
            for key in self.__connection_settings:
                self._log.info('%10s : %s', key,
                               self.__connection_settings[key])

        self._log.info('Connection settings:')
        self._log.info('   %s', self.__connection_settings)

        if platform_type.lower() == 'linux':
            self._log.debug('Setup LINUX target...')
            if "host" not in self.__connection_settings:
                raise ValueError('Missing "host" param in Linux target conf')

            self.target = devlib.LinuxTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'android':
            self._log.debug('Setup ANDROID target...')
            self.target = devlib.AndroidTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'host':
            self._log.debug('Setup HOST target...')
            self.target = devlib.LocalLinuxTarget(
                    platform = platform,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules,
                    connection_settings = {'unrooted': True})
        else:
            raise ValueError('Config error: not supported [platform] type {}'\
                    .format(platform_type))

        self._log.debug('Checking target connection...')
        self._log.debug('Target info:')
        self._log.debug('      ABI: %s', self.target.abi)
        self._log.debug('     CPUs: %s', self.target.cpuinfo)
        self._log.debug(' Clusters: %s', self.target.core_clusters)

        self._log.info('Initializing target workdir:')
        self._log.info('   %s', self.target.working_directory)

        self.target.setup()
        self.install_tools(self.__tools)

        # Verify that all the required modules have been initialized
        for module in self.__modules:
            self._log.debug('Check for module [%s]...', module)
            if not hasattr(self.target, module):
                self._log.warning('Unable to initialize [%s] module', module)
                self._log.error('Fix your target kernel configuration or '
                                'disable module from configuration')
                raise RuntimeError('Failed to initialized [{}] module, '
                        'update your kernel or test configurations'.format(module))

        if not self.nrg_model:
            try:
                self._log.info('Attempting to read energy model from target')
                self.nrg_model = EnergyModel.from_target(self.target)
            except (TargetError, RuntimeError, ValueError) as e:
                self._log.error("Couldn't read target energy model: %s", e)
예제 #7
0
파일: env.py 프로젝트: credp/lisa
    def _init_target(self, force = False):

        if not force and self.target is not None:
            return self.target

        self.__connection_settings = {}

        # Configure username
        if 'username' in self.conf:
            self.__connection_settings['username'] = self.conf['username']
        else:
            self.__connection_settings['username'] = USERNAME_DEFAULT

        # Configure password or SSH keyfile
        if 'keyfile' in self.conf:
            self.__connection_settings['keyfile'] = self.conf['keyfile']
        elif 'password' in self.conf:
            self.__connection_settings['password'] = self.conf['password']
        else:
            self.__connection_settings['password'] = PASSWORD_DEFAULT

        # Configure port
        if 'port' in self.conf:
            self.__connection_settings['port'] = self.conf['port']

        # Configure the host IP/MAC address
        if 'host' in self.conf:
            try:
                if ':' in self.conf['host']:
                    (self.mac, self.ip) = self.resolv_host(self.conf['host'])
                else:
                    self.ip = self.conf['host']
                self.__connection_settings['host'] = self.ip
            except KeyError:
                raise ValueError('Config error: missing [host] parameter')

        try:
            platform_type = self.conf['platform']
        except KeyError:
            raise ValueError('Config error: missing [platform] parameter')

        if platform_type.lower() == 'android':
            self.ANDROID_HOME = self.conf.get('ANDROID_HOME',
                                              self.ANDROID_HOME)
            if self.ANDROID_HOME:
                self._adb = os.path.join(self.ANDROID_HOME,
                                         'platform-tools', 'adb')
                self._fastboot = os.path.join(self.ANDROID_HOME,
                                              'platform-tools', 'fastboot')
                os.environ['ANDROID_HOME'] = self.ANDROID_HOME
                os.environ['CATAPULT_HOME'] = self.CATAPULT_HOME
            else:
                raise RuntimeError('Android SDK not found, ANDROID_HOME must be defined!')

            self._log.info('External tools using:')
            self._log.info('   ANDROID_HOME: %s', self.ANDROID_HOME)
            self._log.info('   CATAPULT_HOME: %s', self.CATAPULT_HOME)

            if not os.path.exists(self._adb):
                raise RuntimeError('\nADB binary not found\n\t{}\ndoes not exists!\n\n'
                                   'Please configure ANDROID_HOME to point to '
                                   'a valid Android SDK installation folder.'\
                                   .format(self._adb))

        ########################################################################
        # Board configuration
        ########################################################################

        # Setup board default if not specified by configuration
        self.nrg_model = None
        platform = None
        self.__modules = ['cpufreq', 'cpuidle']
        if 'board' not in self.conf:
            self.conf['board'] = 'UNKNOWN'

        # Initialize TC2 board
        if self.conf['board'].upper() == 'TC2':
            platform = devlib.platform.arm.TC2()
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize JUNO board
        elif self.conf['board'].upper() in ('JUNO', 'JUNO2'):
            platform = devlib.platform.arm.Juno()
            self.nrg_model = juno_energy
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize OAK board
        elif self.conf['board'].upper() == 'OAK':
            platform = Platform(model='MT8173')
            self.__modules = ['bl', 'cpufreq']

        # Initialized HiKey board
        elif self.conf['board'].upper() == 'HIKEY':
            self.nrg_model = hikey_energy
            self.__modules = [ "cpufreq", "cpuidle" ]
            platform = Platform(model='hikey')

        # Initialize HiKey960 board
        elif self.conf['board'].upper() == 'HIKEY960':
            self.__modules = ['bl', 'cpufreq', 'cpuidle']
            platform = Platform(model='hikey960')

        # Initialize Pixel phone
        elif self.conf['board'].upper() == 'PIXEL':
            self.nrg_model = pixel_energy
            self.__modules = ['bl', 'cpufreq']
            platform = Platform(model='pixel')

        # Initialize gem5 platform
        elif self.conf['board'].upper() == 'GEM5':
            self.nrg_model = None
            self.__modules=['cpufreq']
            platform = self._init_target_gem5()

        elif self.conf['board'] != 'UNKNOWN':
            # Initilize from platform descriptor (if available)
            board = self._load_board(self.conf['board'])
            if board:
                core_names=board['cores']
                platform = Platform(
                    model=self.conf['board'],
                    core_names=core_names,
                    core_clusters = self._get_clusters(core_names),
                    big_core=board.get('big_core', None)
                )
                if 'modules' in board:
                    self.__modules = board['modules']

        ########################################################################
        # Modules configuration
        ########################################################################

        modules = set(self.__modules)

        # Refine modules list based on target.conf
        modules.update(self.conf.get('modules', []))
        # Merge tests specific modules
        modules.update(self.test_conf.get('modules', []))

        remove_modules = set(self.conf.get('exclude_modules', []) +
                             self.test_conf.get('exclude_modules', []))
        modules.difference_update(remove_modules)

        self.__modules = list(modules)
        self._log.info('Devlib modules to load: %s', self.__modules)

        ########################################################################
        # Devlib target setup (based on target.config::platform)
        ########################################################################

        # If the target is Android, we need just (eventually) the device
        if platform_type.lower() == 'android':
            self.__connection_settings = None
            device = 'DEFAULT'

            # Workaround for ARM-software/devlib#225
            if not self.workdir:
                self.workdir = '/data/local/tmp/devlib-target'

            if 'device' in self.conf:
                device = self.conf['device']
                self.__connection_settings = {'device' : device}
            elif 'host' in self.conf:
                host = self.conf['host']
                port = '5555'
                if 'port' in self.conf:
                    port = str(self.conf['port'])
                device = '{}:{}'.format(host, port)
                self.__connection_settings = {'device' : device}
            self._log.info('Connecting Android target [%s]', device)
        else:
            self._log.info('Connecting %s target:', platform_type)
            for key in self.__connection_settings:
                self._log.info('%10s : %s', key,
                               self.__connection_settings[key])

        self._log.info('Connection settings:')
        self._log.info('   %s', self.__connection_settings)

        if platform_type.lower() == 'linux':
            self._log.debug('Setup LINUX target...')
            if "host" not in self.__connection_settings:
                raise ValueError('Missing "host" param in Linux target conf')

            self.target = devlib.LinuxTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'android':
            self._log.debug('Setup ANDROID target...')
            self.target = devlib.AndroidTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'host':
            self._log.debug('Setup HOST target...')
            self.target = devlib.LocalLinuxTarget(
                    platform = platform,
                    working_directory = '/tmp/devlib-target',
                    executables_directory = '/tmp/devlib-target/bin',
                    load_default_modules = False,
                    modules = self.__modules,
                    connection_settings = {'unrooted': True})
        else:
            raise ValueError('Config error: not supported [platform] type {}'\
                    .format(platform_type))

        self._log.debug('Checking target connection...')
        self._log.debug('Target info:')
        self._log.debug('      ABI: %s', self.target.abi)
        self._log.debug('     CPUs: %s', self.target.cpuinfo)
        self._log.debug(' Clusters: %s', self.target.core_clusters)

        self._log.info('Initializing target workdir:')
        self._log.info('   %s', self.target.working_directory)

        self.target.setup()
        self.install_tools(self.__tools)

        # Verify that all the required modules have been initialized
        for module in self.__modules:
            self._log.debug('Check for module [%s]...', module)
            if not hasattr(self.target, module):
                self._log.warning('Unable to initialize [%s] module', module)
                self._log.error('Fix your target kernel configuration or '
                                'disable module from configuration')
                raise RuntimeError('Failed to initialized [{}] module, '
                        'update your kernel or test configurations'.format(module))

        if not self.nrg_model:
            try:
                self._log.info('Attempting to read energy model from target')
                self.nrg_model = EnergyModel.from_target(self.target)
            except (TargetError, RuntimeError, ValueError) as e:
                self._log.error("Couldn't read target energy model: %s", e)
예제 #8
0
                           active_states=a57_cpu_active_states,
                           idle_states=a57_cpu_idle_states)


juno_r0_energy = 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])
예제 #9
0
def cpu_pd(cpu):
    return PowerDomain(cpu=cpu, idle_states=['WFI', 'cpu-sleep'])


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


hikey_energy = 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]])