From 9e7a48bf52c1e0cf136dfdce5ba7ecc12768a092 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Wed, 22 Jun 2016 12:34:53 +0100 Subject: [PATCH] libs/utils/trace: add cluster frequency coherency check Usually we work under the assumption that every CPU in a cluster runs at the same frequency, i.e. frequency changes per-cluster and not per-CPU. This adds a simple check to prove this assumption true. Signed-off-by: Michele Di Giorgio --- libs/utils/trace.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libs/utils/trace.py b/libs/utils/trace.py index 38e157b79..d24fa61b2 100644 --- a/libs/utils/trace.py +++ b/libs/utils/trace.py @@ -70,6 +70,9 @@ class Trace(object): # List of events available in the parsed trace self.available_events = [] + # Cluster frequency coherency flag + self.freq_coherency = True + # Folder containing trace if not os.path.isdir(datadir): self.datadir = os.path.dirname(datadir) @@ -124,6 +127,8 @@ class Trace(object): self.__loadTasksNames(tasks) + self.__checkClusterFrequencyCoherency() + # Compute plot window if not normalize_time: start = self.window[0] @@ -377,3 +382,25 @@ class Trace(object): df['start'] = df.index df['len'] = (df.start - df.start.shift()).fillna(0).shift(-1) df.drop('start', axis=1, inplace=True) + + def __chuncker(seq, size): + return (seq.iloc[pos:pos + size] for pos in range(0, len(seq), size)) + + def __checkClusterFrequencyCoherency(self): + """ + """ + if not self.hasEvents('cpu_frequency'): + return + + df = self.df('cpu_frequency') + clusters = self.platform['clusters'] + for c, cpus in clusters.iteritems(): + cluster_df = df[df.cpu.isin(cpus)] + for chunk in self.__chuncker(cluster_df, len(cpus)): + f = chunk.iloc[0].frequency + if any(chunk.frequency != f): + logging.warn('Cluster Frequency is not coherent! '\ + 'Failure in [cpu_frequency] events at:') + logging.warn(chunk) + self.freq_coherency = False + return -- GitLab