Ejemplo n.º 1
0
    def __init__(self, target, hwmon_conf=None):
        super(HWMon, self).__init__(target)

        # The HWMon energy meter
        self._hwmon = None

        # Energy readings
        self.readings = {}

        if 'hwmon' not in self._target.modules:
            logging.info('%14s - HWMON module not enabled',
                    'EnergyMeter')
            logging.warning('%14s - Energy sampling disabled by configuration',
                    'EnergyMeter')
            return

        # Initialize HWMON instrument
        logging.info('%14s - Scanning for HWMON channels, may take some time...', 'EnergyMeter')
        self._hwmon = devlib.HwmonInstrument(self._target)

        # Configure channels for energy measurements
        logging.debug('%14s - Enabling channels %s', 'EnergyMeter', hwmon_conf)
        self._hwmon.reset(**hwmon_conf)

        # Logging enabled channels
        logging.info('%14s - Channels selected for energy sampling:',
                     'EnergyMeter')
        for channel in self._hwmon.active_channels:
            logging.info('%14s -    %s', 'EnergyMeter', channel.label)
Ejemplo n.º 2
0
    def __init__(self, target, conf=None, res_dir=None):
        super(HWMon, self).__init__(target, res_dir)

        # The HWMon energy meter
        self._hwmon = None

        # Energy readings
        self.readings = {}

        if 'hwmon' not in self._target.modules:
            logging.info('%14s - HWMON module not enabled', 'HWMon')
            logging.warning('%14s - Energy sampling disabled by configuration',
                            'HWMon')
            return

        # Initialize HWMON instrument
        logging.info('%14s - Scanning for HWMON channels, may take some time...', 'HWMon')
        self._hwmon = devlib.HwmonInstrument(self._target)

        # Configure channels for energy measurements
        logging.debug('%14s - Enabling channels %s', 'HWMon', conf['conf'])
        self._hwmon.reset(**conf['conf'])

        # Logging enabled channels
        logging.info('%14s - Channels selected for energy sampling:', 'HWMon')
        for channel in self._hwmon.active_channels:
            logging.info('%14s -    %s', 'HWMon', channel.label)

        # record the HWMon channels
        self._channels = conf.get('channel_map', {
            'LITTLE': self._target.little_core.upper(),
            'big': self._target.big_core.upper()
        })
Ejemplo n.º 3
0
    def __init__(self, target, channel_map, res_dir=None):
        super().__init__(target, res_dir)
        logger = self.get_logger()

        # Energy readings
        self.readings = {}

        if 'hwmon' not in self._target.modules:
            raise RuntimeError('HWMON devlib module not enabled')

        # Initialize HWMON instrument
        logger.info('Scanning for HWMON channels, may take some time...')
        self._hwmon = devlib.HwmonInstrument(self._target)

        # Decide which channels we'll collect data from.
        # If the caller provided a channel_map, require that all the named
        # channels exist.
        # Otherwise, try using the big.LITTLE core names as channel names.
        # If they don't match, just collect all available channels.

        available_sites = [c.site for c in self._hwmon.get_channels('energy')]

        self._channels = channel_map
        if self._channels:
            # If the user provides a channel_map then require it to be correct.
            if not all(s in available_sites
                       for s in list(self._channels.values())):
                raise RuntimeError(
                    "Found sites {} but channel_map contains {}".format(
                        sorted(available_sites),
                        sorted(self._channels.values())))
        elif self._target.big_core:
            bl_sites = [
                self._target.big_core.upper(),
                self._target.little_core.upper()
            ]
            if all(s in available_sites for s in bl_sites):
                logger.info('Using default big.LITTLE hwmon channels')
                self._channels = dict(zip(['big', 'LITTLE'], bl_sites))

        if not self._channels:
            logger.info('Using all hwmon energy channels')
            self._channels = {site: site for site in available_sites}

        # Configure channels for energy measurements
        logger.debug('Enabling channels %s', list(self._channels.values()))
        self._hwmon.reset(kinds=['energy'],
                          sites=list(self._channels.values()))

        # Logging enabled channels
        logger.info('Channels selected for energy sampling:')
        for channel in self._hwmon.active_channels:
            logger.info('   %s', channel.label)
Ejemplo n.º 4
0
    def __init__(self, target, hwmon_conf=None, res_dir=None):
        super(HWMon, self).__init__(target, res_dir)

        # The HWMon energy meter
        self._hwmon = None

        # Energy readings
        self.readings = {}

        if 'hwmon' not in self._target.modules:
            logging.info('%14s - HWMON module not enabled', 'EnergyMeter')
            logging.warning('%14s - Energy sampling disabled by configuration',
                            'EnergyMeter')
            return

        # Initialize HWMON instrument
        logging.info(
            '%14s - Scanning for HWMON channels, may take some time...',
            'EnergyMeter')
        self._hwmon = devlib.HwmonInstrument(self._target)

        # Configure channels for energy measurements
        logging.debug('%14s - Enabling channels %s', 'EnergyMeter',
                      hwmon_conf['conf'])
        self._hwmon.reset(**hwmon_conf['conf'])

        # Logging enabled channels
        logging.info('%14s - Channels selected for energy sampling:',
                     'EnergyMeter')
        for channel in self._hwmon.active_channels:
            logging.info('%14s -    %s', 'EnergyMeter', channel.label)

        # record the hwmon channel mapping
        self.little_channel = self._target.little_core.upper()
        self.big_channel = self._target.big_core.upper()
        if hwmon_conf and 'channel_map' in hwmon_conf:
            self.little_channel = hwmon_conf['channel_map']['little']
            self.big_channel = hwmon_conf['channel_map']['big']
        logging.info('%14s - Using channel %s as little channel',
                     'EnergyMeter', self.little_channel)
        logging.info('%14s - Using channel %s as big channel', 'EnergyMeter',
                     self.big_channel)