summaryrefslogtreecommitdiff
path: root/src/cpu/testers/traffic_gen/generators.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2013-05-30 12:54:06 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2013-05-30 12:54:06 -0400
commitfc09bc8678b5e78d553e009105c58e5c5d5befb4 (patch)
tree6d5ff719387cd2e24d549f575576589dbfd98f6e /src/cpu/testers/traffic_gen/generators.cc
parent4931414ca79b97ee64a958c4dd4ed1cafc44b4bd (diff)
downloadgem5-fc09bc8678b5e78d553e009105c58e5c5d5befb4.tar.xz
cpu: Add request elasticity to the traffic generator
This patch adds an optional request elasticity to the traffic generator, effectievly compensating for it in the case of the linear and random generators, and adding it in the case of the trace generator. The accounting is left with the top-level traffic generator, and the individual generators do the necessary math as part of determining the next packet tick. Note that in the linear and random generators we have to compensate for the blocked time to not be elastic, i.e. without this patch the aforementioned generators will slow down in the case of back-pressure.
Diffstat (limited to 'src/cpu/testers/traffic_gen/generators.cc')
-rw-r--r--src/cpu/testers/traffic_gen/generators.cc42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/cpu/testers/traffic_gen/generators.cc b/src/cpu/testers/traffic_gen/generators.cc
index f9556b2b3..8a03e21d0 100644
--- a/src/cpu/testers/traffic_gen/generators.cc
+++ b/src/cpu/testers/traffic_gen/generators.cc
@@ -112,7 +112,7 @@ LinearGen::getNextPacket()
}
Tick
-LinearGen::nextPacketTick() const
+LinearGen::nextPacketTick(bool elastic, Tick delay) const
{
// Check to see if we have reached the data limit. If dataLimit is
// zero we do not have a data limit and therefore we will keep
@@ -123,7 +123,19 @@ LinearGen::nextPacketTick() const
return MaxTick;
} else {
// return the time when the next request should take place
- return curTick() + random_mt.random<Tick>(minPeriod, maxPeriod);
+ Tick wait = random_mt.random<Tick>(minPeriod, maxPeriod);
+
+ // compensate for the delay experienced to not be elastic, by
+ // default the value we generate is from the time we are
+ // asked, so the elasticity happens automatically
+ if (!elastic) {
+ if (wait < delay)
+ wait = 0;
+ else
+ wait -= delay;
+ }
+
+ return curTick() + wait;
}
}
@@ -162,7 +174,7 @@ RandomGen::getNextPacket()
}
Tick
-RandomGen::nextPacketTick() const
+RandomGen::nextPacketTick(bool elastic, Tick delay) const
{
// Check to see if we have reached the data limit. If dataLimit is
// zero we do not have a data limit and therefore we will keep
@@ -173,8 +185,20 @@ RandomGen::nextPacketTick() const
// No more requests. Return MaxTick.
return MaxTick;
} else {
- // Return the time when the next request should take place.
- return curTick() + random_mt.random<Tick>(minPeriod, maxPeriod);
+ // return the time when the next request should take place
+ Tick wait = random_mt.random<Tick>(minPeriod, maxPeriod);
+
+ // compensate for the delay experienced to not be elastic, by
+ // default the value we generate is from the time we are
+ // asked, so the elasticity happens automatically
+ if (!elastic) {
+ if (wait < delay)
+ wait = 0;
+ else
+ wait -= delay;
+ }
+
+ return curTick() + wait;
}
}
@@ -217,7 +241,7 @@ TraceGen::InputStream::read(TraceElement& element)
}
Tick
-TraceGen::nextPacketTick() const
+TraceGen::nextPacketTick(bool elastic, Tick delay) const
{
if (traceComplete) {
DPRINTF(TrafficGen, "No next tick as trace is finished\n");
@@ -232,7 +256,11 @@ TraceGen::nextPacketTick() const
DPRINTF(TrafficGen, "Next packet tick is %d\n", tickOffset +
nextElement.tick);
- return tickOffset + nextElement.tick;
+ // if the playback is supposed to be elastic, add the delay
+ if (elastic)
+ tickOffset += delay;
+
+ return std::max(tickOffset + nextElement.tick, curTick());
}
void