diff -r 10df991a6ac9 -r 6e1f6c9cd4ac src/python/m5/stats/display.py --- a/src/python/m5/stats/display.py Tue Jan 29 10:24:04 2013 +0000 +++ b/src/python/m5/stats/display.py Tue Jan 29 10:28:27 2013 +0000 @@ -216,6 +216,67 @@ p.value = mytotal p.display(out) +## @brief Class to display a vector forula +class VectorFormulaDisplay(DisplayBase): + ## @brief Display the value if it is non zero + # @param out The output to which we want to print. + def display(self, out): + if not self.value: + return + + p = Display(self) + p.flags = self.flags + p.precision = self.precision + + # If the value is not a list or a tuple, just print the value. + if not isinstance(self.value, (list, tuple)): + p.name = self.name + p.desc = self.desc + p.value = self.value + p.display(out) + return + + mytotal = self.total + mycdf = 0.0 + + value = self.value + if any(self.subnames): + subnames = [''] * len(value) + for i,subname in enumerate(self.subnames): + if subname: + subnames[i] = '::%s' % subname + else: + subnames = [ '::%d' % i for i in range(len(value)) ] + + subdescs = [self.desc] * len(value) + if self.subdescs: + for i in xrange(min(len(value), len(self.subdescs))): + if self.subdescs[i]: + subdescs[i] = self.subdescs[i] + + for val,sname,sdesc in map(None, value, subnames, subdescs): + if mytotal > 0.0: + mypdf = float(val) / float(mytotal) + mycdf += mypdf + if (self.flags & flags.pdf): + p.pdf = mypdf + p.cdf = mycdf + + if not sname: + continue + + p.name = self.name + sname + p.desc = sdesc + p.value = val + p.display(out) + + if self.flags & flags.total: + p.reset() + p.name = self.name + '::total' + p.desc = self.desc + p.value = mytotal + p.display(out) + ## @brief Display a distribution. Begin by printing the number of samples, the # mean and the standard deviation. This is followed by printing the # distribution itself. @@ -332,7 +393,13 @@ if scalar(stat): display_scalar(stat, out) elif vector(stat): - display_vector(stat, out) + if len(stat) == 1: + p = Display(stat) + p.value = value(stat, 0) + else: + p = VectorFormulaDisplay(stat) + p.value = [ value(stat, i) for i in xrange(len(stat)) ] + p.display(out) @register_display(Dist) ## @brief Function to display a distribution.