> On Feb. 5, 2013, 4:21 p.m., Nathan Binkert wrote: > > This really confuses me. A the idea of the Formula class was that it was a > > Vector, and we'd simply pretend that Formulas of length 1 were scalars. It > > seems wrong to me to have two classes here and we need to fix the main > > class itself. > > Nilay Vaish wrote: > I second Nate's opinion here. A formula can involve both scalars and > vectors. What would you do then?
The basic functionality of the interface to the classes is there same and therefore does not represent an issue. The issue lies with the total calculation for the different types of statistic. For example, to calculate the total of a vector, we sum each of the elements. The same principle applies for the total for a 2D vector, where we sum each of the "rows" and then also calculate an overall total. However, in the case of a formula it becomes more complex. Specifically, if we were to just sum the value of each element of a vector formula the result would potentially be incorrect. For example, if we are calculating a rate using a formula, then we do not want to sum all of the elements as this will not give the overall rate. Instead we want to calculate the total of the numerators and the total of the denominators before dividing them to get the overall total for the formula. This is the reason that I split the display class into two classes. The total for a vector is calculated "externally", i.e. we take the list representing the vector, and sum all of the values to get the total. This is done as part of the display class. On the other hand, the total for a formula is calculated "internally", i.e. it is calculated by the formula class itself (using abstract syntax trees) by calculating the total for the numerator and denominator separately. Aside from the calculation of the total these classes are identical, but are incompatible. An alternative solution to having separate display classes would be to add an additional layer of indirection which then provides the same interface for getting the total of the vectors and formulas, but hides the mechanics internally. Do you have any better suggestions? Nilay, regarding your question: the formulas can indeed involve both scalars and vectors. However the calculation of the formula is handled using python's eval function. Any formula calculation involving both vectors and scalars will invariably result in a vector result. However, based on the length of the vector, it is either processed directly as a scalar (hence we do not have the issues with the total calculation), or as a vector formula. Does this clarify things? - Sascha ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: http://reviews.gem5.org/r/1678/#review3992 ----------------------------------------------------------- On Jan. 29, 2013, 2:27 a.m., Andreas Hansson wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > http://reviews.gem5.org/r/1678/ > ----------------------------------------------------------- > > (Updated Jan. 29, 2013, 2:27 a.m.) > > > Review request for Default. > > > Description > ------- > > Changeset 9513:6e1f6c9cd4ac > --------------------------- > stats: Add a separate display class for vector formulas > > This patch adds a separate display class for vector formulas, which is > tailored to more closely resemble that of the original C++ based > stats. Unlike the vector class, the total for a formula needs to be > evaluated by calculating the total of the numerator and the total of > the denominator, and then dividing them. Therefore, the vector formula > display class calls the total function of the formula, rather than > evaluating the total locally. > > > Diffs > ----- > > src/python/m5/stats/display.py PRE-CREATION > > Diff: http://reviews.gem5.org/r/1678/diff/ > > > Testing > ------- > > > Thanks, > > Andreas Hansson > > _______________________________________________ gem5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/gem5-dev
