• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: Apache-2.0
2#
3# Copyright (C) 2015, ARM Limited and contributors.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18import logging
19
20""" Helper module for Analysis classes """
21
22
23class AnalysisModule(object):
24    """
25    Base class for Analysis modules.
26
27    :param trace: input Trace object
28    :type trace: :mod:`libs.utils.Trace`
29    """
30
31    def __init__(self, trace):
32
33        self._log = logging.getLogger('Analysis')
34
35        self._trace = trace
36        self._platform = trace.platform
37        self._tasks = trace.tasks
38        self._data_dir = trace.data_dir
39
40        self._dfg_trace_event = trace._dfg_trace_event
41
42        trace._registerDataFrameGetters(self)
43
44        # Further initialization not possible if platform info is missing
45        if not self._platform:
46            return
47
48        # By default assume SMP system
49        self._big_cap = 1024
50        self._little_cap = 1024
51        nrg_model = self._platform.get('nrg_model', None)
52        if nrg_model:
53            try:
54                self._big_cap = nrg_model['big']['cpu']['cap_max']
55                self._little_cap = nrg_model['little']['cpu']['cap_max']
56            except TypeError:
57                self._log.debug('Failed parsing EM from platform data')
58        else:
59            self._log.debug('Platform data without Energy Model info')
60
61        # By default assume SMP system
62        self._big_cpus = []
63        self._little_cpus = []
64        if 'big' in self._platform['clusters']:
65            self._log.debug('Parsing big.LITTLE system clusters')
66            self._big_cpus = self._platform['clusters']['big']
67            self._little_cpus = self._platform['clusters']['little']
68        else:
69            self._log.debug('Parsing SMP clusters')
70            for cid in self._platform['clusters']:
71                self._big_cpus.append(self._platform['clusters'][cid])
72
73# vim :set tabstop=4 shiftwidth=4 expandtab
74