From 2698e739660516af442c0f913eb0e91a00e7b7db Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Wed, 3 Sep 2014 07:42:54 -0400 Subject: 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. --- src/mem/ruby/network/simple/PerfectSwitch.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mem/ruby/network/simple/PerfectSwitch.cc') diff --git a/src/mem/ruby/network/simple/PerfectSwitch.cc b/src/mem/ruby/network/simple/PerfectSwitch.cc index fa0709496..caf07b3cf 100644 --- a/src/mem/ruby/network/simple/PerfectSwitch.cc +++ b/src/mem/ruby/network/simple/PerfectSwitch.cc @@ -29,6 +29,7 @@ #include #include "base/cast.hh" +#include "base/random.hh" #include "debug/RubyNetwork.hh" #include "mem/ruby/network/MessageBuffer.hh" #include "mem/ruby/network/simple/PerfectSwitch.hh" @@ -169,7 +170,8 @@ PerfectSwitch::operateVnet(int vnet) out_queue_length += m_out[out][v]->getSize(); } int value = - (out_queue_length << 8) | (random() & 0xff); + (out_queue_length << 8) | + random_mt.random(0, 0xff); m_link_order[out].m_link = out; m_link_order[out].m_value = value; } -- cgit v1.2.3