summaryrefslogtreecommitdiff
path: root/src/cpu/testers/traffic_gen/generators.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-09-03 07:42:54 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2014-09-03 07:42:54 -0400
commit2698e739660516af442c0f913eb0e91a00e7b7db (patch)
tree331dfa865e3b36d5187353fe3db57f93c73eb0e0 /src/cpu/testers/traffic_gen/generators.cc
parent1ff4c45bbbaa22d5bd91e9bdd34d4435290ab8be (diff)
downloadgem5-2698e739660516af442c0f913eb0e91a00e7b7db.tar.xz
base: Use the global Mersenne twister throughout
This patch tidies up random number generation to ensure that it is done consistently throughout the code base. In essence this involves a clean-up of Ruby, and some code simplifications in the traffic generator. As part of this patch a bunch of skewed distributions (off-by-one etc) have been fixed. Note that a single global random number generator is used, and that the object instantiation order will impact the behaviour (the sequence of numbers will be unaffected, but if module A calles random before module B then they would obviously see a different outcome). The dependency on the instantiation order is true in any case due to the execution-model of gem5, so we leave it as is. Also note that the global ranom generator is not thread safe at this point. Regressions using the memtest, TrafficGen or any Ruby tester are affected and will be updated accordingly.
Diffstat (limited to 'src/cpu/testers/traffic_gen/generators.cc')
-rw-r--r--src/cpu/testers/traffic_gen/generators.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/cpu/testers/traffic_gen/generators.cc b/src/cpu/testers/traffic_gen/generators.cc
index 7c6bab92c..135765fce 100644
--- a/src/cpu/testers/traffic_gen/generators.cc
+++ b/src/cpu/testers/traffic_gen/generators.cc
@@ -84,7 +84,7 @@ LinearGen::getNextPacket()
{
// choose if we generate a read or a write here
bool isRead = readPercent != 0 &&
- (readPercent == 100 || random_mt.random<uint8_t>(0, 100) < readPercent);
+ (readPercent == 100 || random_mt.random(0, 100) < readPercent);
assert((readPercent == 0 && !isRead) || (readPercent == 100 && isRead) ||
readPercent != 100);
@@ -124,7 +124,7 @@ LinearGen::nextPacketTick(bool elastic, Tick delay) const
return MaxTick;
} else {
// return the time when the next request should take place
- Tick wait = random_mt.random<Tick>(minPeriod, maxPeriod);
+ Tick wait = random_mt.random(minPeriod, maxPeriod);
// compensate for the delay experienced to not be elastic, by
// default the value we generate is from the time we are
@@ -152,13 +152,13 @@ RandomGen::getNextPacket()
{
// choose if we generate a read or a write here
bool isRead = readPercent != 0 &&
- (readPercent == 100 || random_mt.random<uint8_t>(0, 100) < readPercent);
+ (readPercent == 100 || random_mt.random(0, 100) < readPercent);
assert((readPercent == 0 && !isRead) || (readPercent == 100 && isRead) ||
readPercent != 100);
// address of the request
- Addr addr = random_mt.random<Addr>(startAddr, endAddr - 1);
+ Addr addr = random_mt.random(startAddr, endAddr - 1);
// round down to start address of block
addr -= addr % blocksize;
@@ -184,15 +184,14 @@ DramGen::getNextPacket()
// choose if we generate a read or a write here
isRead = readPercent != 0 &&
- (readPercent == 100 ||
- random_mt.random<uint8_t>(0, 100) < readPercent);
+ (readPercent == 100 || random_mt.random(0, 100) < readPercent);
assert((readPercent == 0 && !isRead) ||
(readPercent == 100 && isRead) ||
readPercent != 100);
// start by picking a random address in the range
- addr = random_mt.random<Addr>(startAddr, endAddr - 1);
+ addr = random_mt.random(startAddr, endAddr - 1);
// round down to start address of a block, i.e. a DRAM burst
addr -= addr % blocksize;
@@ -275,7 +274,7 @@ RandomGen::nextPacketTick(bool elastic, Tick delay) const
return MaxTick;
} else {
// return the time when the next request should take place
- Tick wait = random_mt.random<Tick>(minPeriod, maxPeriod);
+ Tick wait = random_mt.random(minPeriod, maxPeriod);
// compensate for the delay experienced to not be elastic, by
// default the value we generate is from the time we are