changeset f954ee138ca3 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=f954ee138ca3
description:
Ruby: Ensure order-dependent iteration uses an ordered map
This patch fixes a bug in Ruby that caused non-deterministic
simulation when changing the underlying hash map implementation. The
reason is order-dependent behaviour in combination with iteration over
the hash map contents. The two locations where a sorted container is
assumed are now changed to make use of a std::map instead of the
unordered hash map.
With this change, the stats changes slightly and the follow-on
changeset will update the relevant statistics.
diffstat:
src/mem/ruby/buffers/MessageBuffer.hh | 4 +++-
src/mem/ruby/system/TimerTable.hh | 6 ++++--
src/mem/slicc/symbols/StateMachine.py | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
diffs (49 lines):
diff -r 5534a564f6a0 -r f954ee138ca3 src/mem/ruby/buffers/MessageBuffer.hh
--- a/src/mem/ruby/buffers/MessageBuffer.hh Mon Apr 09 23:20:30 2012 -0700
+++ b/src/mem/ruby/buffers/MessageBuffer.hh Thu Apr 12 08:35:49 2012 -0400
@@ -162,7 +162,9 @@
Consumer* m_consumer_ptr; // Consumer to signal a wakeup(), can be NULL
std::vector<MessageBufferNode> m_prio_heap;
- typedef m5::hash_map< Address, std::list<MsgPtr> > StallMsgMapType;
+ // use a std::map for the stalled messages as this container is
+ // sorted and ensures a well-defined iteration order
+ typedef std::map< Address, std::list<MsgPtr> > StallMsgMapType;
typedef std::vector<MsgPtr>::iterator MsgListIter;
StallMsgMapType m_stall_msg_map;
diff -r 5534a564f6a0 -r f954ee138ca3 src/mem/ruby/system/TimerTable.hh
--- a/src/mem/ruby/system/TimerTable.hh Mon Apr 09 23:20:30 2012 -0700
+++ b/src/mem/ruby/system/TimerTable.hh Thu Apr 12 08:35:49 2012 -0400
@@ -33,7 +33,6 @@
#include <iostream>
#include <string>
-#include "base/hashmap.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/Global.hh"
@@ -74,7 +73,10 @@
TimerTable& operator=(const TimerTable& obj);
// Data Members (m_prefix)
- typedef m5::hash_map<Address, Time> AddressMap;
+
+ // use a std::map for the address map as this container is sorted
+ // and ensures a well-defined iteration order
+ typedef std::map<Address, Time> AddressMap;
AddressMap m_map;
mutable bool m_next_valid;
mutable Time m_next_time; // Only valid if m_next_valid is true
diff -r 5534a564f6a0 -r f954ee138ca3 src/mem/slicc/symbols/StateMachine.py
--- a/src/mem/slicc/symbols/StateMachine.py Mon Apr 09 23:20:30 2012 -0700
+++ b/src/mem/slicc/symbols/StateMachine.py Thu Apr 12 08:35:49 2012 -0400
@@ -324,7 +324,7 @@
bool m_is_blocking;
std::map<Address, MessageBuffer*> m_block_map;
typedef std::vector<MessageBuffer*> MsgVecType;
-typedef m5::hash_map< Address, MsgVecType* > WaitingBufType;
+typedef std::map< Address, MsgVecType* > WaitingBufType;
WaitingBufType m_waiting_buffers;
int m_max_in_port_rank;
int m_cur_in_port_rank;
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev