changeset 1a21964b7227 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=1a21964b7227
description:
        cpu: Fix state transition bug in the traffic generator

        The traffic generator used to incorrectly determine the next state in
        when state 0 had a non-zero probability. Due to the way the next
        transition was determined, state 0 could never be entered other than
        as an initial state. This changeset updates the transitition() method
        to correctly handle such cases and cases where the transition matrix
        is a 1x1 matrix.

diffstat:

 src/cpu/testers/traffic_gen/traffic_gen.cc |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (23 lines):

diff -r c1a5a20cc1fa -r 1a21964b7227 src/cpu/testers/traffic_gen/traffic_gen.cc
--- a/src/cpu/testers/traffic_gen/traffic_gen.cc        Mon Mar 11 17:45:09 
2013 -0500
+++ b/src/cpu/testers/traffic_gen/traffic_gen.cc        Tue Mar 12 18:41:29 
2013 +0100
@@ -324,13 +324,14 @@
     // determine next state
     double p = random_mt.gen_real1();
     assert(currState < transitionMatrix.size());
-    double cumulative = transitionMatrix[currState][0];
-    size_t i = 1;
-    while (p < cumulative && i != transitionMatrix[currState].size()) {
+    double cumulative = 0.0;
+    size_t i = 0;
+    do {
         cumulative += transitionMatrix[currState][i];
         ++i;
-    }
-    enterState(i);
+    } while (cumulative < p && i < transitionMatrix[currState].size());
+
+    enterState(i - 1);
 }
 
 void
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to