RFD: profile standard deviation of # of loop iterations?
Joern Rennecke
joern.rennecke@superh.com
Tue Mar 16 12:34:00 GMT 2004
We currently seem to assume that the probability for a loop to end is equal
at each iteration. I think this is a rather unrealistic assumption.
And it does not only matter in getting probabilities right after unrolling,
but also in deciding what unrolling factor is best to start with.
The current profile-arcs framework gives us the number of executions for
the loop header and for the loop body, which allows us to just calculate
the average number of iterations.
To be able to calculate the standard deviation, we'd have to keep track
of the sum of the squares of loop iterations.
One way to do this would entail to keep track of the total number of loop
iterations at the finish of the last loop, which would be initialized to zero.
After the end of a loop, we subtract the previous total iterations from
current total iterations, square the difference, and add the result to
the sum of squares of loop iterations. Then we copy the current total
number of loop iterations to the previous number of loop iterations.
The instrumentation point for this need not necessarily be after the loop;
we could also do this before the loop, and in addition to that at function
or program end to capture the last loop run.
More information about the Gcc
mailing list